Beispiel #1
0
        public void Test(string geoResourceName, string neyResourceName, double projectDelta, double unprojectDelta)
        {
            var latLonData = GoldData.GetReadyReader(geoResourceName);
            var prjData = GoldData.GetReadyReader(neyResourceName);

            var projection = new NeysProjection(
                new GeographicCoordinate(
                    Double.Parse(prjData["ORIGIN LATITUDE"]) * Math.PI / 180.0,
                    Double.Parse(prjData["CENTRAL MERIDIAN"]) * Math.PI / 180.0
                ),
                Double.Parse(prjData["STANDARD PARALLEL ONE"]) * Math.PI / 180.0,
                new Vector2(
                    Double.Parse(prjData["FALSE EASTING"]),
                    Double.Parse(prjData["FALSE NORTHING"])
                ),
                GoldData.GenerateSpheroid(prjData["DATUM"])
            );

            var inverse = projection.GetInverse();

            while (latLonData.Read() && prjData.Read()) {
                var coord = latLonData.CurrentLatLon();
                var coordRads = latLonData.CurrentLatLonRadians();
                var expected = prjData.CurrentPoint2D();

                var projected = projection.TransformValue(coordRads);
                Assert.AreEqual(expected.X, projected.X, projectDelta);
                Assert.AreEqual(expected.Y, projected.Y, projectDelta);

                var unProjected = inverse.TransformValue(expected);
                unProjected = new GeographicCoordinate(unProjected.Latitude * 180.0 / Math.PI, unProjected.Longitude * 180.0 / Math.PI);
                Assert.AreEqual(coord.Latitude, unProjected.Latitude, unprojectDelta);
                Assert.AreEqual(coord.Longitude, unProjected.Longitude, unprojectDelta);
            }
        }
 public KrovakModifiedNorth(
     GeographicCoordinate geographicOrigin,
     double latitudeOfPseudoStandardParallel,
     double azimuthOfInitialLine,
     double scaleFactor,
     Vector2 falseProjectedOffset,
     ISpheroid<double> spheroid,
     Point2 evaluationPoint,
     double[] constants
 )
     : this(new KrovakModified(
     geographicOrigin,
     latitudeOfPseudoStandardParallel,
     azimuthOfInitialLine,
     scaleFactor,
     falseProjectedOffset,
     spheroid,
     evaluationPoint,
     constants
 ))
 {
     Contract.Requires(spheroid != null);
     Contract.Requires(constants != null);
     Contract.Requires(constants.Length == 10);
 }
        public void epsg3140_to_wgs()
        {
            var crs = EpsgMicroDatabase.Default.GetCrs(3140);
            var wgs = EpsgMicroDatabase.Default.GetCrs(4326);

            // source for coordinates is http://epsg.io/3140/map
            var ptWgs = new GeographicCoordinate(-17.785, 177.97);
            var pt3140 = new Point2(530138.52663372, 821498.68898981); // units in links

            var gen = new EpsgCrsCoordinateOperationPathGenerator();
            var paths = gen.Generate(wgs, crs);
            var compiler = new StaticCoordinateOperationCompiler();
            var txs = paths
                .Select(p => compiler.Compile(p))
                .Where(p => p != null);

            var forward = txs.Single();
            var actualForward = (Point2)forward.TransformValue(ptWgs);
            Assert.AreEqual(pt3140.X, actualForward.X, 30);
            Assert.AreEqual(pt3140.Y, actualForward.Y, 30);

            var reverse = forward.GetInverse();
            var actualReverse = (GeographicCoordinate)reverse.TransformValue(pt3140);
            Assert.AreEqual(ptWgs.Longitude, actualReverse.Longitude, 0.01);
            Assert.AreEqual(ptWgs.Latitude, actualReverse.Latitude, 0.01);
        }
Beispiel #4
0
 protected LambertConicBase(
     GeographicCoordinate geographicOrigin,
     Vector2 falseProjectedOffset,
     ISpheroid<double> spheroid
 )
     : base(falseProjectedOffset, spheroid)
 {
     Contract.Requires(spheroid != null);
     GeographicOrigin = geographicOrigin;
 }
Beispiel #5
0
        public void Test(string geoResourceName, string prjResourceName, double projectDelta, double unprojectDelta)
        {
            var latLonData = GoldData.GetReadyReader(geoResourceName);
            var prjData = GoldData.GetReadyReader(prjResourceName);

            var spheroid = GoldData.GenerateSpheroid(prjData["DATUM"]);
            PolarStereographic projection;
            if (null != prjData["SCALE FACTOR"]) {
                projection = new PolarStereographic(
                    new GeographicCoordinate(
                        Math.PI / 2.0,
                        Double.Parse(prjData["LONGITUDE DOWN FROM POLE"]) * Math.PI / 180.0
                    ),
                    Double.Parse(prjData["SCALE FACTOR"]),
                    new Vector2(
                        Double.Parse(prjData["FALSE EASTING"]),
                        Double.Parse(prjData["FALSE NORTHING"])
                    ),
                    spheroid
                );
            }
            else {
                var latSp = Double.Parse(prjData["LATITUDE OF TRUE SCALE"]) * Math.PI / 180.0;
                var originLat = latSp < 0 ? -Math.PI / 2.0 : Math.PI / 2.0;
                projection = PolarStereographic.CreateFromStandardParallel(
                    new GeographicCoordinate(
                        originLat,
                        Double.Parse(prjData["LONGITUDE DOWN FROM POLE"]) * Math.PI / 180.0
                    ),
                    latSp,
                    new Vector2(
                        Double.Parse(prjData["FALSE EASTING"]),
                        Double.Parse(prjData["FALSE NORTHING"])
                    ),
                    spheroid
                );
            }

            var inverse = projection.GetInverse();

            while (latLonData.Read() && prjData.Read()) {
                var coord = latLonData.CurrentLatLon();
                var coordRads = latLonData.CurrentLatLonRadians();
                var expected = prjData.CurrentPoint2D();

                var projected = projection.TransformValue(coordRads);
                Assert.AreEqual(expected.X, projected.X, projectDelta);
                Assert.AreEqual(expected.Y, projected.Y, projectDelta);

                var unProjected = inverse.TransformValue(expected);
                unProjected = new GeographicCoordinate(unProjected.Latitude * 180.0 / Math.PI, unProjected.Longitude * 180.0 / Math.PI);
                Assert.AreEqual(coord.Latitude, unProjected.Latitude, unprojectDelta);
                Assert.AreEqual(coord.Longitude, unProjected.Longitude, unprojectDelta);
            }
        }
        public void epsg_example_1_3_14()
        {
            var projection = new EquidistantCylindrical(GeographicCoordinate.Zero, Vector2.Zero, new SpheroidEquatorialInvF(6378137, 298.257223563));

            var input    = new GeographicCoordinate(0.959931086, 0.174532925);
            var expected = new Point2(1113194.91, 6097230.31);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.004);
            Assert.AreEqual(expected.Y, result.Y, 0.02);
        }
        private Point2 TransformValueNorth(GeographicCoordinate source)
        {
            var theta   = source.Longitude - GeographicOrigin.Longitude;
            var eSinLat = Math.Sin(source.Latitude) * E;
            var r       = Math.Tan(QuarterPi - (source.Latitude / 2.0))
                          * Math.Pow((1 + eSinLat) / (1 - eSinLat), EHalf)
                          * CoefficientT;
            var de = r * Math.Sin(theta);
            var dn = r * Math.Cos(theta);

            return(new Point2(de + FalseProjectedOffset.X, FalseProjectedOffset.Y - dn));
        }
