Esempio n. 1
0
 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));
     }
 }
Esempio n. 2
0
 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));
     }
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
 private void OnDirect(object sender, EventArgs e)
 {
     try
     {
         double lat1 = Double.Parse(m_Lat1TextBox.Text);
         double lon1 = Double.Parse(m_lon1TextBox.Text);
         double s12 = Double.Parse(m_s12TextBox.Text);
         double azimuth = Double.Parse(m_azimuthTextBox.Text);
         double lat2, lon2;
         m_rhumb.Direct(lat1, lon1, azimuth, s12, out lat2, out lon2);
         m_lat2TextBox.Text = lat2.ToString();
         m_lon2TextBox.Text = lon2.ToString();
         GeneratePoints(lat1, lon1, azimuth, 0.25 * s12);
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 6
0
        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 );
            }
        }