Esempio n. 1
0
        private void ConvertTransverse()
        {
            double lat = 0.0, lon = 0.0, x = 0.0, y = 0.0, gamma = 0.0, k = 0.0;
            double lon0 = Double.Parse(m_lon0TextBox.Text);

            switch (m_functionComboBox.SelectedIndex)
            {
            case 0:
                lat = Double.Parse(m_latitudeTextBox.Text);
                lon = Double.Parse(m_longitudeTextBox.Text);
                m_trans.Forward(lon0, lat, lon, out x, out y, out gamma, out k);
                m_xTextBox.Text = x.ToString();
                m_yTextBox.Text = y.ToString();
                break;

            case 1:
                x = Double.Parse(m_xTextBox.Text);
                y = Double.Parse(m_yTextBox.Text);
                m_trans.Reverse(lon0, x, y, out lat, out lon, out gamma, out k);
                m_latitudeTextBox.Text  = lat.ToString();
                m_longitudeTextBox.Text = lon.ToString();
                break;
            }
            m_gammaTextBox.Text          = gamma.ToString();
            m_azimuthalScaleTextBox.Text = k.ToString();
        }
        public void TransverseMercatorProj4_CheckUseOfComplexArithmeticToDoClenshawSum()
        {
            var tme = new TransverseMercatorExact(6.4e6, 1d / 150, Constants.UTM_k0);

            var(x, y) = tme.Forward(0, 20, 30, out var gamma, out var k);
            Assert.AreEqual(3266035.453860, x, 1e-6);
            Assert.AreEqual(2518371.552676, y, 1e-6);
            Assert.AreEqual(11.207356502141, gamma, 1e-12);
            Assert.AreEqual(1.134138960741, k, 1e-12);

            var tm = new TransverseMercator(6.4e6, 1d / 150, Constants.UTM_k0);

            (x, y) = tm.Forward(0, 20, 30, out gamma, out k);
            Assert.AreEqual(3266035.453860, x, 1e-6);
            Assert.AreEqual(2518371.552676, y, 1e-6);
            Assert.AreEqual(11.207356502141, gamma, 1e-12);
            Assert.AreEqual(1.134138960741, k, 1e-12);
        }
        public void TransverseMercatorProj0_TestFixToBadMeridianConvergence()
        {
            var tme = new TransverseMercatorExact(Ellipsoid.WGS84, 1);

            var(x, y) = tme.Forward(0, 90, 75, out var gamma, out var k);
            Assert.AreEqual(0.0, x, 0.01);
            Assert.AreEqual(10001965.7293, y, 0.0001);
            Assert.AreEqual(75.0, gamma, 0.01);
            Assert.AreEqual(1.0, k, 0.01);

            var tm = new TransverseMercator(Ellipsoid.WGS84, 1);

            (x, y) = tm.Forward(0, 90, 75, out gamma, out k);
            Assert.AreEqual(0.0, x, 0.01);
            Assert.AreEqual(10001965.7293, y, 0.0001);
            Assert.AreEqual(75.0, gamma, 0.01);
            Assert.AreEqual(1.0, k, 0.01);
        }