Beispiel #8
0
        public override Point2 TransformValue(GeographicCoordinate coordinate)
        {
            var eSinLat = Math.Sin(coordinate.Latitude) * E;

            return(new Point2(
                       ((coordinate.Longitude - CentralMeridian) * Ak) + FalseProjectedOffset.X,
                       (Math.Log(
                            Math.Tan((coordinate.Latitude / 2.0) + QuarterPi)
                            * Math.Pow((1.0 - eSinLat) / (1.0 + eSinLat), EHalf)
                            ) * Ak) + FalseProjectedOffset.Y
                       ));
        }
        public void Vincenty_CorrectlyCalculatesDestinationCoordinates(double latA, double lonA, double bearingInRadians, double distanceInMeters,
                                                                       double expectedLat, double expectedLon, int maxIterations, double tolerance)
        {
            IGeographicCoordinate pointA = new GeographicCoordinate(latA, lonA);

            IGeographicCoordinate expected = new GeographicCoordinate(expectedLat, expectedLon);

            IGeographicCoordinate result = pointA.DestinationCoordinates(new Angle(bearingInRadians, AngleMeasurement.Radians), new Distance(distanceInMeters, DistanceMeasurement.Meters),
                                                                         maxIterations, tolerance);

            Assert.Equal(expected, result);
        }
Beispiel #10
0
        public EquidistantCylindrical(GeographicCoordinate origin, Vector2 falseProjectedOffset, ISpheroid <double> spheroid)
            : base(falseProjectedOffset, spheroid)
        {
            Contract.Requires(spheroid != null);
            _origin = origin;
            var e4  = ESq * ESq;
            var e6  = e4 * ESq;
            var e8  = e6 * ESq;
            var e10 = e8 * ESq;
            var e12 = e10 * ESq;
            var e14 = e12 * ESq;

            _coefLine1 = 1.0 - (ESq / 4.0)
                         - (3.0 / 64.0 * e4)
                         - (5.0 / 256.0 * e6)
                         - (175.0 / 16384.0 * e8)
                         - (441.0 / 65536.0 * e10)
                         - (4851.0 / 1048576.0 * e12)
                         - (14157.0 / 4194304.0 * e14);
            _coefLine2 = (-3.0 / 8.0 * ESq)
                         - (3.0 / 32.0 * e4)
                         - (45.0 / 1024.0 * e6)
                         - (105.0 / 4096.0 * e8)
                         - (2205.0 / 131072.0 * e10)
                         - (6237.0 / 524288.0 * e12)
                         - (297297.0 / 33554432.0 * e14);
            _coefLine3 = (15.0 / 256.0 * e4)
                         + (45.0 / 1024.0 * e6)
                         + (525.0 / 16384.0 * e8)
                         + (1575.0 / 65536.0 * e10)
                         + (155925.0 / 8388608.0 * e12)
                         + (495495.0 / 33554432.0 * e14);
            _coefLine4 = (-35.0 / 3072.0 * e6)
                         - (175.0 / 12288.0 * e8)
                         - (3675.0 / 262144.0 * e10)
                         - (13475.0 / 1048576.0 * e12)
                         - (385385.0 / 33554432.0 * e14);
            _coefLine5 = (315.0 / 131072.0 * e8)
                         + (2205.0 / 524288.0 * e10)
                         + (43659.0 / 8388608.0 * e12)
                         + (189189.0 / 33554432.0 * e14);
            _coefLine6 = (-693.0 / 1310720.0 * e10)
                         - (6237.0 / 5242880.0 * e12)
                         - (297297.0 / 167772160.0 * e14);
            _coefLine7 = (1001.0 / 8388608.0 * e12)
                         + (11011.0 / 33554432.0 * e14);
            _coefLine8 = (-6435.0 / 234881024.0 * e14);

            var sinLatOrigin = Math.Sin(_origin.Latitude);
            var v            = MajorAxis / Math.Sqrt(1.0 - (ESq * sinLatOrigin * sinLatOrigin));

            _vCosLatOrigin = v * Math.Cos(_origin.Latitude);
        }
        public void epsg_example_1_3_14()
        {
            var projection = new EquidistantCylindrical(GeographicCoordinate.Zero, Vector2.Zero, new SpheroidEquatorialInvF(6378137, 298.257223563));

            var input = new GeographicCoordinate(0.959931086, 0.174532925);
            var expected = new Point2(1113194.91, 6097230.31);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.004);
            Assert.AreEqual(expected.Y, result.Y, 0.02);
        }
