public void TestUnitTransforms()
        {
            ICoordinateSystem         nadUTM   = SRIDReader.GetCSbyID(2868);   //UTM Arizona Central State Plane using Feet as units
            ICoordinateSystem         wgs84GCS = SRIDReader.GetCSbyID(4326);   //GCS WGS84
            ICoordinateTransformation trans    = new CoordinateTransformationFactory().CreateFromCoordinateSystems(wgs84GCS, nadUTM);

            double[] p0       = new double[] { -111.89, 34.165 };
            double[] expected = new double[] { 708066.190579, 1151426.44638 };

            double[] p1 = trans.MathTransform.Transform(p0);
            double[] p2 = trans.MathTransform.Inverse().Transform(p1);

            Assert.IsTrue(ToleranceLessThan(p1, expected, 0.013), String.Format("Transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], p1[0], p1[1]));
            //WARNING: This accuracy is too poor!
            Assert.IsTrue(ToleranceLessThan(p0, p2, 0.0000001), String.Format("Transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", p0[0], p0[1], p2[0], p2[1]));
        }
Пример #2
0
        public void TestUnitTransforms()
        {
            var nadUTM   = SRIDReader.GetCSbyID(2868);           //UTM Arizona Central State Plane using Feet as units
            var wgs84GCS = SRIDReader.GetCSbyID(4326);           //GCS WGS84
            var trans    = new CoordinateTransformationFactory().CreateFromCoordinateSystems(wgs84GCS, nadUTM);

            var p0 = new[] { -111.89, 34.165 };
            //var expected = new[] { 708066.19058, 1151461.51413 };
            var expected = new[] { 708066.19057935325, 1151426.4460563776 };


            var p1 = trans.MathTransform.Transform(p0);
            var p2 = trans.MathTransform.Inverse().Transform(p1);

            Assert.IsTrue(ToleranceLessThan(p1, expected, 0.013), TransformationError("Unit", expected, p1));
            //WARNING: This accuracy is too poor!
            Assert.IsTrue(ToleranceLessThan(p0, p2, 0.0001), TransformationError("Unit", expected, p1, true));
        }
Пример #3
0
        public void TestPolyconicTransforms()
        {
            var wgs84GCS = SRIDReader.GetCSbyID(4326); //GCS WGS84
            var wkt      =
                //"PROJCS[\"SAD69 / Brazil Polyconic (deprecated)\",GEOGCS[\"SAD69\",DATUM[\"South_American_Datum_1969\",SPHEROID[\"GRS 1967\",6378160,298.247167427,AUTHORITY[\"EPSG\",\"7036\"]],TOWGS84[-57,1,-41,0,0,0,0],AUTHORITY[\"EPSG\",\"6291\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AUTHORITY[\"EPSG\",\"4291\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Polyconic\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",-54],PARAMETER[\"false_easting\",5000000],PARAMETER[\"false_northing\",10000000],AUTHORITY[\"EPSG\",\"29100\"],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
                //"PROJCS[\"SAD69 / Brazil Polyconic\",GEOGCS[\"SAD69\",DATUM[\"South_American_Datum_1969\",SPHEROID[\"GRS 1967 Modified\",6378160,298.25,AUTHORITY[\"EPSG\",\"7050\"]],TOWGS84[-57,1,-41,0,0,0,0],AUTHORITY[\"EPSG\",\"6618\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4618\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Polyconic\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",-54],PARAMETER[\"false_easting\",5000000],PARAMETER[\"false_northing\",10000000],AUTHORITY[\"EPSG\",\"29101\"],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
                "PROJCS[\"SAD69 / Brazil Polyconic\",GEOGCS[\"SAD69\",DATUM[\"South_American_Datum_1969\",SPHEROID[\"GRS 1967 (SAD69)\", 6378160, 298.25, AUTHORITY[\"EPSG\", \"7050\"]],AUTHORITY[\"EPSG\", \"6618\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]],UNIT[\"degree\", 0.01745329251994328, AUTHORITY[\"EPSG\", \"9122\"]], AUTHORITY[\"EPSG\", \"4618\"]],UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], PROJECTION[\"Polyconic\"],PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", -54],PARAMETER[\"false_easting\", 5000000], PARAMETER[\"false_northing\", 10000000],AUTHORITY[\"EPSG\", \"29101\"], AXIS[\"X\", EAST], AXIS[\"Y\", NORTH]]";
            var sad69 = CoordinateSystemFactory.CreateFromWkt(wkt);

            var trans    = CoordinateTransformationFactory.CreateFromCoordinateSystems(wgs84GCS, sad69);
            var p0       = new[] { -50.085, -14.32 };
            var expected = new[] { 5422386.5795, 8412674.8723 };
            //"POINT(5422386.57956145 8412722.92229278)"
            var p1 = trans.MathTransform.Transform(p0);

            trans.MathTransform.Invert();
            var p2 = trans.MathTransform.Transform(p1);

            Assert.IsTrue(ToleranceLessThan(p1, expected, 50), TransformationError("Polyconic", expected, p1));
            Assert.IsTrue(ToleranceLessThan(p0, p2, 0.0001), TransformationError("Polyconic", expected, p1, true));
        }