Пример #1
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);
 }
Пример #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
         Gnomonic     proj = new Gnomonic(geod);
         {
             // Sample forward calculation
             double lat = 50.9, lon = 1.8; // Calais
             double x, y;
             proj.Forward(lat0, lon0, 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(lat0, lon0, 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));
     }
 }
Пример #3
0
        private void ConvertGnomonic()
        {
            double lat0 = Double.Parse(m_lat0TextBox.Text);
            double lon0 = Double.Parse(m_lon0TextBox.Text);
            double lat = 0.0, lon = 0.0, x = 0.0, y = 0.0, azi = 0.0, rk = 0.0;

            switch (m_functionComboBox.SelectedIndex)
            {
            case 0:
                lat = Double.Parse(m_latitudeTextBox.Text);
                lon = Double.Parse(m_longitudeTextBox.Text);
                m_gnomonic.Forward(lat0, lon0, lat, lon, out x, out y, out azi, out rk);
                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_gnomonic.Reverse(lat0, lon0, x, y, out lat, out lon, out azi, out rk);
                m_latitudeTextBox.Text  = lat.ToString();
                m_longitudeTextBox.Text = lon.ToString();
                break;
            }
            m_azimuthTextBox.Text = azi.ToString();
            m_scaleTextBox.Text   = rk.ToString();
        }
Пример #4
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
         Gnomonic proj = new Gnomonic(geod);
         {
             // Sample forward calculation
             double lat = 50.9, lon = 1.8; // Calais
             double x, y;
             proj.Forward(lat0, lon0, 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(lat0, lon0, 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));
     }
 }
Пример #5
0
        /**
         * Interception of a point <i>b</i> to a geodesic <i>a</i>.
         * <p>
         *
         * @param lata1 latitude of point <i>1</i> of geodesic <i>a</i> (degrees).
         * @param lona1 longitude of point <i>1</i> of geodesic <i>a</i> (degrees).
         * @param lata2 latitude of point <i>2</i> of geodesic <i>a</i> (degrees).
         * @param lona2 longitude of point <i>2</i> of geodesic <i>a</i> (degrees).
         * @param latb1 latitude of point <i>b</i> (degrees).
         * @param lonb1 longitude of point <i>b</i> (degrees).
         * @return a {@link GeodesicData} object, defining a geodesic from point <i>b</i> to the
         *         intersection point, with the following fields: <i>lat1</i>, <i>lon1</i>, <i>azi1</i>,
         *         <i>lat2</i>, <i>lon2</i>, <i>azi2</i>, <i>s12</i>, <i>a12</i>.
         *         <p>
         *         <i>lat1</i> should be in the range [&minus;90&deg;, 90&deg;]; <i>lon1</i> and
         *         <i>azi1</i> should be in the range [&minus;540&deg;, 540&deg;). The values of
         *         <i>lon2</i> and <i>azi2</i> returned are in the range [&minus;180&deg;, 180&deg;).
         */
        public GeodesicData Intercept(double lata1, double lona1, double lata2, double lona2,
                                      double latb1, double lonb1)
        {
            if (lata1 == lata2 && lona1 == lona2)
            {
                return(_gnom.Earth.Inverse(latb1, lonb1, lata1, lona1));
            }

            var    inv = Geodesic.WGS84.Inverse(lata1, lona1, lata2, lona2);
            var    est = Geodesic.WGS84.Line(inv.lat1, inv.lon1, inv.azi1).Position(inv.s12 * 0.5);
            double latb2 = est.lat2, latb2_ = double.NaN, lonb2_ = double.NaN, lonb2 = est.lon2;

            for (int i = 0; i < _maxit; ++i)
            {
                var xa1 = _gnom.Forward(latb2, lonb2, lata1, lona1);
                var xa2 = _gnom.Forward(latb2, lonb2, lata2, lona2);
                var xb1 = _gnom.Forward(latb2, lonb2, latb1, lonb1);

                var va1 = new Vector3D(xa1.x, xa1.y, 1);
                var va2 = new Vector3D(xa2.x, xa2.y, 1);
                var la  = va1.Cross(va2);
                var lb  = new Vector3D(la.Y, -(la.X), la.X * xb1.y - la.Y * xb1.x);
                var p0  = la.Cross(lb);
                p0 = p0 * (1d / p0.Z);

                latb2_ = latb2;
                lonb2_ = lonb2;

                GnomonicData rev = _gnom.Reverse(latb2, lonb2, p0.X, p0.Y);
                latb2 = rev.lat;
                lonb2 = rev.lon;

                if (Math.Abs(lonb2_ - lonb2) < eps && Math.Abs(latb2_ - latb2) < eps)
                {
                    break;
                }
            }

            return(_gnom.Earth.Inverse(latb1, lonb1, latb2, lonb2));
        }
Пример #6
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);
 }