Ejemplo n.º 1
0
        /// <summary>
        ///     Convert this latitude and longitude into an OSGB (Ordnance Survey of Great
        ///     Britain) grid reference.
        /// </summary>
        /// <param name="ll"> The latitude and longitude. </param>
        /// <exception cref="ArgumentException"> If the northing or easting are out of range </exception>
        public OsRef(LatLng ll)
            : base(OSGB36Datum.Instance)
        {
            ll.ToDatum(OSGB36Datum.Instance);

            var airy1830 = Airy1830Ellipsoid.Instance;
            var OSGB_F0  = 0.9996012717;
            var N0       = -100000.0;
            var E0       = 400000.0;
            var phi0     = Util.ToRadians(49.0);
            var lambda0  = Util.ToRadians(-2.0);
            var a        = airy1830.SemiMajorAxis;
            var b        = airy1830.SemiMinorAxis;
            var eSquared = airy1830.EccentricitySquared;
            var phi      = Util.ToRadians(ll.Latitude);
            var lambda   = Util.ToRadians(ll.Longitude);
            var E        = 0.0;
            var N        = 0.0;
            var n        = (a - b) / (a + b);
            var v        = a * OSGB_F0
                           * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -0.5);
            var rho = a * OSGB_F0 * (1.0 - eSquared)
                      * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -1.5);
            var etaSquared = v / rho - 1.0;
            var M          = b * OSGB_F0
                             * ((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)));
            var I   = M + N0;
            var II  = v / 2.0 * Math.Sin(phi) * Math.Cos(phi);
            var III = v / 24.0 * Math.Sin(phi) * Math.Pow(Math.Cos(phi), 3.0)
                      * (5.0 - Util.tanSquared(phi) + 9.0 * etaSquared);
            var 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));
            var IV = v * Math.Cos(phi);
            var V  = v / 6.0 * Math.Pow(Math.Cos(phi), 3.0)
                     * (v / rho - Util.tanSquared(phi));
            var 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;
        }