Beispiel #12
0
        public void Test(string geoResourceName, string mercResourceName, double projectDelta, double unprojectDelta)
        {
            var      latLonData   = GoldData.GetReadyReader(geoResourceName);
            var      lccData      = GoldData.GetReadyReader(mercResourceName);
            var      latTrueScale = lccData["LATITUDE OF TRUE SCALE"];
            Mercator projection;

            if (null == latTrueScale)
            {
                projection = new Mercator(
                    Double.Parse(lccData["CENTRAL MERIDIAN"]) / 180 * Math.PI,
                    Double.Parse(lccData["SCALE FACTOR"]),
                    new Vector2(
                        Double.Parse(lccData["FALSE EASTING"]),
                        Double.Parse(lccData["FALSE NORTHING"])
                        ),
                    GoldData.GenerateSpheroid(lccData["DATUM"])
                    );
            }
            else
            {
                projection = new Mercator(
                    new GeographicCoordinate(
                        Double.Parse(latTrueScale) / 180 * Math.PI,
                        Double.Parse(lccData["CENTRAL MERIDIAN"]) / 180 * Math.PI
                        ),
                    new Vector2(
                        Double.Parse(lccData["FALSE EASTING"]),
                        Double.Parse(lccData["FALSE NORTHING"])
                        ),
                    GoldData.GenerateSpheroid(lccData["DATUM"])
                    );
            }

            var inverse = projection.GetInverse();

            while (latLonData.Read() && lccData.Read())
            {
                var coord     = latLonData.CurrentLatLon();
                var coordRads = latLonData.CurrentLatLonRadians();
                var expected  = lccData.CurrentPoint2D();

                var projected = projection.TransformValue(coordRads);
                Assert.AreEqual(expected.X, projected.X, projectDelta);
                Assert.AreEqual(expected.Y, projected.Y, projectDelta);

                var unProjected = inverse.TransformValue(expected);
                unProjected = new GeographicCoordinate(unProjected.Latitude * 180.0 / Math.PI, unProjected.Longitude * 180.0 / Math.PI);
                Assert.AreEqual(coord.Latitude, unProjected.Latitude, unprojectDelta);
                Assert.AreEqual(coord.Longitude, unProjected.Longitude, unprojectDelta);
            }
        }
Beispiel #13
0
        public override Point2 TransformValue(GeographicCoordinate source)
        {
            var m       = CalculateM(source.Latitude);
            var sinLat  = Math.Sin(source.Latitude);
            var mScalar = Math.Cos(source.Latitude) / Math.Sqrt(ESq * sinLat * sinLat);
            var p       = (MajorAxis * MScalarOrigin / SinLatOrigin) + MOrigin + m;
            var t       = MajorAxis * mScalar * (source.Longitude - GeographicOrigin.Longitude) / p;

            return(new Point2(
                       (p * Math.Sin(t)) + FalseProjectedOffset.X,
                       ((MajorAxis * MScalarOrigin / SinLatOrigin) - (p * Math.Cos(t))) + FalseProjectedOffset.Y
                       ));
        }
        public void Vincenty_CorrectlyCalculatesBearingFromPointBearingDistance(double latA, double lonA, double bearingInRadians, double distanceInMeters,
                                                                                double expectedBearing, int maxIterations, double tolerance)
        {
            IGeographicCoordinate pointA = new GeographicCoordinate(latA, lonA);
            IAngle    initialBearing     = new Angle(bearingInRadians, AngleMeasurement.Radians);
            IDistance distance           = new Distance(distanceInMeters, DistanceMeasurement.Meters);

            IAngle expected = new Angle(expectedBearing, AngleMeasurement.Radians);

            IAngle result = pointA.BearingFrom(initialBearing, distance, maxIterations, tolerance);

            Assert.Equal(expected, result);
        }
Beispiel #15
0
        public override Point2 TransformValue(GeographicCoordinate source)
        {
            throw new NotImplementedException("I have no idea what is going on.");
            var sinLat = Math.Sin(source.Latitude);
            var q      = (1 - ESq) * (
                (sinLat / (1 - (ESq * sinLat * sinLat)))
                - ((1.0 / (2.0 * E)) * Math.Log((1 - (E * sinLat)) / (1 + (E * sinLat))))
                );

            return(new Point2(
                       MajorAxis * Scale * (source.Longitude - GeographicOrigin.Longitude),
                       MajorAxis * q / (2.0 * Scale)));
        }
Beispiel #16
0
 /// <summary>
 /// Constructs a Mercator projection from 2 standard parallels.
 /// </summary>
 /// <param name="geographicOrigin">The geographic origin.</param>
 /// <param name="falseProjectedOffset">The false projected offset.</param>
 /// <param name="spheroid">The spheroid.</param>
 public Mercator(
     GeographicCoordinate geographicOrigin,
     Vector2 falseProjectedOffset,
     ISpheroid <double> spheroid
     ) : this(
         geographicOrigin.Longitude,
         CalculateScaleFactor(geographicOrigin.Latitude, spheroid.ESquared),
         falseProjectedOffset,
         spheroid
         )
 {
     Contract.Requires(spheroid != null);
 }
Beispiel #17
0
        public override Point2 TransformValue(GeographicCoordinate source)
        {
            var sinLat = Math.Sin(source.Latitude);
            var x      = MajorAxis * (source.Longitude - GeographicOrigin.Longitude) * Math.Cos(source.Latitude)
                         / Math.Sqrt(1 - (ESq * sinLat * sinLat));
            var m = CalculateM(source.Latitude);
            var y = m - MOrigin + (x * x * Math.Tan(source.Latitude) * Math.Sqrt(1 - (ESq * sinLat * sinLat)) / (2.0 * MajorAxis));

            return(new Point2(
                       FalseProjectedOffset.X + x,
                       FalseProjectedOffset.Y + y
                       ));
        }
Beispiel #18
0
        public PolarStereographic(GeographicCoordinate geographicOrigin, double scaleFactor, Vector2 falseProjectedOffset, ISpheroid <double> spheroid)
            : base(falseProjectedOffset, spheroid)
        {
            Contract.Requires(spheroid != null);
            ScaleFactor      = scaleFactor;
            GeographicOrigin = geographicOrigin;
            CrazyEValue      = CalculateCrazyEValue(E);
            CoefficientT     = MajorAxis * 2.0 * ScaleFactor / CrazyEValue;

            _transform = IsNorth(geographicOrigin.Latitude)
                ? (Func <GeographicCoordinate, Point2>)TransformValueNorth
                : TransformValueSouth;
        }
Beispiel #19
0
 public TransverseMercatorSouth(
     GeographicCoordinate naturalOrigin,
     Vector2 falseProjectedOffset,
     double scaleFactor,
     ISpheroid <double> spheroid
     ) : base(
         naturalOrigin,
         new Vector2(-falseProjectedOffset.X, -falseProjectedOffset.Y),
         scaleFactor,
         spheroid
         )
 {
     Contract.Requires(spheroid != null);
 }
 public LambertCylindricalEqualAreaSpherical(GeographicCoordinate origin, Vector2 offset, ISpheroid <double> spheroid)
     : base(offset, spheroid)
 {
     Contract.Requires(spheroid != null);
     // ReSharper disable CompareOfFloatsByEqualityOperator
     GeographicOrigin = origin;
     CosLatOrigin     = Math.Cos(GeographicOrigin.Latitude);
     R = MajorAxis;
     if (E != 0)
     {
         R *= Math.Sqrt((1 - (((1.0 - ESq) / (2.0 * E)) * Math.Log((1 - E) / (1 + E)))) / 2.0);
     }
     // ReSharper restore CompareOfFloatsByEqualityOperator
 }
