Exemplo n.º 1
0
 static void Main(string[] args)
 {
     try {
         Geodesic       geod = new Geodesic();                       // WGS84
         const double   lat0 = 48 + 50 / 60.0, lon0 = 2 + 20 / 60.0; // Paris
         CassiniSoldner proj = new CassiniSoldner(lat0, lon0, geod);
         {
             // Sample forward calculation
             double lat = 50.9, lon = 1.8; // Calais
             double x, y;
             proj.Forward(lat, lon, out x, out y);
             Console.WriteLine(String.Format("X: {0} Y: {1}", x, y));
         }
         {
             // Sample reverse calculation
             double x = -38e3, y = 230e3;
             double lat, lon;
             proj.Reverse(x, y, out lat, out lon);
             Console.WriteLine(String.Format("Latitude: {0} Longitude: {1}", lat, lon));
         }
     }
     catch (GeographicErr e) {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     try {
         Geodesic geod = new Geodesic(); // WGS84
         const double lat0 = 48 + 50/60.0, lon0 = 2 + 20/60.0; // Paris
         CassiniSoldner proj = new CassiniSoldner(lat0, lon0, geod);
         {
             // Sample forward calculation
             double lat = 50.9, lon = 1.8; // Calais
             double x, y;
             proj.Forward(lat, lon, out x, out y);
             Console.WriteLine(String.Format("X: {0} Y: {1}", x, y));
         }
         {
             // Sample reverse calculation
             double x = -38e3, y = 230e3;
             double lat, lon;
             proj.Reverse(x, y, out lat, out lon);
             Console.WriteLine(String.Format("Latitude: {0} Longitude: {1}", lat, lon));
         }
     }
     catch (GeographicErr e) {
         Console.WriteLine( String.Format( "Caught exception: {0}", e.Message ) );
     }
 }
Exemplo n.º 3
0
        public void GeodesicProj0_TestFixToCassiniSoldner_ForwardBug()
        {
            var cass = new CassiniSoldner();

            var(x, _) = cass.Forward(90, 80, out var azi, out _);
            Assert.AreEqual(0.0, x, 0.1);
            Assert.AreEqual(170.0, azi, 0.1);
        }
Exemplo n.º 4
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         double lat = 0.0, lon = 0.0, x = 0.0, y = 0.0, x1 = 0.0, y1 = 0.0, azi = 0.0, rk = 0.0;
         AzimuthalEquidistant azimuthal = new AzimuthalEquidistant(m_geodesic);
         azimuthal = new AzimuthalEquidistant();
         azimuthal.Forward(32.0, -86.0, 33.0, -87.0, out x, out y, out azi, out rk);
         azimuthal.Forward(32.0, -86.0, 33.0, -87.0, out x1, out y1);
         if (x != x1 || y != y1)
         {
             throw new Exception("Error in AzimuthalEquidistant.Forward");
         }
         azimuthal.Reverse(32.0, -86.0, x, y, out lat, out lon, out azi, out rk);
         azimuthal.Reverse(32.0, -86.0, x, y, out x1, out y1);
         if (x1 != lat || y1 != lon)
         {
             throw new Exception("Error in AzimuthalEquidistant.Reverse");
         }
         CassiniSoldner cassini         = new CassiniSoldner(32.0, -86.0, m_geodesic);
         cassini = new CassiniSoldner(32.0, -86.0);
         cassini.Reset(31.0, -87.0);
         cassini.Forward(32.0, -86.0, out x, out y, out azi, out rk);
         cassini.Forward(32.0, -86.0, out x1, out y1);
         if (x != x1 || y != y1)
         {
             throw new Exception("Error in CassiniSoldner.Forward");
         }
         cassini.Reverse(x, y, out lat, out lon, out azi, out rk);
         cassini.Reverse(x, y, out x1, out y1);
         if (x1 != lat || y1 != lon)
         {
             throw new Exception("Error in CassiniSoldner.Reverse");
         }
         Gnomonic gnomonic = new Gnomonic(m_geodesic);
         gnomonic = new Gnomonic();
         gnomonic.Forward(32.0, -86.0, 31.0, -87.0, out x, out y, out azi, out rk);
         gnomonic.Forward(32.0, -86.0, 31.0, -87.0, out x1, out y1);
         if (x != x1 || y != y1)
         {
             throw new Exception("Error in Gnomonic.Forward");
         }
         gnomonic.Reverse(32.0, -86.0, x, y, out lat, out lon, out azi, out rk);
         gnomonic.Reverse(32.0, -86.0, x, y, out x1, out y1);
         if (x1 != lat || y1 != lon)
         {
             throw new Exception("Error in Gnomonic.Reverse");
         }
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Exemplo n.º 5
0
        public void EpsgExample134Test()
        {
            var projection = new CassiniSoldner(
                new GeographicCoordinate(0.182241463, -1.070468608),
                new Vector2(430000.00, 325000.00),
                new SpheroidEquatorialInvF(31706587.88, 294.2606764)
            );

            var result = projection.TransformValue(new GeographicCoordinate(0.17453293, -1.08210414));
            var expected = new Point2(66644.94, 82536.22);

            Assert.AreEqual(expected.X, result.X, 0.2);
            Assert.AreEqual(expected.Y, result.Y, 0.2);
        }
Exemplo n.º 6
0
        public void EpsgExample134InverseTest()
        {
            var projection = new CassiniSoldner(
                new GeographicCoordinate(0.182241463, -1.070468608),
                new Vector2(430000.00, 325000.00),
                new SpheroidEquatorialInvF(31706587.88, 294.2606764)
                );

            var result   = projection.GetInverse().TransformValue(new Point2(66644.94, 82536.22));
            var expected = new GeographicCoordinate(0.17453293, -1.08210414);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.00000004);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.000000004);
        }
