Beispiel #1
0
        private void OnSelectFile(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter     = "Geoid File (*.pgm)|*.pgm";
            dlg.DefaultExt = "pgm";
            dlg.Title      = "Open Geoid File";

            if (dlg.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            m_path = dlg.FileName.Substring(0, dlg.FileName.LastIndexOf('\\')).Replace('\\', '/');
            int length = dlg.FileName.LastIndexOf('.') - dlg.FileName.LastIndexOf('\\') - 1;

            m_fileName = dlg.FileName.Substring(dlg.FileName.LastIndexOf('\\') + 1, length);

            try
            {
                m_geoid = new Geoid(m_fileName, m_path, true, m_threadSafeCheckBox.Checked);
            }
            catch (Exception xcpt)
            {
                MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            m_convertEllipsodButton.Enabled = m_convertGeoidButton.Enabled = m_heightButton.Enabled = m_validateButton.Enabled = true;
            m_geoidFileNameTextBox.Text     = dlg.FileName;
            m_dateTimeTextBox.Text          = m_geoid.DateTime;
            m_descriptionTextBox.Text       = m_geoid.Description;
            m_majorRadiusTextBox.Text       = m_geoid.EquatorialRadius.ToString();
            m_flatteningTtextBox.Text       = m_geoid.Flattening.ToString();
        }
Beispiel #2
0
        /// <summary>
        /// troposphere mapping function
        /// compute tropospheric mapping function by GMF or NMF or......
        /// </summary>
        /// <param name="time">time</param>
        /// <param name="pos">receiver position {lat, lon, h} (rad, m)</param>
        /// <param name="zael">azimuth/elevation angle {az, el} (rad)</param>
        /// <param name="mapfw">wet mapping function (null : not output)</param>
        /// <returns></returns>
        public double tropmapf(Time time, GeoCoord pos, double[] azel, ref double mapfw)
        {
            Time ep = new Time(2000, 1, 1, 12);

            Geoid geoid = new Geoid();

            if (pos.Height < -1000.0 || pos.Height > 20000.0)
            {
                mapfw = 0.0;
                return(0.0);
            }


            double mjd = 51544.5 + (double)(time - ep) / 86400.0;

            double lat = pos.Lat * SunMoonPosition.DegToRad;

            double lon = pos.Lon * SunMoonPosition.DegToRad;

            double hgt = pos.Height - geoid.geoidh(pos);

            double zd = SunMoonPosition.PI / 2.0 - azel[1];

            double gmfh = 0.0, mapf = 0.0;

            gmf(mjd, lat, lon, hgt, zd, ref gmfh, ref mapf);

            mapfw = mapf;

            return(gmfh);
        }
Beispiel #3
0
        public void Test_EvaluateWithoutCache(string c, double height)
        {
            using (var geoid = new Geoid("egm84-30",
                                         Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "geoids")))
            {
                var coord = new GeoCoords(c);
                var h     = geoid.Evaluate(coord);

                Assert.AreEqual(height, h, 1e-4);
            }
        }
Beispiel #4
0
 public void Test_Load()
 {
     using (var geoid = new Geoid("egm84-30",
                                  Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "geoids")))
     {
         Assert.AreEqual("WGS84 EGM84, 30-minute grid", geoid.Description);
         Assert.AreEqual(DateTime.Parse("2009-08-29 18:45:02"), geoid.DateTime);
         Assert.AreEqual(0.274, geoid.MaxError);
         Assert.AreEqual(0.014, geoid.RMSError);
         Assert.AreEqual(-108, geoid.Offset);
         Assert.AreEqual(0.003, geoid.Scale);
     }
 }