Beispiel #21
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);
        }
Beispiel #22
0
    public void Initalize(int id, int res, float scale, bool shaded, GameObject planetObj)
    {
        m_id    = id;
        m_res   = res;
        m_res2  = m_res * m_res;
        m_scale = scale;
        m_geo   = new GeographicCoordinate[8];
        for (int i = 0; i < m_geo.Length; i++)
        {
            m_geo[i] = new GeographicCoordinate();
        }
        m_cullVector = transform.localPosition.normalized;

        m_planet = new PlanetInfo()
        {
            obj        = planetObj,
            planetComp = planetObj.GetComponent <Planet>()
        };

        m_neighbourChunks = new PlanetChunk[27];

        m_meshFilter   = GetComponent <MeshFilter>();
        m_meshCollider = GetComponent <MeshCollider>();

        m_mcRender = new MarchingCubes
        {
            m_MCRenderShader         = m_MCRenderShader,
            m_clearVerticesShader    = m_ClearVerticesShader,
            m_calculateNormalsShader = m_CalculateNormalsShader,
            m_meshMaterial           = m_meshMaterial,
            m_recalculateNormals     = !shaded,
            m_chunkTransform         = transform
        };
        m_mcRender.InitalizeRenderMesh(m_res, m_res, m_res, m_scale);

        m_mcCollider = new MarchingCubes
        {
            m_MCColliderShader    = m_MCColliderShader,
            m_clearVerticesShader = m_ClearVerticesShader,
        };
        m_mcCollider.InitalizeColliderCompute(m_res, m_res, m_res, scale);

        m_borderMaps.borderMapx   = new float[2 * m_res2];
        m_borderMaps.borderMapy   = new float[2 * m_res2];
        m_borderMaps.borderMapz   = new float[2 * m_res2];
        m_borderMaps.borderMapxy  = new float[3 * m_res];
        m_borderMaps.borderMapyz  = new float[3 * m_res];
        m_borderMaps.borderMapxz  = new float[3 * m_res];
        m_borderMaps.borderMapxyz = new float[4];
    }
        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);
        }
Beispiel #24
0
 public LambertConicConformal1SpWest(
     GeographicCoordinate geographicOrigin,
     double originScaleFactor,
     Vector2 falseProjectedOffset,
     ISpheroid <double> spheroid
     ) : base(
         geographicOrigin,
         originScaleFactor,
         new Vector2(-falseProjectedOffset.X, falseProjectedOffset.Y),
         spheroid
         )
 {
     Contract.Requires(spheroid != null);
 }
Beispiel #25
0
 private static IEnumerable <List <GeographicCoordinate> > ReadPagesToGeographicCoordinate(IEnumerator <Dictionary <int, Shape> > pages)
 {
     while (pages.MoveNext())
     {
         var page   = pages.Current;
         var points = new List <GeographicCoordinate>(page.Count);
         foreach (var shape in page.Values)
         {
             var p = new GeographicCoordinate(shape.Vertices[1], shape.Vertices[0]);
             points.Add(p);
         }
         yield return(points);
     }
 }
        public override Point2 TransformValue(GeographicCoordinate source)
        {
            var lonDiff = source.Longitude - (
                GeogCoordinatesAreRelativeToGreenwich
                    ? GreenwichCenterLongitude
                    : ParisCenterLongitude);

            var sinLat      = Math.Sin(source.Latitude);
            var eSinLat     = E * sinLat;
            var halfLat     = source.Latitude / 2.0;
            var betaLonDiff = Beta * lonDiff;
            var q           = C + (
                Beta
                * Math.Log(
                    Math.Tan(QuarterPi + halfLat)
                    * Math.Pow((1 - eSinLat) / (1 + eSinLat), EHalf)
                    )
                );
            var    p = (Math.Atan(Math.Pow(Math.E, q)) * 2.0) - HalfPi;
            var    cosP = Math.Cos(p);
            var    sinP = Math.Sin(p);
            var    cosL = Math.Cos(betaLonDiff);
            var    sinL = Math.Sin(betaLonDiff);
            var    u = (cosP * cosL * Math.Cos(SLatitude)) + (sinP * Math.Sin(SLatitude));
            var    v = (cosP * cosL * Math.Sin(SLatitude)) - (sinP * Math.Cos(SLatitude));
            var    w = cosP * sinL;
            var    d = Math.Sqrt((u * u) + (v * v));
            double lPrime, pPrime;

            if (0 == d)
            {
                lPrime = 0;
                pPrime = w < 0 ? -HalfPi : HalfPi;
            }
            else
            {
                lPrime = Math.Atan(v / (u + d)) * 2.0;
                pPrime = Math.Atan(w / d);
            }
            var h  = -lPrime;
            var hi = Math.Log(Math.Tan(QuarterPi + (pPrime / 2.0)));
            var g  = (1 - Math.Cos(2.0 * Azimuth)) / 12.0;
            var gi = Math.Sin(2.0 * Azimuth) / 12.0;

            var x = FalseProjectedOffset.X + (R * (hi + (gi * hi * hi * hi)));
            var y = FalseProjectedOffset.Y + (R * (h + (g * h * h * h)));

            return(new Point2(x, y));
        }
        public override Point2 TransformValue(GeographicCoordinate source)
        {
            double deltaLon          = source.Longitude - GeographicOrigin.Longitude;
            double cosLat            = Math.Cos(source.Latitude);
            double cosDeltaLonCosLat = Math.Cos(deltaLon) * cosLat;
            double sinLat            = Math.Sin(source.Latitude);
            double rk = R * Math.Sqrt(
                2.0 /
                (1.0 + (_sinLatOrg * sinLat) + (_cosLatOrg * cosDeltaLonCosLat))
                );
            double x = rk * cosLat * Math.Sin(deltaLon);
            double y = rk * ((_cosLatOrg * sinLat) - (_sinLatOrg * cosDeltaLonCosLat));

            return(new Point2(x, y));
        }
