Beispiel #1
0
        /// <summary>
        /// Create an IrishRef object from the given latitude and longitude.
        /// </summary>
        /// <param name="ll">The latitude and longitude.</param>
        public IrishRef(LatLng ll) : base(Ireland1965Datum.Instance)
        {
            ll.ToDatum(Ireland1965Datum.Instance);

            DotNetCoords.Ellipsoid.Ellipsoid ellipsoid = Datum.ReferenceEllipsoid;
            double N0       = FALSE_ORIGIN_NORTHING;
            double E0       = FALSE_ORIGIN_EASTING;
            double phi0     = Util.ToRadians(FALSE_ORIGIN_LATITUDE);
            double lambda0  = Util.ToRadians(FALSE_ORIGIN_LONGITUDE);
            double a        = ellipsoid.SemiMajorAxis * SCALE_FACTOR;
            double b        = ellipsoid.SemiMinorAxis * SCALE_FACTOR;
            double eSquared = ellipsoid.EccentricitySquared;
            double phi      = Util.ToRadians(ll.Latitude);
            double lambda   = Util.ToRadians(ll.Longitude);
            double E        = 0.0;
            double N        = 0.0;
            double n        = (a - b) / (a + b);
            double v        = a
                              * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -0.5);
            double rho = a * (1.0 - eSquared)
                         * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -1.5);
            double etaSquared = (v / rho) - 1.0;
            double M          = b
                                * (((1 + n + ((5.0 / 4.0) * n * n) + ((5.0 / 4.0) * n * n * n)) * (phi - phi0))
                                   - (((3 * n) + (3 * n * n) + ((21.0 / 8.0) * n * n * n))
                                      * Math.Sin(phi - phi0) * Math.Cos(phi + phi0))
                                   + ((((15.0 / 8.0) * n * n) + ((15.0 / 8.0) * n * n * n))
                                      * Math.Sin(2.0 * (phi - phi0)) * Math.Cos(2.0 * (phi + phi0))) - (((35.0 / 24.0)
                                                                                                         * n * n * n)
                                                                                                        * Math.Sin(3.0 * (phi - phi0)) * Math.Cos(3.0 * (phi + phi0))));
            double I   = M + N0;
            double II  = (v / 2.0) * Math.Sin(phi) * Math.Cos(phi);
            double III = (v / 24.0) * Math.Sin(phi) * Math.Pow(Math.Cos(phi), 3.0)
                         * (5.0 - Util.tanSquared(phi) + (9.0 * etaSquared));
            double IIIA = (v / 720.0) * Math.Sin(phi) * Math.Pow(Math.Cos(phi), 5.0)
                          * (61.0 - (58.0 * Util.tanSquared(phi)) + Math.Pow(Math.Tan(phi), 4.0));
            double IV = v * Math.Cos(phi);
            double V  = (v / 6.0) * Math.Pow(Math.Cos(phi), 3.0)
                        * ((v / rho) - Util.tanSquared(phi));
            double VI = (v / 120.0)
                        * Math.Pow(Math.Cos(phi), 5.0)
                        * (5.0 - (18.0 * Util.tanSquared(phi)) + (Math.Pow(Math.Tan(phi), 4.0))
                           + (14 * etaSquared) - (58 * Util.tanSquared(phi) * etaSquared));

            N = I + (II * Math.Pow(lambda - lambda0, 2.0))
                + (III * Math.Pow(lambda - lambda0, 4.0))
                + (IIIA * Math.Pow(lambda - lambda0, 6.0));
            E = E0 + (IV * (lambda - lambda0)) + (V * Math.Pow(lambda - lambda0, 3.0))
                + (VI * Math.Pow(lambda - lambda0, 5.0));

            Easting  = E;
            Northing = N;
        }