Exemplo n.º 7
0
        private void OnProjectectionType(object sender, EventArgs e)
        {
            m_type = (ProjectionTypes)m_projectionComboBox.SelectedIndex;
            switch (m_type)
            {
            case ProjectionTypes.AzimuthalEquidistant:
                m_azimuthal = new AzimuthalEquidistant(m_geodesic);
                break;

            case ProjectionTypes.CassiniSoldner:
                double lat0 = Double.Parse(m_lat0TextBox.Text);
                double lon0 = Double.Parse(m_lon0TextBox.Text);
                m_cassini = new CassiniSoldner(lat0, lon0, m_geodesic);
                break;

            case ProjectionTypes.Gnomonic:
                m_gnomonic = new Gnomonic(m_geodesic);
                break;
            }
        }
Exemplo n.º 8
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         double lat = 0.0, lon = 0.0, x = 0.0, y = 0.0, x1 = 0.0, y1 = 0.0, azi = 0.0, rk = 0.0;
         AzimuthalEquidistant azimuthal = new AzimuthalEquidistant(m_geodesic);
         azimuthal = new AzimuthalEquidistant();
         azimuthal.Forward(32.0, -86.0, 33.0, -87.0, out x, out y, out azi, out rk);
         azimuthal.Forward(32.0, -86.0, 33.0, -87.0, out x1, out y1);
         if (x != x1 || y != y1)
             throw new Exception("Error in AzimuthalEquidistant.Forward");
         azimuthal.Reverse(32.0, -86.0, x, y, out lat, out lon, out azi, out rk);
         azimuthal.Reverse(32.0, -86.0, x, y, out x1, out y1);
         if ( x1 != lat || y1 != lon )
             throw new Exception("Error in AzimuthalEquidistant.Reverse");
         CassiniSoldner cassini = new CassiniSoldner(32.0, -86.0, m_geodesic);
         cassini = new CassiniSoldner(32.0, -86.0);
         cassini.Reset(31.0, -87.0);
         cassini.Forward(32.0, -86.0, out x, out y, out azi, out rk);
         cassini.Forward(32.0, -86.0, out x1, out y1);
         if (x != x1 || y != y1)
             throw new Exception("Error in CassiniSoldner.Forward");
         cassini.Reverse(x, y, out lat, out lon, out azi, out rk);
         cassini.Reverse(x, y, out x1, out y1);
         if (x1 != lat || y1 != lon)
             throw new Exception("Error in CassiniSoldner.Reverse");
         Gnomonic gnomonic = new Gnomonic(m_geodesic);
         gnomonic = new Gnomonic();
         gnomonic.Forward(32.0, -86.0, 31.0, -87.0, out x, out y, out azi, out rk);
         gnomonic.Forward(32.0, -86.0, 31.0, -87.0, out x1, out y1);
         if (x != x1 || y != y1)
             throw new Exception("Error in Gnomonic.Forward");
         gnomonic.Reverse(32.0, -86.0, x, y, out lat, out lon, out azi, out rk);
         gnomonic.Reverse(32.0, -86.0, x, y, out x1, out y1);
         if (x1 != lat || y1 != lon)
             throw new Exception("Error in Gnomonic.Reverse");
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Exemplo n.º 9
0
 private void OnProjectectionType(object sender, EventArgs e)
 {
     m_type = (ProjectionTypes)m_projectionComboBox.SelectedIndex;
     switch (m_type)
     {
         case ProjectionTypes.AzimuthalEquidistant:
             m_azimuthal = new AzimuthalEquidistant(m_geodesic);
             break;
         case ProjectionTypes.CassiniSoldner:
             double lat0 = Double.Parse( m_lat0TextBox.Text );
             double lon0 = Double.Parse( m_lon0TextBox.Text );
             m_cassini = new CassiniSoldner(lat0, lon0, m_geodesic);
             break;
         case ProjectionTypes.Gnomonic:
             m_gnomonic = new Gnomonic(m_geodesic);
             break;
     }
 }