Beispiel #28
0
        public void EpsgExample_1_3_3_C_Test()
        {
            var projection = Mercator.ConstructVariantC(
                new GeographicCoordinate(0.73303829, 0.89011792),
                new Vector2(0, 0),
                new SpheroidEquatorialInvF(6378245, 298.3));

            var input    = new GeographicCoordinate(0.9250245, 0.9250245);
            var expected = new Point2(165704.29, 1351950.22);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.04);
            Assert.AreEqual(expected.Y, result.Y, 0.06);
        }
        public void EpsgExample_1_3_3_2_Test()
        {
            var projection = new PopularVisualizationPseudoMercator(
                new GeographicCoordinate(0, 0),
                new Vector2(0, 0),
                new SpheroidEquatorialPolar(6378137, 298.2572236)
            );
            var input = new GeographicCoordinate(0.425542460, -1.751147016);
            var expected = new Point2(-11169055.58, 2800000.00);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.005);
            Assert.AreEqual(expected.Y, result.Y, 0.006);
        }
Beispiel #30
0
        public void EpsgExample_1_3_3_B_InverseTest()
        {
            var projection = new Mercator(
                new GeographicCoordinate(0.73303829, 0.89011792),
                new Vector2(0, 0),
                new SpheroidEquatorialInvF(6378245, 298.3)
                );
            var expected = new GeographicCoordinate(0.9250245, 0.9250245);
            var input    = new Point2(165704.29, 5171848.07);

            var result = projection.GetInverse().TransformValue(input);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.000000006);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.000000005);
        }
        public void EpsgExample221WithoutHeightTest()
        {
            var transform = new GeographicGeocentricTransformation(new SpheroidEquatorialInvF(6378137.000, 298.2572236));
            var inputValue = new GeographicCoordinate(0.939151102, 0.037167659); // the actual point is 73 from the surface
            var expectedVector = new Vector3(3771793.968, 140253.342, 5124304.349);
            var expectedNormal = expectedVector.GetNormalized();

            var result = transform.TransformValue(new GeographicCoordinate(inputValue.Latitude, inputValue.Longitude));
            var resultVector = new Vector3(result); // so we can check that the normal is at least the same, as we remove height information
            var resultNormal = resultVector.GetNormalized();
            Assert.AreEqual(expectedNormal.X, resultNormal.X, 0.00000003);
            Assert.AreEqual(expectedNormal.Y, resultNormal.Y, 0.000000002);
            Assert.AreEqual(expectedNormal.Z, resultNormal.Z, 0.00000003);
            Assert.AreEqual(resultVector.GetMagnitude(), expectedVector.GetMagnitude() - 73.0, 0.0005); // it should be about 73 units from the expected height above the surface
        }
        public void EpsgExample1312()
        {
            var projection = new LambertConicConformal1Sp(
                new GeographicCoordinate(0.31415927, -1.34390352),
                1,
                new Vector2(250000, 150000),
                new SpheroidEquatorialInvF(6378206.400, 294.97870));
            var input = new GeographicCoordinate(0.31297535, -1.34292061);
            var expected = new Point2(255966.58, 142493.51);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.006);
            Assert.AreEqual(expected.Y, result.Y, 0.04);
        }
Beispiel #33
0
        public void EpsgExample_1_3_3_B_Test()
        {
            var projection = new Mercator(
                new GeographicCoordinate(0.73303829, 0.89011792),
                new Vector2(0, 0),
                new SpheroidEquatorialInvF(6378245, 298.3)
            );
            var input = new GeographicCoordinate(0.9250245, 0.9250245);
            var expected = new Point2(165704.29, 5171848.07);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.03);
            Assert.AreEqual(expected.Y, result.Y, 0.05);
        }
Beispiel #34
0
        public void EpsgExample1312()
        {
            var projection = new LambertConicConformal1Sp(
                new GeographicCoordinate(0.31415927, -1.34390352),
                1,
                new Vector2(250000, 150000),
                new SpheroidEquatorialInvF(6378206.400, 294.97870));
            var input    = new GeographicCoordinate(0.31297535, -1.34292061);
            var expected = new Point2(255966.58, 142493.51);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.006);
            Assert.AreEqual(expected.Y, result.Y, 0.04);
        }
        public void EpsgExample_1_3_3_2_InverseTest()
        {
            var projection = new PopularVisualizationPseudoMercator(
                new GeographicCoordinate(0, 0),
                new Vector2(0, 0),
                new SpheroidEquatorialPolar(6378137, 298.2572236)
                );
            var expected = new GeographicCoordinate(0.425542460, -1.751147016);
            var input    = new Point2(-11169055.58, 2800000.00);

            var result = projection.GetInverse().TransformValue(input);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.0000000008);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.0000000008);
        }
Beispiel #36
0
            public override Point2 TransformValue(GeographicCoordinate source)
            {
                // common
                var lonDelta = source.Longitude - LongitudeOrigin;
                var eSinLat  = E * Math.Sin(source.Latitude);
                var theta    = Math.Tan(QuarterPi - (source.Latitude / 2.0))
                               / Math.Pow((1 - eSinLat) / (1 + eSinLat), EHalf);
                var q       = H / Math.Pow(theta, B);                                                             // Q
                var invQ    = 1 / q;
                var sFactor = (q - invQ) / 2.0;                                                                   // S
                var tFactor = (q + invQ) / 2.0;                                                                   // T
                var vFactor = Math.Sin(B * lonDelta);                                                             // V
                var uFactor = ((-vFactor * Math.Cos(GammaOrigin)) + (sFactor * Math.Sin(GammaOrigin))) / tFactor; // U
                var vScalar = A * Math.Log((1 - uFactor) / (1 + uFactor)) / (2.0 * B);                            // v

                // variant B
                double uScalar;

                if (HasHighAzimuth)
                {
                    if (lonDelta == 0)
                    {
                        uScalar = 0;
                    }
                    else
                    {
                        uScalar = A * Math.Atan(((sFactor * Math.Cos(GammaOrigin)) + (vFactor * Math.Sin(GammaOrigin))) / Math.Cos(B * lonDelta)) / B;
                        var signLatNeg = GeographicCenter.Latitude < 0;
                        var signLonNeg = lonDelta < 0;
                        var negUc      = signLatNeg ^ signLonNeg;
                        var absUc      = Math.Abs(Uc);
                        uScalar = negUc ? uScalar + absUc : uScalar - absUc;
                    }
                }
                else
                {
                    uScalar = A * Math.Atan(((sFactor * Math.Cos(GammaOrigin)) + (vFactor * Math.Sin(GammaOrigin))) / Math.Cos(B * lonDelta)) / B;
                    var negUc = GeographicCenter.Latitude < 0;
                    var absUc = Math.Abs(Uc);
                    uScalar = negUc ? uScalar + absUc : uScalar - absUc;
                }

                // common
                var x = (vScalar * Math.Cos(AngleFromRectified)) + (uScalar * Math.Sin(AngleFromRectified)) + FalseProjectedOffset.X;
                var y = (uScalar * Math.Cos(AngleFromRectified)) - (vScalar * Math.Sin(AngleFromRectified)) + FalseProjectedOffset.Y;

                return(new Point2(x, y));
            }