Beispiel #5
0
 static void Main(string[] args)
 {
     try {
         Geoid egm96 = new Geoid("egm96-5", "", true, false);
         // Convert height above egm96 to height above the ellipsoid
         double lat = 42, lon = -75, height_above_geoid = 20;
         double
             geoid_height           = egm96.Height(lat, lon),
             height_above_ellipsoid = (height_above_geoid +
                                       (double)Geoid.ConvertFlag.GEOIDTOELLIPSOID * geoid_height);
         Console.WriteLine(height_above_ellipsoid);
     }
     catch (GeographicErr e) {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
Beispiel #6
0
 static void Main(string[] args)
 {
     try {
         Geoid egm96 = new Geoid("egm96-5", "", true, false);
         // Convert height above egm96 to height above the ellipsoid
         double lat = 42, lon = -75, height_above_geoid = 20;
         double
             geoid_height = egm96.Height(lat, lon),
             height_above_ellipsoid = (height_above_geoid +
                 (double)Geoid.ConvertFlag.GEOIDTOELLIPSOID * geoid_height);
         Console.WriteLine(height_above_ellipsoid);
     }
     catch (GeographicErr e) {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
Beispiel #7
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         Geoid g = new Geoid(m_fileName, m_path, false, false);
         g.CacheArea(20.0, -30.0, 30.0, -20.0);
         g.CacheAll();
         double h2 = g.Height(32.0, -60.0);
         g.ConvertHeight(32.0, -60.0, 100.0, Geoid.ConvertFlag.ELLIPSOIDTOGEOID);
         MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #8
0
 private void OnThreadSafe(object sender, EventArgs e)
 {
     if (m_geoidFileNameTextBox.Text.Length > 0)
     {
         try
         {
             m_geoid = new Geoid(m_fileName, m_path, true, m_threadSafeCheckBox.Checked);
         }
         catch (Exception xcpt)
         {
             MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     m_cacheButton.Enabled   = !m_threadSafeCheckBox.Checked;
     m_northTextBox.ReadOnly = m_southTextBox.ReadOnly = m_eastTextBox.ReadOnly = m_westTextBox.ReadOnly = m_threadSafeCheckBox.Checked;
 }
Beispiel #9
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         Geoid g = new Geoid(m_fileName, m_path, false, false);
         g.CacheArea(20.0, -30.0, 30.0, -20.0);
         g.CacheAll();
         double gradx, grady;
         double h1 = g.Height(32.0, -60.0, out gradx, out grady);
         double h2 = g.Height(32.0, -60.0);
         if (h1 != h2)
             throw new Exception("Error in Geoid.Height");
         g.ConvertHeight(32.0, -60.0, 100.0, Geoid.ConvertFlag.ELLIPSOIDTOGEOID);
         MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #10
0
 private void OnThreadSafe(object sender, EventArgs e)
 {
     if (m_geoidFileNameTextBox.Text.Length > 0)
     {
         try
         {
             m_geoid = new Geoid(m_fileName, m_path, true, m_threadSafeCheckBox.Checked);
         }
         catch (Exception xcpt)
         {
             MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     m_cacheButton.Enabled = !m_threadSafeCheckBox.Checked;
     m_northTextBox.ReadOnly = m_southTextBox.ReadOnly = m_eastTextBox.ReadOnly = m_westTextBox.ReadOnly = m_threadSafeCheckBox.Checked;
 }
Beispiel #11
0
        private void OnSelectFile(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Geoid File (*.pgm)|*.pgm";
            dlg.DefaultExt = "pgm";
            dlg.Title = "Open Geoid File";

            if (dlg.ShowDialog() == DialogResult.Cancel) return;

            m_path = dlg.FileName.Substring(0, dlg.FileName.LastIndexOf('\\')).Replace('\\', '/');
            int length = dlg.FileName.LastIndexOf('.') - dlg.FileName.LastIndexOf('\\') - 1;
            m_fileName = dlg.FileName.Substring(dlg.FileName.LastIndexOf('\\') + 1, length);

            try
            {
                m_geoid = new Geoid(m_fileName, m_path, true, m_threadSafeCheckBox.Checked);
            }
            catch (Exception xcpt)
            {
                MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            m_convertEllipsodButton.Enabled = m_convertGeoidButton.Enabled = m_heightButton.Enabled = m_validateButton.Enabled = true;
            m_geoidFileNameTextBox.Text = dlg.FileName;
            m_dateTimeTextBox.Text = m_geoid.DateTime;
            m_descriptionTextBox.Text = m_geoid.Description;
            m_majorRadiusTextBox.Text = m_geoid.MajorRadius.ToString();
            m_flatteningTtextBox.Text = m_geoid.Flattening.ToString();
        }