Ejemplo n.º 1
0
        public void OsgbInverseTest()
        {
            var projection = new TransverseMercator(
                new GeographicCoordinate(49 * Math.PI / 180, -2 * Math.PI / 180),
                new Vector2(400000, -100000),
                0.9996012717,
                new SpheroidEquatorialInvF(6377563.396, 299.32496)
                );
            var a = new Point2(651409.903, 313177.270);
            var b = new GeographicCoordinate(52.6576 * Math.PI / 180, 1.7179 * Math.PI / 180);

            var unProjected = projection.GetInverse().TransformValue(a);

            Assert.AreEqual(b.Latitude, unProjected.Latitude, 0.0000006);
            Assert.AreEqual(b.Longitude, unProjected.Longitude, 0.0000004);
        }
Ejemplo n.º 2
0
        public void EpsgExample1351InverseTest()
        {
            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 Point2(577274.99, 69740.50);
            var expected = new GeographicCoordinate(0.88139127, 0.00872665);

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

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.00000000004);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.000000008);
        }
Ejemplo n.º 3
0
        public void EpsgExample1351InverseTest()
        {
            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 Point2(577274.99, 69740.50);
            var expected = new GeographicCoordinate(0.88139127, 0.00872665);

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

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.00000000004);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.000000008);
        }
Ejemplo n.º 4
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"]);
            var projection = new TransverseMercator(
                new GeographicCoordinate(
                    Double.Parse(prjData["ORIGIN LATITUDE"]) * Math.PI / 180.0,
                    Double.Parse(prjData["CENTRAL MERIDIAN"]) * Math.PI / 180.0
                    ),
                new Vector2(
                    Double.Parse(prjData["FALSE EASTING"]),
                    Double.Parse(prjData["FALSE NORTHING"])
                    ),
                Double.Parse(prjData["SCALE FACTOR"]),
                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);
            }
        }
Ejemplo n.º 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"]);
            var projection = new TransverseMercator(
                new GeographicCoordinate(
                    Double.Parse(prjData["ORIGIN LATITUDE"]) * Math.PI / 180.0,
                    Double.Parse(prjData["CENTRAL MERIDIAN"]) * Math.PI / 180.0
                ),
                new Vector2(
                    Double.Parse(prjData["FALSE EASTING"]),
                    Double.Parse(prjData["FALSE NORTHING"])
                ),
                Double.Parse(prjData["SCALE FACTOR"]),
                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);
            }
        }
Ejemplo n.º 6
0
        public void OsgbInverseTest()
        {
            var projection = new TransverseMercator(
                new GeographicCoordinate(49 * Math.PI / 180, -2 * Math.PI / 180),
                new Vector2(400000, -100000),
                0.9996012717,
                new SpheroidEquatorialInvF(6377563.396, 299.32496)
            );
            var a = new Point2(651409.903, 313177.270);
            var b = new GeographicCoordinate(52.6576 * Math.PI / 180, 1.7179 * Math.PI / 180);

            var unProjected = projection.GetInverse().TransformValue(a);

            Assert.AreEqual(b.Latitude, unProjected.Latitude, 0.0000006);
            Assert.AreEqual(b.Longitude, unProjected.Longitude, 0.0000004);
        }