Beispiel #37
0
        public void Test(string geoResourceName, string mercResourceName, double projectDelta, double unprojectDelta)
        {
            var latLonData = GoldData.GetReadyReader(geoResourceName);
            var lccData = GoldData.GetReadyReader(mercResourceName);
            var latTrueScale = lccData["LATITUDE OF TRUE SCALE"];
            Mercator projection;
            if (null == latTrueScale) {
                projection = new Mercator(
                    Double.Parse(lccData["CENTRAL MERIDIAN"]) / 180 * Math.PI,
                    Double.Parse(lccData["SCALE FACTOR"]),
                    new Vector2(
                        Double.Parse(lccData["FALSE EASTING"]),
                        Double.Parse(lccData["FALSE NORTHING"])
                    ),
                    GoldData.GenerateSpheroid(lccData["DATUM"])
                );
            }
            else {
                projection = new Mercator(
                    new GeographicCoordinate(
                        Double.Parse(latTrueScale) / 180 * Math.PI,
                        Double.Parse(lccData["CENTRAL MERIDIAN"]) / 180 * Math.PI
                    ),
                    new Vector2(
                        Double.Parse(lccData["FALSE EASTING"]),
                        Double.Parse(lccData["FALSE NORTHING"])
                    ),
                    GoldData.GenerateSpheroid(lccData["DATUM"])
                );
            }

            var inverse = projection.GetInverse();

            while (latLonData.Read() && lccData.Read()) {
                var coord = latLonData.CurrentLatLon();
                var coordRads = latLonData.CurrentLatLonRadians();
                var expected = lccData.CurrentPoint2D();

                var projected = projection.TransformValue(coordRads);
                Assert.AreEqual(expected.X, projected.X, projectDelta);
                Assert.AreEqual(expected.Y, projected.Y, projectDelta);

                var unProjected = inverse.TransformValue(expected);
                unProjected = new GeographicCoordinate(unProjected.Latitude * 180.0 / Math.PI, unProjected.Longitude * 180.0 / Math.PI);
                Assert.AreEqual(coord.Latitude, unProjected.Latitude, unprojectDelta);
                Assert.AreEqual(coord.Longitude, unProjected.Longitude, unprojectDelta);
            }
        }
        public void EpsgExample1311Test()
        {
            var proj = new LambertConicConformal2Sp(
                new GeographicCoordinate(0.48578331, -1.72787596),
                0.49538262,
                0.52854388,
                new Vector2(2000000.0, 0),
                new SpheroidEquatorialInvF(20925832.16, 294.97870)
            );
            var a = new GeographicCoordinate(0.49741884, -1.67551608);
            var b = new Point2(2963503.91, 254759.80);

            var projected = proj.TransformValue(a);
            Assert.AreEqual(b.X, projected.X, 0.05);
            Assert.AreEqual(b.Y, projected.Y, 0.04);
        }
        public void Epsg_1_3_1_5_Inverse_Test()
        {
            var projection = new LambertConicNearConformal(
                new GeographicCoordinate(0.604756586, 0.651880476),
                0.99962560,
                new Vector2(300000.00, 300000.00),
                new SpheroidEquatorialInvF(6378249.2, 293.46602)
                );
            var expected = new GeographicCoordinate(0.654874806, 0.595793792);
            var input    = new Point2(15707.96, 623165.96);

            var result = projection.GetInverse().TransformValue(input);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.0000000002);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.00000000008);
        }
Beispiel #40
0
 public LambertAzimuthalEqualAreaOblique(
     GeographicCoordinate geogOrigin,
     Vector2 falseOffset,
     ISpheroid <double> spheroid
     ) : base(geogOrigin, falseOffset, spheroid)
 {
     QOrigin         = OneMinusESq * ((SinLatOrigin / (1.0 - (ESq * SinLatOrigin * SinLatOrigin))) - (OneOverTwoE * Math.Log((1.0 - ESinLatOrigin) / (1.0 + ESinLatOrigin))));
     QRadiusParallel = MajorAxis * Math.Sqrt(QParallel / 2.0);
     BetaOrigin      = Math.Asin(QOrigin / QParallel);
     SinBetaOrigin   = Math.Sin(BetaOrigin);
     CosBetaOrigin   = Math.Cos(BetaOrigin);
     D = MajorAxis
         * (CosLatOrigin / Math.Sqrt(1.0 - (ESq * SinLatOrigin * SinLatOrigin)))
         / (QRadiusParallel * CosBetaOrigin);
     ;
 }
Beispiel #41
0
        public void EpsgExample_1_3_3_A_Test()
        {
            var projection = new Mercator(
                1.91986218,
                0.997,
                new Vector2(3900000, 900000),
                new SpheroidEquatorialInvF(6377397.155, 299.15281)
            );
            var input = new GeographicCoordinate(-0.05235988, 2.09439510);
            var expected = new Point2(5009726.58, 569150.82);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.03);
            Assert.AreEqual(expected.Y, result.Y, 0.02);
        }