Beispiel #2
0
        /// <summary>
        /// Create an IrishRef object from the given latitude and longitude.
        /// </summary>
        /// <param name="ll">The latitude and longitude.</param>
        public IrishRef(LatLng ll) : base(Ireland1965Datum.Instance)
        {
            ll.ToDatum(Ireland1965Datum.Instance);

            Ellipsoid.Ellipsoid ellipsoid = Datum.ReferenceEllipsoid;
            const double        n0        = FalseOriginNorthing;
            const double        e0        = FalseOriginEasting;
            double phi0     = Util.ToRadians(FalseOriginLatitude);
            double lambda0  = Util.ToRadians(FalseOriginLongitude);
            double a        = ellipsoid.SemiMajorAxis * ScaleFactor;
            double b        = ellipsoid.SemiMinorAxis * ScaleFactor;
            double eSquared = ellipsoid.EccentricitySquared;
            double phi      = Util.ToRadians(ll.Latitude);
            double lambda   = Util.ToRadians(ll.Longitude);
            double n        = (a - b) / (a + b);
            double v        = a
                              * Math.Pow(1.0 - eSquared * Util.SinSquared(phi), -0.5);
            double rho = a * (1.0 - eSquared)
                         * Math.Pow(1.0 - eSquared * Util.SinSquared(phi), -1.5);
            double etaSquared = (v / rho) - 1.0;
            double m          = b
                                * (((1 + n + ((5.0 / 4.0) * n * n) + ((5.0 / 4.0) * n * n * n)) * (phi - phi0))
                                   - (((3 * n) + (3 * n * n) + ((21.0 / 8.0) * n * n * n))
                                      * Math.Sin(phi - phi0) * Math.Cos(phi + phi0))
                                   + ((((15.0 / 8.0) * n * n) + ((15.0 / 8.0) * n * n * n))
                                      * Math.Sin(2.0 * (phi - phi0)) * Math.Cos(2.0 * (phi + phi0))) - (((35.0 / 24.0)
                                                                                                         * n * n * n)
                                                                                                        * Math.Sin(3.0 * (phi - phi0)) * Math.Cos(3.0 * (phi + phi0))));
            double I   = m + n0;
            double ii  = (v / 2.0) * Math.Sin(phi) * Math.Cos(phi);
            double iii = (v / 24.0) * Math.Sin(phi) * Math.Pow(Math.Cos(phi), 3.0)
                         * (5.0 - Util.TanSquared(phi) + (9.0 * etaSquared));
            double iiia = (v / 720.0) * Math.Sin(phi) * Math.Pow(Math.Cos(phi), 5.0)
                          * (61.0 - (58.0 * Util.TanSquared(phi)) + Math.Pow(Math.Tan(phi), 4.0));
            double iv = v * Math.Cos(phi);
            double V  = (v / 6.0) * Math.Pow(Math.Cos(phi), 3.0)
                        * ((v / rho) - Util.TanSquared(phi));
            double vi = (v / 120.0)
                        * Math.Pow(Math.Cos(phi), 5.0)
                        * (5.0 - (18.0 * Util.TanSquared(phi)) + (Math.Pow(Math.Tan(phi), 4.0))
                           + (14 * etaSquared) - (58 * Util.TanSquared(phi) * etaSquared));

            double N = I + (ii * Math.Pow(lambda - lambda0, 2.0))
                       + (iii * Math.Pow(lambda - lambda0, 4.0))
                       + (iiia * Math.Pow(lambda - lambda0, 6.0));
            double e = e0 + (iv * (lambda - lambda0)) + (V * Math.Pow(lambda - lambda0, 3.0))
                       + (vi * Math.Pow(lambda - lambda0, 5.0));

            Easting  = e;
            Northing = N;
        }
Beispiel #3
0
        /// <summary>
        /// Create a new earth-centred, earth-fixed reference from the given latitude
        /// and longitude.
        /// </summary>
        /// <param name="ll">The latitude and longitude.</param>
        public ECEFRef(LatLng ll) : base(ll.Datum)
        {
            DotNetCoords.Ellipsoid.Ellipsoid ellipsoid = Datum.ReferenceEllipsoid;

            double phi      = Util.ToRadians(ll.Latitude);
            double lambda   = Util.ToRadians(ll.Longitude);
            double h        = ll.Height;
            double a        = ellipsoid.SemiMajorAxis;
            double f        = ellipsoid.Flattening;
            double eSquared = (2 * f) - (f * f);
            double nphi     = a / Math.Sqrt(1 - eSquared * Util.sinSquared(phi));

            X = (nphi + h) * Math.Cos(phi) * Math.Cos(lambda);
            Y = (nphi + h) * Math.Cos(phi) * Math.Sin(lambda);
            Z = (nphi * (1 - eSquared) + h) * Math.Sin(phi);
        }
Beispiel #4
0
        /// <summary>
        /// Convert this ECEFRef object to a point represented
        /// by a latitude and longitude and a perpendicular height above (or below) a
        /// reference ellipsoid.
        /// </summary>
        /// <returns>
        /// The equivalent latitude and longitude.
        /// </returns>
        public override LatLng ToLatLng()
        {
            DotNetCoords.Ellipsoid.Ellipsoid ellipsoid = Datum.ReferenceEllipsoid;

            double a         = ellipsoid.SemiMajorAxis;
            double b         = ellipsoid.SemiMinorAxis;
            double e2Squared = ((a * a) - (b * b)) / (b * b);
            double f         = ellipsoid.Flattening;
            double eSquared  = (2 * f) - (f * f);
            double p         = Math.Sqrt((x * x) + (y * y));
            double theta     = Math.Atan((z * a) / (p * b));

            double phi = Math.Atan((z + (e2Squared * b * Util.sinCubed(theta)))
                                   / (p - eSquared * a * Util.cosCubed(theta)));
            double lambda = Math.Atan2(y, x);

            double nphi = a / Math.Sqrt(1 - eSquared * Util.sinSquared(phi));
            double h    = (p / Math.Cos(phi)) - nphi;

            return(new LatLng(Util.ToDegrees(phi), Util.ToDegrees(lambda), h,
                              WGS84Datum.Instance));
        }