Ejemplo n.º 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);

            var ellipsoid = Datum.ReferenceEllipsoid;
            var N0        = FALSE_ORIGIN_NORTHING;
            var E0        = FALSE_ORIGIN_EASTING;
            var phi0      = Util.ToRadians(FALSE_ORIGIN_LATITUDE);
            var lambda0   = Util.ToRadians(FALSE_ORIGIN_LONGITUDE);
            var a         = ellipsoid.SemiMajorAxis * SCALE_FACTOR;
            var b         = ellipsoid.SemiMinorAxis * SCALE_FACTOR;
            var eSquared  = ellipsoid.EccentricitySquared;
            var phi       = Util.ToRadians(ll.Latitude);
            var lambda    = Util.ToRadians(ll.Longitude);
            var E         = 0.0;
            var N         = 0.0;
            var n         = (a - b) / (a + b);
            var v         = a
                            * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -0.5);
            var rho = a * (1.0 - eSquared)
                      * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -1.5);
            var etaSquared = v / rho - 1.0;
            var 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)));
            var I   = M + N0;
            var II  = v / 2.0 * Math.Sin(phi) * Math.Cos(phi);
            var III = v / 24.0 * Math.Sin(phi) * Math.Pow(Math.Cos(phi), 3.0)
                      * (5.0 - Util.tanSquared(phi) + 9.0 * etaSquared);
            var 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));
            var IV = v * Math.Cos(phi);
            var V  = v / 6.0 * Math.Pow(Math.Cos(phi), 3.0)
                     * (v / rho - Util.tanSquared(phi));
            var 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;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Convert this latitude and longitude into an OSGB (Ordnance Survey of Great
        /// Britain) grid reference.
        /// </summary>
        /// <param name="ll">The latitude and longitude.</param>
        /// <exception cref="ArgumentException">If the northing or easting are out of range</exception>
        public OSRef(LatLng ll) : base(OSGB36Datum.Instance)
        {
            ll.ToDatum(OSGB36Datum.Instance);

            Airy1830Ellipsoid airy1830 = Airy1830Ellipsoid.Instance;
            double            OSGB_F0  = 0.9996012717;
            double            N0       = -100000.0;
            double            E0       = 400000.0;
            double            phi0     = Util.ToRadians(49.0);
            double            lambda0  = Util.ToRadians(-2.0);
            double            a        = airy1830.SemiMajorAxis;
            double            b        = airy1830.SemiMinorAxis;
            double            eSquared = airy1830.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 * OSGB_F0
                                         * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -0.5);
            double rho = a * OSGB_F0 * (1.0 - eSquared)
                         * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -1.5);
            double etaSquared = (v / rho) - 1.0;
            double M          = (b * OSGB_F0)
                                * (((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;
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Convert this latitude and longitude into an OSGB (Ordnance Survey of Great
        /// Britain) grid reference.
        /// </summary>
        /// <param name="ll">The latitude and longitude.</param>
        /// <exception cref="ArgumentException">If the northing or easting are out of range</exception>
        public OSRef(LatLng ll) : base(OSGB36Datum.Instance)
        {
            ll.ToDatum(OSGB36Datum.Instance);

            Airy1830Ellipsoid airy1830 = Airy1830Ellipsoid.Instance;
            const double      osgbF0   = 0.9996012717;
            const double      n0       = -100000.0;
            const double      e0       = 400000.0;
            double            phi0     = Util.ToRadians(49.0);
            double            lambda0  = Util.ToRadians(-2.0);
            double            a        = airy1830.SemiMajorAxis;
            double            b        = airy1830.SemiMinorAxis;
            double            eSquared = airy1830.EccentricitySquared;
            double            phi      = Util.ToRadians(ll.Latitude);
            double            lambda   = Util.ToRadians(ll.Longitude);
            double            n        = (a - b) / (a + b);
            double            v        = a * osgbF0
                                         * Math.Pow(1.0 - eSquared * Util.SinSquared(phi), -0.5);
            double rho = a * osgbF0 * (1.0 - eSquared)
                         * Math.Pow(1.0 - eSquared * Util.SinSquared(phi), -1.5);
            double etaSquared = (v / rho) - 1.0;
            double m          = (b * osgbF0)
                                * (((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;
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
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);

            var ellipsoid = Datum.ReferenceEllipsoid;
            var N0 = FALSE_ORIGIN_NORTHING;
            var E0 = FALSE_ORIGIN_EASTING;
            var phi0 = Util.ToRadians(FALSE_ORIGIN_LATITUDE);
            var lambda0 = Util.ToRadians(FALSE_ORIGIN_LONGITUDE);
            var a = ellipsoid.SemiMajorAxis*SCALE_FACTOR;
            var b = ellipsoid.SemiMinorAxis*SCALE_FACTOR;
            var eSquared = ellipsoid.EccentricitySquared;
            var phi = Util.ToRadians(ll.Latitude);
            var lambda = Util.ToRadians(ll.Longitude);
            var E = 0.0;
            var N = 0.0;
            var n = (a - b)/(a + b);
            var v = a
                    *Math.Pow(1.0 - eSquared*Util.sinSquared(phi), -0.5);
            var rho = a*(1.0 - eSquared)
                      *Math.Pow(1.0 - eSquared*Util.sinSquared(phi), -1.5);
            var etaSquared = v/rho - 1.0;
            var 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)));
            var I = M + N0;
            var II = v/2.0*Math.Sin(phi)*Math.Cos(phi);
            var III = v/24.0*Math.Sin(phi)*Math.Pow(Math.Cos(phi), 3.0)
                      *(5.0 - Util.tanSquared(phi) + 9.0*etaSquared);
            var 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));
            var IV = v*Math.Cos(phi);
            var V = v/6.0*Math.Pow(Math.Cos(phi), 3.0)
                    *(v/rho - Util.tanSquared(phi));
            var 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;
        }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Convert this latitude and longitude into an OSGB (Ordnance Survey of Great
        ///     Britain) grid reference.
        /// </summary>
        /// <param name="ll"> The latitude and longitude. </param>
        /// <exception cref="ArgumentException"> If the northing or easting are out of range </exception>
        public OsRef(LatLng ll)
            : base(OSGB36Datum.Instance)
        {
            ll.ToDatum(OSGB36Datum.Instance);

            var airy1830 = Airy1830Ellipsoid.Instance;
            var OSGB_F0 = 0.9996012717;
            var N0 = -100000.0;
            var E0 = 400000.0;
            var phi0 = Util.ToRadians(49.0);
            var lambda0 = Util.ToRadians(-2.0);
            var a = airy1830.SemiMajorAxis;
            var b = airy1830.SemiMinorAxis;
            var eSquared = airy1830.EccentricitySquared;
            var phi = Util.ToRadians(ll.Latitude);
            var lambda = Util.ToRadians(ll.Longitude);
            var E = 0.0;
            var N = 0.0;
            var n = (a - b)/(a + b);
            var v = a*OSGB_F0
                    *Math.Pow(1.0 - eSquared*Util.sinSquared(phi), -0.5);
            var rho = a*OSGB_F0*(1.0 - eSquared)
                      *Math.Pow(1.0 - eSquared*Util.sinSquared(phi), -1.5);
            var etaSquared = v/rho - 1.0;
            var M = b*OSGB_F0
                    *((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)));
            var I = M + N0;
            var II = v/2.0*Math.Sin(phi)*Math.Cos(phi);
            var III = v/24.0*Math.Sin(phi)*Math.Pow(Math.Cos(phi), 3.0)
                      *(5.0 - Util.tanSquared(phi) + 9.0*etaSquared);
            var 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));
            var IV = v*Math.Cos(phi);
            var V = v/6.0*Math.Pow(Math.Cos(phi), 3.0)
                    *(v/rho - Util.tanSquared(phi));
            var 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;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Convert this latitude and longitude into an OSGB (Ordnance Survey of Great
        /// Britain) grid reference.
        /// </summary>
        /// <param name="ll">The latitude and longitude.</param>
        /// <exception cref="ArgumentException">If the northing or easting are out of range</exception>
        public OSRef(LatLng ll)
            : base(OSGB36Datum.Instance)
        {
            ll.ToDatum(OSGB36Datum.Instance);

              Airy1830Ellipsoid airy1830 = Airy1830Ellipsoid.Instance;
              double OSGB_F0 = 0.9996012717;
              double N0 = -100000.0;
              double E0 = 400000.0;
              double phi0 = Util.ToRadians(49.0);
              double lambda0 = Util.ToRadians(-2.0);
              double a = airy1830.SemiMajorAxis;
              double b = airy1830.SemiMinorAxis;
              double eSquared = airy1830.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 * OSGB_F0
              * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -0.5);
              double rho = a * OSGB_F0 * (1.0 - eSquared)
              * Math.Pow(1.0 - eSquared * Util.sinSquared(phi), -1.5);
              double etaSquared = (v / rho) - 1.0;
              double M = (b * OSGB_F0)
              * (((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;
        }