Beispiel #42
0
        public override Point2 TransformValue(GeographicCoordinate source)
        {
            var deltaLon    = source.Longitude - GeographicOrigin.Longitude;
            var cosDeltaLon = Math.Cos(deltaLon);
            var sinDeltaLon = Math.Sin(deltaLon);
            var sinLat      = Math.Sin(source.Latitude);
            var q           = OneMinusESq * ((sinLat / (1.0 - (ESq * sinLat * sinLat))) - (OneOverTwoE * Math.Log((1.0 - (E * sinLat)) / (1.0 + (E * sinLat)))));
            var beta        = Math.Asin(q / QParallel);
            var cosBeta     = Math.Cos(beta);
            var sinBeta     = Math.Sin(beta);
            var b           = QRadiusParallel * Math.Sqrt(2.0 / (1.0 + (SinBetaOrigin * sinBeta) + (CosBetaOrigin * cosBeta * cosDeltaLon)));
            var east        = FalseProjectedOffset.X + ((b * D) * (cosBeta * sinDeltaLon));
            var north       = FalseProjectedOffset.Y + ((b / D) * ((CosBetaOrigin * sinBeta) - (SinBetaOrigin * cosBeta * cosDeltaLon)));

            return(new Point2(east, north));
        }
        public void EpsgExample_1_3_5_3_Test()
        {
            var projection = new TransverseMercatorSouth(
                new GeographicCoordinate(0, 0.506145483),
                new Vector2(0, 0),
                1,
                new SpheroidEquatorialInvF(6378137, 298.25722356)
            );
            var expected = new Point2(2847342.74, 71984.49);
            var input = new GeographicCoordinate(-0.449108618, 0.493625066);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.003);
            Assert.AreEqual(expected.Y, result.Y, 0.002);
        }
Beispiel #44
0
        public void EpsgExample_1_3_7_1_Inverse()
        {
            var projection = new ObliqueStereographic(
                new GeographicCoordinate(0.910296727, 0.094032038),
                0.9999079,
                new Vector2(155000.00, 463000.00),
                new SpheroidEquatorialInvF(6377397.155, 299.15281)
            );
            var expected = new GeographicCoordinate(0.925024504, 0.104719755);
            var input = new Point2(196105.283, 557057.739);

            var result = projection.GetInverse().TransformValue(input);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.000000001);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.0000000007);
        }
Beispiel #45
0
 protected LambertAzimuthalEqualArea(
     GeographicCoordinate geogOrigin,
     Vector2 falseOffset,
     ISpheroid <double> spheroid
     ) : base(falseOffset, spheroid)
 {
     GeographicOrigin = geogOrigin;
     OneMinusESq      = 1.0 - ESq;
     OneMinusE        = 1.0 - E;
     OnePlusE         = 1.0 + E;
     OneOverTwoE      = 1.0 / (2.0 * E);
     SinLatOrigin     = Math.Sin(GeographicOrigin.Latitude);
     CosLatOrigin     = Math.Cos(GeographicOrigin.Latitude);
     ESinLatOrigin    = E * SinLatOrigin;
     QParallel        = OneMinusESq * ((1.0 / OneMinusESq) - (OneOverTwoE * Math.Log(OneMinusE / OnePlusE)));
 }
Beispiel #46
0
        public void EpsgExample221WithoutHeightTest()
        {
            var transform      = new GeographicGeocentricTransformation(new SpheroidEquatorialInvF(6378137.000, 298.2572236));
            var inputValue     = new GeographicCoordinate(0.939151102, 0.037167659); // the actual point is 73 from the surface
            var expectedVector = new Vector3(3771793.968, 140253.342, 5124304.349);
            var expectedNormal = expectedVector.GetNormalized();

            var result       = transform.TransformValue(new GeographicCoordinate(inputValue.Latitude, inputValue.Longitude));
            var resultVector = new Vector3(result); // so we can check that the normal is at least the same, as we remove height information
            var resultNormal = resultVector.GetNormalized();

            Assert.AreEqual(expectedNormal.X, resultNormal.X, 0.00000003);
            Assert.AreEqual(expectedNormal.Y, resultNormal.Y, 0.000000002);
            Assert.AreEqual(expectedNormal.Z, resultNormal.Z, 0.00000003);
            Assert.AreEqual(resultVector.GetMagnitude(), expectedVector.GetMagnitude() - 73.0, 0.0005); // it should be about 73 units from the expected height above the surface
        }
Beispiel #47
0
        public void EpsgExample_1_3_7_2_A_Inverse()
        {
            var projection = new PolarStereographic(
                new GeographicCoordinate(1.570796327, 0),
                0.994,
                new Vector2(2000000.00, 2000000.00),
                new SpheroidEquatorialInvF(6378137, 298.2572236)
            );
            var expected = new GeographicCoordinate(1.274090354, 0.767944871);
            var input = new Point2(3320416.75, 632668.43);

            var result = projection.GetInverse().TransformValue(input);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.0000000005);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.000000001);
        }
        public void Epsg_1_3_1_5_Test()
        {
            var projection = new LambertConicNearConformal(
                new GeographicCoordinate(0.604756586, 0.651880476),
                0.99962560,
                new Vector2(300000.00, 300000.00),
                new SpheroidEquatorialInvF(6378249.2, 293.46602)
            );
            var input = new GeographicCoordinate(0.654874806, 0.595793792);
            var expected = new Point2(15707.96, 623165.96);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.0004);
            Assert.AreEqual(expected.Y, result.Y, 0.02);
        }
        public void EpsgExample1351Test()
        {
            var projection = new TransverseMercator(
                new GeographicCoordinate(0.85521133, -0.03490659),
                new Vector2(400000.00, -100000.00),
                0.9996012717,
                new SpheroidEquatorialInvF(6377563.396, 299.32496)
            );

            var input = new GeographicCoordinate(0.88139127, 0.00872665);
            var expected = new Point2(577274.99, 69740.50);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.03);
            Assert.AreEqual(expected.Y, result.Y, 0.002);
        }