Esempio n. 4
0
        public point(long t, double x, double y, bool polar, double _referenceMeridian)
        {
            ti                = t;
            xi                = x;
            yi                = y;
            zonei             = zone;
            active            = true;
            referenceMeridian = _referenceMeridian;

            if (x > -360.0 && x <= 360.0 && y >= -90.0 && y <= 90.0)
            {
                NETGeographicLib.TransverseMercator p = new TransverseMercator(a, f, k1);
                p.Forward(referenceMeridian, y, x, out xx, out yy);
            }
            else
            {
                xx = x;
                yy = y;
            }
        }
 static void Main(string[] args)
 {
     try {
         TransverseMercator proj = new TransverseMercator(); // WGS84
         double lon0 = -75;          // Central meridian for UTM zone 18
         {
             // Sample forward calculation
             double lat = 40.3, lon = -74.7; // Princeton, NJ
             double x, y;
             proj.Forward(lon0, lat, lon, out x, out y);
             Console.WriteLine(String.Format("{0} {1}", x, y));
         }
         {
             // Sample reverse calculation
             double x = 25e3, y = 4461e3;
             double lat, lon;
             proj.Reverse(lon0, x, y, out lat, out lon);
             Console.WriteLine(String.Format("{0} {1}", lat, lon));
         }
     }
     catch (GeographicErr e) {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
 static void Main(string[] args)
 {
     try {
         TransverseMercator proj = new TransverseMercator(); // WGS84
         double             lon0 = -75;                      // Central meridian for UTM zone 18
         {
             // Sample forward calculation
             double lat = 40.3, lon = -74.7; // Princeton, NJ
             double x, y;
             proj.Forward(lon0, lat, lon, out x, out y);
             Console.WriteLine(String.Format("{0} {1}", x, y));
         }
         {
             // Sample reverse calculation
             double x = 25e3, y = 4461e3;
             double lat, lon;
             proj.Reverse(lon0, x, y, out lat, out lon);
             Console.WriteLine(String.Format("{0} {1}", lat, lon));
         }
     }
     catch (GeographicErr e) {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
Esempio n. 7
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         const double    DEG_TO_RAD = 3.1415926535897932384626433832795 / 180.0;
         AlbersEqualArea a          = new AlbersEqualArea(AlbersEqualArea.StandardTypes.AzimuthalEqualAreaNorth);
         a = new AlbersEqualArea(AlbersEqualArea.StandardTypes.AzimuthalEqualAreaSouth);
         double radius = a.EquatorialRadius;
         double f      = a.Flattening;
         a = new AlbersEqualArea(radius, f, 60.0, 1.0);
         a = new AlbersEqualArea(radius, f, 60.0, 70.0, 1.0);
         a = new AlbersEqualArea(radius, f, Math.Sin(88.0 * DEG_TO_RAD), Math.Cos(88.0 * DEG_TO_RAD),
                                 Math.Sin(89.0 * DEG_TO_RAD), Math.Cos(89.0 * DEG_TO_RAD), 1.0);
         a = new AlbersEqualArea(AlbersEqualArea.StandardTypes.CylindricalEqualArea);
         double lon0 = 0.0, lat = 32.0, lon = -86.0, x, y, gamma, k, x1, y1;
         a.Forward(lon0, lat, lon, out x, out y, out gamma, out k);
         a.Forward(lon0, lat, lon, out x1, out y1);
         if (x != x1 || y != y1)
         {
             throw new Exception("Error in AlbersEqualArea.Forward");
         }
         a.Reverse(lon0, x, y, out lat, out lon, out gamma, out k);
         a.Reverse(lon0, x, y, out x1, out y1);
         if (lat != x1 || lon != y1)
         {
             throw new Exception("Error in AlbersEqualArea.Reverse");
         }
         LambertConformalConic b = new LambertConformalConic(radius, f, 60.0, 1.0);
         b = new LambertConformalConic(radius, f, 60.0, 65.0, 1.0);
         b = new LambertConformalConic(radius, f, Math.Sin(88.0 * DEG_TO_RAD), Math.Cos(88.0 * DEG_TO_RAD),
                                       Math.Sin(89.0 * DEG_TO_RAD), Math.Cos(89.0 * DEG_TO_RAD), 1.0);
         b = new LambertConformalConic();
         b.SetScale(60.0, 1.0);
         b.Forward(-87.0, 32.0, -86.0, out x, out y, out gamma, out k);
         b.Forward(-87.0, 32.0, -86.0, out x1, out y1);
         if (x != x1 || y != y1)
         {
             throw new Exception("Error in LambertConformalConic.Forward");
         }
         b.Reverse(-87.0, x, y, out lat, out lon, out gamma, out k);
         b.Reverse(-87.0, x, y, out x1, out y1, out gamma, out k);
         if (lat != x1 || lon != y1)
         {
             throw new Exception("Error in LambertConformalConic.Reverse");
         }
         TransverseMercator c = new TransverseMercator(radius, f, 1.0);
         c = new TransverseMercator();
         c.Forward(-87.0, 32.0, -86.0, out x, out y, out gamma, out k);
         c.Forward(-87.0, 32.0, -86.0, out x1, out y1);
         if (x != x1 || y != y1)
         {
             throw new Exception("Error in TransverseMercator.Forward");
         }
         c.Reverse(-87.0, x, y, out lat, out lon, out gamma, out k);
         c.Reverse(-87.0, x, y, out x1, out y1);
         if (lat != x1 || lon != y1)
         {
             throw new Exception("Error in TransverseMercator.Reverse");
         }
         TransverseMercatorExact d = new TransverseMercatorExact(radius, f, 1.0, false);
         d = new TransverseMercatorExact();
         d.Forward(-87.0, 32.0, -86.0, out x, out y, out gamma, out k);
         d.Forward(-87.0, 32.0, -86.0, out x1, out y1);
         if (x != x1 || y != y1)
         {
             throw new Exception("Error in TransverseMercatorExact.Forward");
         }
         d.Reverse(-87.0, x, y, out lat, out lon, out gamma, out k);
         d.Reverse(-87.0, x, y, out x1, out y1);
         if (lat != x1 || lon != y1)
         {
             throw new Exception("Error in TransverseMercatorExact.Reverse");
         }
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Esempio n. 8
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         const double DEG_TO_RAD = 3.1415926535897932384626433832795 / 180.0;
         AlbersEqualArea a = new AlbersEqualArea(AlbersEqualArea.StandardTypes.AzimuthalEqualAreaNorth);
         a = new AlbersEqualArea(AlbersEqualArea.StandardTypes.AzimuthalEqualAreaSouth);
         double radius = a.MajorRadius;
         double f = a.Flattening;
         a = new AlbersEqualArea(radius, f, 60.0, 1.0);
         a = new AlbersEqualArea(radius, f, 60.0, 70.0, 1.0);
         a = new AlbersEqualArea(radius, f, Math.Sin(88.0 * DEG_TO_RAD), Math.Cos(88.0 * DEG_TO_RAD),
             Math.Sin(89.0*DEG_TO_RAD), Math.Cos(89.0*DEG_TO_RAD), 1.0);
         a = new AlbersEqualArea(AlbersEqualArea.StandardTypes.CylindricalEqualArea);
         double lon0 = 0.0, lat = 32.0, lon = -86.0, x, y, gamma, k, x1, y1;
         a.Forward(lon0, lat, lon, out x, out y, out gamma, out k);
         a.Forward(lon0, lat, lon, out x1, out y1);
         if (x != x1 || y != y1)
             throw new Exception("Error in AlbersEqualArea.Forward");
         a.Reverse(lon0, x, y, out lat, out lon, out gamma, out k);
         a.Reverse(lon0, x, y, out x1, out y1);
         if (lat != x1 || lon != y1)
             throw new Exception("Error in AlbersEqualArea.Reverse");
         LambertConformalConic b = new LambertConformalConic(radius, f, 60.0, 1.0);
         b = new LambertConformalConic(radius, f, 60.0, 65.0, 1.0);
         b = new LambertConformalConic(radius, f, Math.Sin(88.0 * DEG_TO_RAD), Math.Cos(88.0 * DEG_TO_RAD),
             Math.Sin(89.0 * DEG_TO_RAD), Math.Cos(89.0 * DEG_TO_RAD), 1.0);
         b = new LambertConformalConic();
         b.SetScale(60.0, 1.0);
         b.Forward(-87.0, 32.0, -86.0, out x, out y, out gamma, out k);
         b.Forward(-87.0, 32.0, -86.0, out x1, out y1);
         if (x != x1 || y != y1)
             throw new Exception("Error in LambertConformalConic.Forward");
         b.Reverse(-87.0, x, y, out lat, out lon, out gamma, out k);
         b.Reverse(-87.0, x, y, out x1, out y1, out gamma, out k);
         if (lat != x1 || lon != y1)
             throw new Exception("Error in LambertConformalConic.Reverse");
         TransverseMercator c = new TransverseMercator(radius, f, 1.0);
         c = new TransverseMercator();
         c.Forward(-87.0, 32.0, -86.0, out x, out y, out gamma, out k);
         c.Forward(-87.0, 32.0, -86.0, out x1, out y1);
         if (x != x1 || y != y1)
             throw new Exception("Error in TransverseMercator.Forward");
         c.Reverse(-87.0, x, y, out lat, out lon, out gamma, out k);
         c.Reverse(-87.0, x, y, out x1, out y1);
         if (lat != x1 || lon != y1)
             throw new Exception("Error in TransverseMercator.Reverse");
         TransverseMercatorExact d = new TransverseMercatorExact(radius, f, 1.0, false);
         d = new TransverseMercatorExact();
         d.Forward(-87.0, 32.0, -86.0, out x, out y, out gamma, out k);
         d.Forward(-87.0, 32.0, -86.0, out x1, out y1);
         if (x != x1 || y != y1)
             throw new Exception("Error in TransverseMercatorExact.Forward");
         d.Reverse(-87.0, x, y, out lat, out lon, out gamma, out k);
         d.Reverse(-87.0, x, y, out x1, out y1);
         if (lat != x1 || lon != y1)
             throw new Exception("Error in TransverseMercatorExact.Reverse");
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }