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); } }
private void OnHeight(object sender, EventArgs e) { try { double lat = Double.Parse(m_latitudeTextBox.Text); double lon = Double.Parse(m_longitudeTextBox.Text); m_ellipsoidTextBox.Text = m_geoid.Height(lat, lon).ToString(); m_geoidTextBox.Text = "0"; } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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)); } }
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); } }