Beispiel #50
0
 public NeysProjection(
     GeographicCoordinate geographicOrigin,
     double standardParallel,
     Vector2 falseProjectedOffset,
     ISpheroid<double> spheroid
 )
     : base(new GeographicCoordinate(
         geographicOrigin.Latitude,
         geographicOrigin.Longitude > Math.PI ? (geographicOrigin.Longitude - TwoPi) : geographicOrigin.Longitude
         ),
     geographicOrigin.Latitude >= 0 ? standardParallel : -standardParallel,
     geographicOrigin.Latitude >= 0 ? MaximumLatitude : -MaximumLatitude,
     falseProjectedOffset,
     spheroid)
 {
     Contract.Requires(spheroid != null);
 }
        public void gigs_sample_rev()
        {
            var degToRad = Math.PI / 180.0;
            var projection = new AmericanPolyconic(
                new GeographicCoordinate(0, -54.0 * degToRad),
                new Vector2(5000000, 10000000),
                new SpheroidEquatorialInvF(6378.137 * 1000, 298.2572221)
            );

            var expected = new GeographicCoordinate(-6 * degToRad, -45 * degToRad);
            var input = new Point2(5996378.71, 9328349.94);

            var result = projection.GetInverse().TransformValue(input);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.0006);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.00001);
        }
        public void EpsgExample1311InverseTest()
        {
            var proj = new LambertConicConformal2Sp(
                new GeographicCoordinate(0.48578331, -1.72787596),
                0.49538262,
                0.52854388,
                new Vector2(2000000.0, 0),
                new SpheroidEquatorialInvF(20925832.16, 294.97870)
            );
            var a = new GeographicCoordinate(0.49741884, -1.67551608);
            var b = new Point2(2963503.91, 254759.80);

            var unProjected = proj.GetInverse().TransformValue(b);

            Assert.AreEqual(a.Latitude, unProjected.Latitude, 0.000000002);
            Assert.AreEqual(a.Longitude, unProjected.Longitude, 0.000000003);
        }
        public void Epsg_1_3_6_1_Test()
        {
            var projection = new HotineObliqueMercator.VariantB(
                new GeographicCoordinate(0.069813170, 2.007128640),
                0.930536611,
                0.927295218,
                0.99984,
                new Vector2(590476.87, 442857.65),
                new SpheroidEquatorialInvF(6377298.556, 300.8017)
            );
            var input = new GeographicCoordinate(0.094025313, 2.021187362);
            var expected = new Point2(679245.73, 596562.78);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.003);
            Assert.AreEqual(expected.Y, result.Y, 0.001);
        }
        public void EpsgExample1312Inverse()
        {
            var projection = new LambertConicConformal1Sp(
                new GeographicCoordinate(0.31415927, -1.34390352),
                1,
                new Vector2(250000, 150000),
                new SpheroidEquatorialInvF(6378206.400, 294.97870));
            Assert.That(projection.HasInverse);
            var inverse = projection.GetInverse();

            var expected = new GeographicCoordinate(0.31297535, -1.34292061);
            var input = new Point2(255966.58, 142493.51);

            var result = inverse.TransformValue(input);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.00000001);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.00000001);
        }
Beispiel #55
0
        public void Espg_1_3_2_1_InverseTest()
        {
            var projection = new Krovak(
                new GeographicCoordinate(0.863937979, 0.741764932),
                1.370083463,
                0.528627762,
                0.9999,
                Vector2.Zero,
                new SpheroidEquatorialInvF(6377397.155, 299.15281)
            );
            var expected = new GeographicCoordinate(0.876312568, 0.294084);
            var input = new Point2(1050538.63, 568991.00);

            var result = projection.GetInverse().TransformValue(input);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.0000000008);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.000001);
        }
Beispiel #56
0
        public void Espg_1_3_2_2_Test()
        {
            var projection = new KrovakNorth(
                new GeographicCoordinate(0.863937979, 0.741764932),
                1.370083463,
                0.528627762,
                0.9999,
                Vector2.Zero,
                new SpheroidEquatorialInvF(6377397.155, 299.15281)
            );
            var input = new GeographicCoordinate(0.876312568, 0.294084);
            var expected = new Point2(-568991.00, -1050538.63);

            var result = projection.TransformValue(input);

            Assert.AreEqual(expected.X, result.X, 0.1);
            Assert.AreEqual(expected.Y, result.Y, 0.1);
        }
Beispiel #57
0
 public KrovakNorth(
     GeographicCoordinate geographicOrigin,
     double latitudeOfPseudoStandardParallel,
     double azimuthOfInitialLine,
     double scaleFactor,
     Vector2 falseProjectedOffset,
     ISpheroid<double> spheroid
 )
     : this(new Krovak(
     geographicOrigin,
     latitudeOfPseudoStandardParallel,
     azimuthOfInitialLine,
     scaleFactor,
     falseProjectedOffset,
     spheroid
 ))
 {
     Contract.Requires(spheroid != null);
 }
        public void map_proj_working_manual_lambert_az_eq_area_spherical_example()
        {
            var projection = new LambertAzimuthalEqualAreaSpherical(
                new GeographicCoordinate(0, 0),
                new Vector2(0, 0),
                new Sphere(1));
            Assert.That(projection.HasInverse);
            var inverse = projection.GetInverse();

            var projectedExpected = new Point2(0.61040, 0.54826);
            var geographicExpected = new GeographicCoordinate(30 * Math.PI / 180.0, 40 * Math.PI / 180.0);

            var projectedActual = projection.TransformValue(geographicExpected);
            Assert.AreEqual(projectedExpected.X, projectedActual.X, 0.00001);
            Assert.AreEqual(projectedExpected.Y, projectedActual.Y, 0.000003);

            var geographicActual = inverse.TransformValue(projectedExpected);
            Assert.AreEqual(geographicExpected.Latitude, geographicActual.Latitude, 0.00001);
            Assert.AreEqual(geographicExpected.Longitude, geographicActual.Longitude, 0.000004);
        }
        public void Epsg_1_3_6_1_Inverse_Test()
        {
            var projectionForward = new HotineObliqueMercator.VariantB(
                new GeographicCoordinate(0.069813170, 2.007128640),
                0.930536611,
                0.927295218,
                0.99984,
                new Vector2(590476.87, 442857.65),
                new SpheroidEquatorialInvF(6377298.556, 300.8017)
            );
            Assert.That(projectionForward.HasInverse);
            var inverse = projectionForward.GetInverse();

            var expected = new GeographicCoordinate(0.094025313, 2.021187362);
            var input = new Point2(679245.73, 596562.78);

            var result = inverse.TransformValue(input);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.00001);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.0000000005);
        }
        public void epsg_example_1_3_11()
        {
            var projection = new LambertAzimuthalEqualAreaOblique(
                new GeographicCoordinate(0.907571211, 0.174532925),
                new Vector2(4321000, 3210000),
                new SpheroidEquatorialInvF(6378137, 298.2572221));

            var projectedExpected = new Point2(3962799.45, 2999718.85);
            var geographicExpected = new GeographicCoordinate(0.872664626, 0.087266463);

            var projectedActual = projection.TransformValue(geographicExpected);
            Assert.AreEqual(projectedExpected.X, projectedActual.X, 0.004);
            Assert.AreEqual(projectedExpected.Y, projectedActual.Y, 0.004);

            var inverse = projection.GetInverse();
            Assert.IsNotNull(inverse);

            var geographicActual = inverse.TransformValue(projectedExpected);
            Assert.AreEqual(geographicExpected.Latitude, geographicActual.Latitude, 0.000001);
            Assert.AreEqual(geographicExpected.Longitude, geographicActual.Longitude, 0.00000003);
        }