static void Main(string[] args) { try { Rhumb rhumb = new Rhumb(Constants.WGS84.EquatorialRadius, Constants.WGS84.Flattening, true); // Alternatively: const Rhumb& rhumb = Rhumb::WGS84(); { // Sample direct calculation, travelling about NE from JFK double lat1 = 40.6, lon1 = -73.8, s12 = 5.5e6, azi12 = 51; double lat2, lon2; rhumb.Direct(lat1, lon1, azi12, s12, out lat2, out lon2); Console.WriteLine("{0} {1}", lat2, lon2); } { // Sample inverse calculation, JFK to LHR double lat1 = 40.6, lon1 = -73.8, // JFK Airport lat2 = 51.6, lon2 = -0.5; // LHR Airport double s12, azi12; rhumb.Inverse(lat1, lon1, lat2, lon2, out s12, out azi12); Console.WriteLine("{0} {1}", s12, azi12); } } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } }
static void Main(string[] args) { try { // Print waypoints between JFK and SIN Rhumb rhumb = new Rhumb(Constants.WGS84.MajorRadius, 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)); } }
static void Main(string[] args) { try { Rhumb rhumb = new Rhumb(Constants.WGS84.MajorRadius, Constants.WGS84.Flattening, true); // Alternatively: const Rhumb& rhumb = Rhumb::WGS84(); { // Sample direct calculation, travelling about NE from JFK double lat1 = 40.6, lon1 = -73.8, s12 = 5.5e6, azi12 = 51; double lat2, lon2; rhumb.Direct(lat1, lon1, azi12, s12, out lat2, out lon2); Console.WriteLine( "{0} {1}", lat2, lon2 ); } { // Sample inverse calculation, JFK to LHR double lat1 = 40.6, lon1 = -73.8, // JFK Airport lat2 = 51.6, lon2 = -0.5; // LHR Airport double s12, azi12; rhumb.Inverse(lat1, lon1, lat2, lon2, out s12, out azi12); Console.WriteLine( "{0} {1}", s12, azi12 ); } } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } }
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)); } }
public void RhumbSolve0_TestFixToBadHandlingOfPole() { var rhe = new Rhumb(Ellipsoid.WGS84); var rh = new Rhumb(Ellipsoid.WGS84, false); rhe.Inverse(0, 0, 90, 0, out var s12, out var azi12, out var S12); Assert.AreEqual(0, azi12, 0.01); Assert.AreEqual(10001965.729, s12, 0.001); Assert.AreEqual(0, S12, 0.1); rh.Inverse(0, 0, 90, 0, out s12, out azi12, out S12); Assert.AreEqual(0, azi12, 0.01); Assert.AreEqual(10001965.729, s12, 0.001); Assert.AreEqual(0, S12, 0.1); rhe.Inverse(0, 0, 90, 30, out s12, out azi12, out S12); Assert.AreEqual(0.41222947, azi12, 1e-8); Assert.AreEqual(10002224.609, s12, 0.001); Assert.AreEqual(21050634712282, S12, 0.1); rh.Inverse(0, 0, 90, 30, out s12, out azi12, out S12); Assert.AreEqual(0.41222947, azi12, 1e-8); Assert.AreEqual(10002224.609, s12, 0.001); Assert.AreEqual(21050634712282, S12, 0.1); }
public RhumbPanel() { InitializeComponent(); m_rhumb = Rhumb.WGS84(); m_Lat1TextBox.Text = "32"; m_lon1TextBox.Text = "-86"; m_lat2TextBox.Text = "33"; m_lon2TextBox.Text = "-87"; OnIndirect(this, null); }
public void TestDirect(string p1, string p2, double azi12, double s12, double S12, bool exact) { var c1 = new GeoCoords(p1); var c2 = new GeoCoords(p2); var rhumb = new Rhumb(Ellipsoid.WGS84, exact); rhumb.Direct(c1.Latitude, c1.Longitude, azi12, s12, out var _lat2, out var _lon2, out var _S12); Assert.AreEqual(c2.Latitude, _lat2, 1e-8); Assert.AreEqual(c2.Longitude, _lon2, 1e-8); Assert.AreEqual(S12, _S12, 0.01); var result = rhumb.Direct(c1.Latitude, c1.Longitude, azi12, s12); Assert.AreEqual(c2.Latitude, result.Latitude, 1e-8); Assert.AreEqual(c2.Longitude, result.Longitude, 1e-8); Assert.AreEqual(S12, result.Area, 0.01); }
public void TestInverse(string p1, string p2, double azi12, double s12, double S12, bool exact) { var c1 = new GeoCoords(p1); var c2 = new GeoCoords(p2); var rhumb = new Rhumb(Ellipsoid.WGS84, exact); rhumb.Inverse(c1.Latitude, c1.Longitude, c2.Latitude, c2.Longitude, out var _s12, out var _azi12, out var _S12); Assert.AreEqual(azi12, _azi12, 1e-8); Assert.AreEqual(s12, _s12, 1e-8); Assert.AreEqual(S12, _S12, 0.05); var result = rhumb.Inverse(c1.Latitude, c1.Longitude, c2.Latitude, c2.Longitude); Assert.AreEqual(azi12, result.Azimuth, 1e-8); Assert.AreEqual(s12, result.Distance, 1e-8); Assert.AreEqual(S12, result.Area, 0.05); }
private void OnValidate(object sender, EventArgs e) { try { double lat, lon, perim, area; PolygonArea pa = new PolygonArea(new Geodesic(50000.0, 0.001), true); pa = new PolygonArea(false); pa.AddPoint(32.0, -86.0); pa.AddEdge(20.0, 10000.0); pa.AddEdge(-45.0, 10000.0); pa.CurrentPoint(out lat, out lon); pa.Compute(false, false, out perim, out area); pa.TestEdge(-70.0, 5000.0, false, false, out perim, out area); pa.TestPoint(31.0, -86.5, false, false, out perim, out area); PolygonAreaExact p2 = new PolygonAreaExact(new GeodesicExact(), false); p2.AddPoint(32.0, -86.0); p2.AddEdge(20.0, 10000.0); p2.AddEdge(-45.0, 10000.0); p2.CurrentPoint(out lat, out lon); p2.Compute(false, false, out perim, out area); p2.TestEdge(-70.0, 5000.0, false, false, out perim, out area); p2.TestPoint(31.0, -86.5, false, false, out perim, out area); PolygonAreaRhumb p3 = new PolygonAreaRhumb(Rhumb.WGS84(), false); p3.AddPoint(32.0, -86.0); p3.AddEdge(20.0, 10000.0); p3.AddEdge(-45.0, 10000.0); p3.CurrentPoint(out lat, out lon); p3.Compute(false, false, out perim, out area); p3.TestEdge(-70.0, 5000.0, false, false, out perim, out area); p3.TestPoint(31.0, -86.5, false, false, out perim, out area); MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception xcpt) { MessageBox.Show(xcpt.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 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 ); } }