static void Main(string[] args) { try { // Print waypoints between JFK and SIN Rhumb rhumb = new Rhumb(Constants.WGS84.EquatorialRadius, Constants.WGS84.Flattening, true); // Alternatively: const Rhumb& rhumb = Rhumb::WGS84(); double lat1 = 40.640, lon1 = -73.779, // JFK lat2 = 1.359, lon2 = 103.989; // SIN double s12, azi12; rhumb.Inverse(lat1, lon1, lat2, lon2, out s12, out azi12); RhumbLine line = rhumb.Line(lat1, lon1, azi12); // Alternatively // const GeographicLib::RhumbLine line = rhumb.Line(lat1, lon1, azi1); double ds = 500e3; // Nominal distance between points = 500 km int num = (int)Math.Ceiling(s12 / ds); // The number of intervals { // Use intervals of equal length ds = s12 / num; for (int i = 0; i <= num; ++i) { double lat, lon; line.Position(i * ds, out lat, out lon); Console.WriteLine("{0} {1} {2}", i, lat, lon); } } } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } }
private void OnValidate(object sender, EventArgs e) { try { Rhumb r = new Rhumb(NETGeographicLib.Constants.WGS84.MajorRadius, NETGeographicLib.Constants.WGS84.Flattening, true); double lat1 = 32.0, lon1 = -86.0, azi12 = 45.0, s12 = 5000.0; double lat2, lon2, _s12, _azi12, Area, _Area; r.Direct(lat1, lon1, azi12, s12, out lat2, out lon2); r.Inverse(lat1, lon1, lat2, lon2, out _s12, out _azi12); if (Test(s12, _s12) || Test(azi12, _azi12)) { throw new Exception(String.Format("Inverse != Direct: S12 -> {0}, {1}, azi12 -> {2}, {3}", s12, _s12, azi12, _azi12)); } r.Direct(lat1, lon1, azi12, s12, out lat2, out lon2, out Area); r.Inverse(lat1, lon1, lat2, lon2, out _s12, out _azi12, out _Area); if (Test(s12, _s12) || Test(azi12, _azi12) || Test(Area, _Area)) { throw new Exception(String.Format("Inverse != Direct: S12 -> {0}, {1}, azi12 -> {2}, {3}, Area -> {4}, {5}", s12, _s12, azi12, _azi12, Area, _Area)); } double _lat2, _lon2; RhumbLine l = r.Line(lat1, lon1, azi12); l.Position(s12, out _lat2, out _lon2); if (Test(lat2, _lat2) || Test(lon2, _lon2)) { throw new Exception(String.Format("Latitude -> {0}, {1}, Longitude -> {2}, {3}", lat2, _lat2, lon2, _lon2)); } l.Position(s12, out _lat2, out _lon2, out _Area); if (Test(lat2, _lat2) || Test(lon2, _lon2) || Test(Area, _Area)) { throw new Exception(String.Format("Latitude -> {0}, {1}, Longitude -> {2}, {3}, Area -> {4}, {5}", lat2, _lat2, lon2, _lon2, Area, _Area)); } MessageBox.Show("No exceptions detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Exception thrown", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void GeneratePoints(double lat1, double lon1, double azimuth, double space) { RhumbLine line = m_rhumb.Line(lat1, lon1, azimuth); m_pointsView.Items.Clear(); for (int i = 0; i < 5; i++) { double lat2, lon2; line.Position(i * space, out lat2, out lon2); string[] items = new string[2] { lat2.ToString(), lon2.ToString() }; ListViewItem item = new ListViewItem(items); m_pointsView.Items.Add(item); } }