protected void ExecuteTests(IVerticalCoordinateSystem source, IVerticalCoordinateSystem target, bool inverse)
        {
            CoordinateTransformationFactory ctf = new CoordinateTransformationFactory();
            ICoordinateTransformation coordinateTransformation = ctf.CreateFromCoordinateSystems(source, target);

            if( inverse )
                ExecuteTests(coordinateTransformation.MathTransform.Inverse);
            else
                ExecuteTests(coordinateTransformation.MathTransform);
        }
Example #2
0
        public void TestDiscussion352813()
        {
            var csSource = GeographicCoordinateSystem.WGS84;
            var csTarget = ProjectedCoordinateSystem.WebMercator;
            //           CoordinateSystemFactory.CreateFromWkt(
            //"PROJCS[\"Popular Visualisation CRS / Mercator\"," +
            //         "GEOGCS[\"Popular Visualisation CRS\"," +
            //                  "DATUM[\"Popular Visualisation Datum\"," +
            //                          "SPHEROID[\"Popular Visualisation Sphere\", 6378137, 298.257223563, " +
            //                          "AUTHORITY[\"EPSG\", \"7030\"]]," +
            // /*"TOWGS84[0, 0, 0, 0, 0, 0, 0], */"AUTHORITY[\"EPSG\", \"6055\"]], " +
            //                  "PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]]," +
            //                  "UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]]," +
            //                  "AXIS[\"E\", EAST]," +
            //                  "AXIS[\"N\", NORTH]," +
            //                  "AUTHORITY[\"EPSG\", \"4055\"]]," +
            //         "PROJECTION[\"Mercator\"]," +
            //         "PARAMETER[\"semi_major\", 6378137]," +
            //         "PARAMETER[\"semi_minor\", 6378137]," +
            //         "PARAMETER[\"scale_factor\", 1]," +
            //         "PARAMETER[\"False_Easting\", 0]," +
            //         "PARAMETER[\"False_Northing\", 0]," +
            //         "PARAMETER[\"Central_Meridian\", 0]," +
            //         "PARAMETER[\"Latitude_of_origin\", 0]," +
            //         "UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]]," +
            //         "AXIS[\"East\", EAST]," +
            //"AXIS[\"North\", NORTH]," +
            //"AUTHORITY[\"EPSG\", \"3857\"]]");

            //"PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs"],AUTHORITY["EPSG","3857"],AXIS["X",EAST],AXIS["Y",NORTH]]"
            var ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(csSource, csTarget);

            //var ct2 = CoordinateTransformationFactory.CreateFromCoordinateSystems(csSource, csTarget2);

            Verbose = true;

            double[] pg1 = new[] { 23.57892d, 37.94712d };
            //src DotSpatial.Projections
            double[] pExpected = new[] { 2624793.3678553337, 4571958.333297424 };

            double[] pp = ct.MathTransform.Transform(pg1);
            Console.WriteLine(TransformationError("EPSG 4326 -> EPSG 3857", pExpected, pp));

            Assert.IsTrue(ToleranceLessThan(pp, pExpected, 1e-9),
                          TransformationError("EPSG 4326 -> EPSG 3857", pExpected, pp));

            double[] pg2 = ct.MathTransform.Inverse().Transform(pp);
            Assert.IsTrue(ToleranceLessThan(pg1, pg2, 1e-13),
                          TransformationError("EPSG 4326 -> EPSG 3857", pg1, pg2, true));
        }
        public void TestMichiganGeoRefToWebMercator()
        {
            var src = CoordinateSystemFactory.CreateFromWkt(wkt7151);
            var tgt = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator;

            ICoordinateTransformation transform = null;

            Assert.DoesNotThrow(() => transform = CoordinateTransformationFactory.CreateFromCoordinateSystems(src, tgt));
            Assert.IsNotNull(transform);
            double[] ptSrc = new[] { 535247.9375, 324548.09375 };
            double[] ptTgt = null;
            Assert.DoesNotThrow(() => ptTgt = transform.MathTransform.Transform(ptSrc));
            Assert.IsNotNull(ptTgt);
        }
        public void Filter(GeoAPI.Geometries.Coordinate coord)
        {
            ProjNet.CoordinateSystems.ICoordinateSystem equalArea =
                (ProjNet.CoordinateSystems.ICoordinateSystem)CoordinateSystemWktReader.Parse(ProjectionUtil.NORTH_AMERICAN_ALBERS_EQUAL_AREA_WKT);
            ProjNet.CoordinateSystems.IGeographicCoordinateSystem latlon =
                (ProjNet.CoordinateSystems.IGeographicCoordinateSystem)CoordinateSystemWktReader.Parse(ProjectionUtil.GCS_WGS84_WKT);
            ICoordinateTransformationFactory ctfac          = new CoordinateTransformationFactory();
            ICoordinateTransformation        transformation =
                ctfac.CreateFromCoordinateSystems(latlon, equalArea);

            double[] newCoords = transformation.MathTransform.Transform(new double[] { coord.X, coord.Y });
            coord.X = newCoords[0];
            coord.Y = newCoords[1];
        }
Example #5
0
        double calcpolygonarea(List <PointLatLngAlt> polygon)
        {
            // should be a closed polygon
            // coords are in lat long
            // need utm to calc area

            if (polygon.Count == 0)
            {
                CustomMessageBox.Show("Please define a polygon!");
                return(0);
            }

            // close the polygon
            if (polygon[0] != polygon[polygon.Count - 1])
            {
                polygon.Add(polygon[0]); // make a full loop
            }
            CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();

            GeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;

            int utmzone = (int)((polygon[0].Lng - -186.0) / 6.0);

            IProjectedCoordinateSystem utm = ProjectedCoordinateSystem.WGS84_UTM(utmzone, polygon[0].Lat < 0 ? false : true);

            ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84, utm);

            double prod1 = 0;
            double prod2 = 0;

            for (int a = 0; a < (polygon.Count - 1); a++)
            {
                double[] pll1 = { polygon[a].Lng, polygon[a].Lat };
                double[] pll2 = { polygon[a + 1].Lng, polygon[a + 1].Lat };

                double[] p1 = trans.MathTransform.Transform(pll1);
                double[] p2 = trans.MathTransform.Transform(pll2);

                prod1 += p1[0] * p2[1];
                prod2 += p1[1] * p2[0];
            }

            double answer = (prod1 - prod2) / 2;

            if (polygon[0] == polygon[polygon.Count - 1])
            {
                polygon.RemoveAt(polygon.Count - 1); // unmake a full loop
            }
            return(Math.Abs(answer));
        }
Example #6
0
        public void TestGridTransformation_Proj2GeogCS_NTv2()
        {
            var GK     = SRIDReader.GetCSbyID(31466); // DHDN (3-degree Gauss-Kruger zone 2)
            var ETRS89 = SRIDReader.GetCSbyID(4326);  // ETRS89_Lat-Lon

            var ctf = new CoordinateTransformationFactory();
            var ct  = ctf.CreateFromCoordinateSystems(GK, ETRS89, Grid, false);

            double[] input    = new[] { 2598417.333192, 5930677.980308 };
            double[] expected = new[] { 7.482506019176, 53.498461143331 };

            double[] actual = ct.MathTransform.Transform(input);

            CollectionAssert.AreEqual(expected, actual);
        }
Example #7
0
        public void TestGridTransformationInverse_ProjCS_NTv2()
        {
            var ETRS89 = SRIDReader.GetCSbyID(25832); // ETRS89 (UTM Zone 32N)
            var GK     = SRIDReader.GetCSbyID(31466); // DHDN (3-degree Gauss-Kruger zone 2)

            var ctf = new CoordinateTransformationFactory();
            var ct  = ctf.CreateFromCoordinateSystems(ETRS89, GK, Grid, true);

            double[] input    = new[] { 399340.601863, 5928794.177992 };
            double[] expected = new[] { 2598417.333192, 5930677.980308 };

            double[] actual = ct.MathTransform.Transform(input);

            CollectionAssert.AreEqual(expected, actual);
        }
        void SetCoordinateTransformation()
        {
            // Source Coordinate System use by OSM
            var sourceCS = GeographicCoordinateSystem.WGS84;

            // Target Coordinate System used by LiDAR data (Berlin)
            // https://epsg.io/25833
            var ETRS89_EPSG25833 = "PROJCS[\"ETRS89 / UTM zone 33N\", GEOGCS[\"ETRS89\", DATUM[\"European_Terrestrial_Reference_System_1989\", SPHEROID[\"GRS 1980\", 6378137, 298.257222101, AUTHORITY[\"EPSG\", \"7019\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\", \"6258\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9122\"]], AUTHORITY[\"EPSG\", \"4258\"]], PROJECTION[\"Transverse_Mercator\"], PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", 15], PARAMETER[\"scale_factor\", 0.9996], PARAMETER[\"false_easting\", 500000], PARAMETER[\"false_northing\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"Easting\", EAST], AXIS[\"Northing\", NORTH], AUTHORITY[\"EPSG\", \"25833\"]]";
            var cf       = new CoordinateSystemFactory();
            var targetCS = cf.CreateFromWkt(ETRS89_EPSG25833);

            CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();

            CoordinateTransformation = ctfac.CreateFromCoordinateSystems(sourceCS, targetCS);
        }
Example #9
0
        public void TestGeocentric()
        {
            var gcs = CoordinateSystemFactory.CreateGeographicCoordinateSystem("ETRF89 Geographic", AngularUnit.Degrees, HorizontalDatum.ETRF89, PrimeMeridian.Greenwich,
                                                                               new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));
            var gcenCs      = CoordinateSystemFactory.CreateGeocentricCoordinateSystem("ETRF89 Geocentric", HorizontalDatum.ETRF89, LinearUnit.Metre, PrimeMeridian.Greenwich);
            var ct          = CoordinateTransformationFactory.CreateFromCoordinateSystems(gcs, gcenCs);
            var pExpected   = new[] { 2 + 7.0 / 60 + 46.38 / 3600, 53 + 48.0 / 60 + 33.82 / 3600 };         // Point.FromDMS(2, 7, 46.38, 53, 48, 33.82);
            var pExpected3D = new[] { pExpected[0], pExpected[1], 73.0 };
            var p0          = new[] { 3771793.97, 140253.34, 5124304.35 };
            var p1          = ct.MathTransform.Transform(pExpected3D);
            var p2          = ct.MathTransform.Inverse().Transform(p1);

            Assert.IsTrue(ToleranceLessThan(p1, p0, 0.01));
            Assert.IsTrue(ToleranceLessThan(p2, pExpected, 0.00001));
        }
Example #10
0
        private static void ToUTM(double longitude, double latitude, out double x, out double y, out string zone)
        {
            ICoordinateSystem          gcs_WGS84  = GeographicCoordinateSystem.WGS84;
            IProjectedCoordinateSystem pcs_UTM31N = ProjectedCoordinateSystem.WGS84_UTM(23, false);

            CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
            ICoordinateTransformation       trans = ctfac.CreateFromCoordinateSystems(gcs_WGS84, pcs_UTM31N);

            double[] fromPoint = new double[] { longitude, latitude };
            double[] toPoint   = trans.MathTransform.Transform(fromPoint);

            x    = toPoint[0];
            y    = toPoint[1];
            zone = "23S";
        }
 private static ICoordinateTransformation GetCoordinateTransformation(Tuple <int, int> coordinateSystemCombination)
 {
     lock (Transformations)
     {
         if (!Transformations.ContainsKey(coordinateSystemCombination))
         {
             var coordinateTransformation = CoordinateTransformationFactory.CreateFromCoordinateSystems(
                 GeographyService.GetCoordinateSystemById(coordinateSystemCombination.Item1),
                 GeographyService.GetCoordinateSystemById(coordinateSystemCombination.Item2));
             Transformations.Add(coordinateSystemCombination, coordinateTransformation);
         }
         var transformation = Transformations[coordinateSystemCombination];
         return(transformation);
     }
 }
Example #12
0
        //获取shp投影方式
        public ICoordinateTransformation getmapTransform(config.ProjPara proj)
        {
            CoordinateTransformationFactory ctFac     = new CoordinateTransformationFactory();
            CoordinateSystemFactory         cFac      = new CoordinateSystemFactory();
            ICoordinateTransformation       transform = null;

            //等经纬,shp数据原始投影
            var epsg4326 = cFac.CreateFromWkt("GEOGCS[\"GCS_WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_84\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]");
            //目标坐标系
            var epsg3857 = cFac.CreateFromWkt(getSrcCoordinate(proj));

            transform = ctFac.CreateFromCoordinateSystems(epsg4326, epsg3857);

            return(transform);
        }
Example #13
0
        public void TestGridTransformationInverse_GeogCS_NTv2()
        {
            var ETRS89 = SRIDReader.GetCSbyID(4326); // ETRS89_Lat-Lon
            var DHDN   = SRIDReader.GetCSbyID(4314); // DE_DHDN_Lat-Lon

            var ctf = new CoordinateTransformationFactory();
            var ct  = ctf.CreateFromCoordinateSystems(ETRS89, DHDN, Grid, true);

            double[] input    = new[] { 7.482506019176, 53.498461143331 };
            double[] expected = new[] { 7.483333333333, 53.500000000000 };

            double[] actual = ct.MathTransform.Transform(input);

            CollectionAssert.AreEqual(expected, actual);
        }
        private static void Initialize()
        {
            if (_fromCS == null)
            {
                if (_fromCS == null)
                {
                    string utmWkt = @"
PROJCS[""ETRS89 / UTM zone 32N"",
    GEOGCS[""ETRS89"",
        DATUM[""European_Terrestrial_Reference_System_1989"",
            SPHEROID[""GRS 1980"",6378137,298.257222101,
                AUTHORITY[""EPSG"",""7019""]],
            AUTHORITY[""EPSG"",""6258""]],
        PRIMEM[""Greenwich"",0,
            AUTHORITY[""EPSG"",""8901""]],
        UNIT[""degree"",0.01745329251994328,
            AUTHORITY[""EPSG"",""9122""]],
        AUTHORITY[""EPSG"",""4258""]],
    UNIT[""metre"",1,
        AUTHORITY[""EPSG"",""9001""]],
    PROJECTION[""Transverse_Mercator""],
    PARAMETER[""latitude_of_origin"",0],
    PARAMETER[""central_meridian"",9],
    PARAMETER[""scale_factor"",0.9996],
    PARAMETER[""false_easting"",500000],
    PARAMETER[""false_northing"",0],
    AUTHORITY[""EPSG"",""25832""],
    AXIS[""Easting"",EAST],
    AXIS[""Northing"",NORTH]]";


                    // WGS 84
                    string wgsWkt = @"
                GEOGCS[""GCS_WGS_1984"",
                    DATUM[""D_WGS_1984"",SPHEROID[""WGS_1984"",6378137,298.257223563]],
                    PRIMEM[""Greenwich"",0],
                    UNIT[""Degree"",0.0174532925199433]
                ]";

                    // Initialize objects needed for coordinate transformation
                    _fromCS = ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wgsWkt) as IGeographicCoordinateSystem;
                    _toCS   = ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(utmWkt) as IProjectedCoordinateSystem;
                    _ctfac  = new CoordinateTransformationFactory();
                    _trans  = _ctfac.CreateFromCoordinateSystems(_fromCS, _toCS);
                }
            }
        }
Example #15
0
        public void TestGitHubIssue53()
        {
            // arrange
            var csWgs84     = GeographicCoordinateSystem.WGS84;
            var csUtm35N    = ProjectedCoordinateSystem.WGS84_UTM(35, true);
            var csTrans     = CoordinateTransformationFactory.CreateFromCoordinateSystems(csWgs84, csUtm35N);
            var csTransBack = CoordinateTransformationFactory.CreateFromCoordinateSystems(csUtm35N, csWgs84);

            // act
            double[] point = { 42.5, 24.5 };
            double[] r     = csTrans.MathTransform.Transform(point);
            double[] rBack = csTransBack.MathTransform.Transform(r);

            // assert
            Assert.AreEqual(point[0], rBack[0], 1e-5);
            Assert.AreEqual(point[1], rBack[1], 1e-5);
        }
        public static double MetersDistance(this Point pointA, Point pointB)
        {
            var transformationFactory  = new CoordinateTransformationFactory();
            var originCoordinateSystem = GeographicCoordinateSystem.WGS84;
            var targetCoordinateSystem = GeocentricCoordinateSystem.WGS84;

            var transform = transformationFactory.CreateFromCoordinateSystems(
                originCoordinateSystem, targetCoordinateSystem);

            var pointACoordinate = new GeoAPI.Geometries.Coordinate(pointA.X, pointA.Y);
            var pointBCoordinate = new GeoAPI.Geometries.Coordinate(pointB.X, pointB.Y);

            var newPointA = transform.MathTransform.Transform(pointACoordinate);
            var newPointB = transform.MathTransform.Transform(pointBCoordinate);

            return(newPointB.Distance(newPointA) * 1.11);
        }
Example #17
0
    public static void Main()
    {
        //////Add this to class constructor
        NtsGeometryServices.Instance = new NtsGeometryServices(
            NetTopologySuite.Geometries.Implementation.CoordinateArraySequenceFactory.Instance,
            new NetTopologySuite.Geometries.PrecisionModel(1000d), 4326,
            // Note the following arguments are only valid for NTS v2.2
            // Geometry overlay operation function set to use (Legacy or NG)
            NetTopologySuite.Geometries.GeometryOverlay.NG,
            // Coordinate equality comparer to use (CoordinateEqualityComparer or PerOrdinateEqualityComparer)
            new NetTopologySuite.Geometries.CoordinateEqualityComparer());

        //Transform Projection
        //*****Add ProjNet to make transform
        //https://docs.microsoft.com/en-us/ef/core/modeling/spatial

        //2nd Way

        //Add WKT projection coordinate system
        const string            outputWKT = @"";
        CoordinateSystemFactory csFact    = new CoordinateSystemFactory();
        var csWgs84Text      = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84.WKT;
        var csWgs84          = csFact.CreateFromWkt(csWgs84Text);
        var outputProjection = csFact.CreateFromWkt(outputWKT);
        CoordinateTransformationFactory ctFact = new CoordinateTransformationFactory();
        ICoordinateTransformation       trans  = ctFact.CreateFromCoordinateSystems(csWgs84, outputProjection);
        var mt = trans.MathTransform;


        // Use the following website to look up the arguement below that should match outputProjection ESRG
        //http://epsg.io
        var gf = NtsGeometryServices.Instance.CreateGeometryFactory(XXXX);
        //////End of Class Constructor

        //IMPORTANT-ALL GEOMETRY POINTS MUST BE WRAPPED WITH mt.Transform()
        // Create a point at Aurich (lat=53.4837, long=7.5404)
        var pntAUR = gf.CreatePoint(mt.Transform(new NetTopologySuite.Geometries.Coordinate(7.5404, 53.4837)));
        // Create a point at Emden (lat=53.3646, long=7.1559)
        var pntLER = gf.CreatePoint(mt.Transform(new NetTopologySuite.Geometries.Coordinate(7.1559, 53.3646)));
        // Create a point at Leer (lat=53.2476, long=7.4550)
        var pntEMD = gf.CreatePoint(mt.Transform(new NetTopologySuite.Geometries.Coordinate(7.4550, 53.2476)));

        var distancepntAURpntLER = pntAUR.Distance(pntLER);

        Console.WriteLine($"{distancepntAURpntLER} miles");
    }
Example #18
0
        public string getCoordinates(int X, int Y)
        {
            GeoAPI.Geometries.Coordinate p = _sharpMap.ImageToWorld(new PointF(X, Y));
            PointF pUTM = new PointF();

            IProjectedCoordinateSystem      utmProj   = Helpers.CoordinateSystem.CreateUtmProjection(34);
            IGeographicCoordinateSystem     geoCS     = utmProj.GeographicCoordinateSystem;
            CoordinateTransformationFactory ctFac     = new CoordinateTransformationFactory();
            ICoordinateTransformation       transform = ctFac.CreateFromCoordinateSystems(geoCS, utmProj);

            double[] c = new double[2];
            c[0]   = p.X; c[1] = p.Y;
            c      = transform.MathTransform.Transform(c);
            pUTM.X = (float)c[0]; pUTM.Y = (float)c[1];

            return(pUTM.X + " : " + pUTM.Y);
        }
        public static Coordinate ConvertDegreesToUTM(ICoordinate coordinate)
        {
            var ctfac = new CoordinateTransformationFactory();

            ProjNet.CoordinateSystems.ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
            int zone = (int)System.Math.Ceiling((coordinate.X + 180) / 6);

            ProjNet.CoordinateSystems.ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(zone, coordinate.Y > 0);
            var trans = ctfac.CreateFromCoordinateSystems(wgs84geo, utm);

            double[] pUtm = trans.MathTransform.Transform(new[] { coordinate.X, coordinate.Y });

            return(new Coordinate
            {
                X = pUtm[0],
                Y = pUtm[1],
            });
        }
        public SpatialReference(KinectReader kinectReader, PositionReader positionReader)
        {
            this.kinectReader   = kinectReader;
            this.positionReader = positionReader;

            string wkt = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]";

            this.wgs84 = (ICoordinateSystem)ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(wkt);

            //hardcoded UTM 55S - should parameterize
            string toWKT = "PROJCS[\"WGS 72BE / UTM zone 55S\",GEOGCS[\"WGS 72BE\",DATUM[\"WGS_1972_Transit_Broadcast_Ephemeris\",SPHEROID[\"WGS 72\",6378135,298.26,AUTHORITY[\"EPSG\",\"7043\"]],TOWGS84[0,0,1.9,0,0,0.814,-0.38],AUTHORITY[\"EPSG\",\"6324\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4324\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",147],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",10000000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"32555\"]]";

            this.toCs = (ICoordinateSystem)ProjNet.Converters.WellKnownText.CoordinateSystemWktReader.Parse(toWKT);

            CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();

            this.toGridtrans = ctfac.CreateFromCoordinateSystems(wgs84, toCs);
        }
Example #21
0
        public PointLatLngAlt ToLLA()
        {
            IProjectedCoordinateSystem utm = ProjectedCoordinateSystem.WGS84_UTM(Math.Abs(zone), zone < 0 ? false : true);

            ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84, utm);

            // get leader utm coords
            double[] pll = trans.MathTransform.Inverse().Transform(this);

            PointLatLngAlt ans = new PointLatLngAlt(pll[1], pll[0]);

            if (this.Tag != null)
            {
                ans.Tag = this.Tag.ToString();
            }

            return(ans);
        }
Example #22
0
        public void TestLaea()
        {
            const string Epsg3035 =
                @"PROJCS[""ETRS89 / ETRS-LAEA"",GEOGCS[""ETRS89"",DATUM[""European_Terrestrial_Reference_System_1989"",SPHEROID[""GRS 1980"",6378137,298.257222101,AUTHORITY[""EPSG"",""7019""]],AUTHORITY[""EPSG"",""6258""]],PRIMEM[""Greenwich"",0,AUTHORITY[""EPSG"",""8901""]],UNIT[""degree"",0.01745329251994328,AUTHORITY[""EPSG"",""9122""]],AUTHORITY[""EPSG"",""4258""]],UNIT[""metre"",1,AUTHORITY[""EPSG"",""9001""]],PROJECTION[""Lambert_Azimuthal_Equal_Area""],PARAMETER[""latitude_of_center"",52],PARAMETER[""longitude_of_center"",10],PARAMETER[""false_easting"",4321000],PARAMETER[""false_northing"",3210000],AUTHORITY[""EPSG"",""3035""],AXIS[""X"",EAST],AXIS[""Y"",NORTH]]";

            var csSrc = GeographicCoordinateSystem.WGS84;
            var csTgt = CoordinateSystemFactory.CreateFromWkt(Epsg3035);

            var ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(csSrc, csTgt);

            (double resX, double resY) = ((MathTransform)ct.MathTransform).Transform(16.4, 48.2);
            Assert.That(resX, Is.EqualTo(4796297.431434812).Within(1e-2));
            Assert.That(resY, Is.EqualTo(2807999.1539475969).Within(1e-2));

            (double origX, double origY) = ((MathTransform)ct.MathTransform.Inverse()).Transform(resX, resY);
            Assert.That(origX, Is.EqualTo(16.4).Within(1e-2));
            Assert.That(origY, Is.EqualTo(48.2).Within(1e-2));
        }
        protected virtual IGeometry ToTarget(IGeometry geometry)
        {
            if (geometry.SRID == EarthSrid || (geometry.SRID <= 0 && CoordinateTransformation == null))
            {
                return(geometry);
            }

            if (CoordinateTransformation == null || geometry.SRID != CoordinateTransformation.SourceCS.AuthorityCode)
            {
                var sourceWkt = SpatialReference.SridToWkt(geometry.SRID);
                var sourceCs  = CoordinateSystemFactory.CreateFromWkt(sourceWkt);

                CoordinateTransformation = CoordinateTransformationFactory.CreateFromCoordinateSystems(
                    sourceCs,
                    _earthCs);
            }

            return(GeometryTransform.TransformGeometry(geometry, CoordinateTransformation.MathTransform, _earthGeometryFactory));
        }
Example #24
0
        public static Point GetCellFeetForProjection(double widthFeet, double heightFeet)
        {
            const double FEET_PER_METER  = 3.2808399;
            const string webMercator1984 = "PROJCS[\"WGS_1984_Web_Mercator\", GEOGCS[\"GCS_WGS_1984_Major_Auxiliary_Sphere\", DATUM[\"WGS_1984_Major_Auxiliary_Sphere\", SPHEROID[\"WGS_1984_Major_Auxiliary_Sphere\",6378137.0,0.0]], PRIMEM[\"Greenwich\",0.0], UNIT[\"Degree\",0.0174532925199433]], PROJECTION[\"Mercator_1SP\"], PARAMETER[\"False_Easting\",0.0], PARAMETER[\"False_Northing\",0.0], PARAMETER[\"Central_Meridian\",0.0], PARAMETER[\"latitude_of_origin\",0.0], UNIT[\"Meter\",1.0]]";

            CoordinateSystemFactory csf = new CoordinateSystemFactory();
            var webMercatorCS           = csf.CreateFromWkt(webMercator1984);

            var f    = new CoordinateTransformationFactory();
            var proj = f.CreateFromCoordinateSystems(webMercatorCS, GeographicCoordinateSystem.WGS84);

            var widthMeters  = (widthFeet / FEET_PER_METER);
            var heightMeters = (heightFeet / FEET_PER_METER);

            var xStep = proj.MathTransform.Transform(new double[] { widthMeters, 0 });
            var yStep = proj.MathTransform.Transform(new double[] { 0, heightMeters });

            return(new Point(xStep[0], yStep[1]));
        }
Example #25
0
        public void OnMapMouseMoved(Coordinate point)
        {
            if (_bShowUTM)
            {
                IProjectedCoordinateSystem      utmProj   = CreateUtmProjection(34);
                IGeographicCoordinateSystem     geoCS     = utmProj.GeographicCoordinateSystem;
                CoordinateTransformationFactory ctFac     = new CoordinateTransformationFactory();
                ICoordinateTransformation       transform = ctFac.CreateFromCoordinateSystems(geoCS, utmProj);
                double[] coordsGeo = new double[2];
                double[] coordsUTM;
                coordsGeo[0] = point.X;
                coordsGeo[1] = point.Y;
                coordsUTM    = transform.MathTransform.Transform(coordsGeo);
                point.X      = coordsUTM[0];
                point.Y      = coordsUTM[1];
            }

            _view.TextCoord = "X: " + point.X + "  Y: " + point.Y;
        }
Example #26
0
        public void TestTransformListOnConcatenatedDoTransformDoubleArr()
        {
            ICoordinateSystem utm35ETRS =
                CoordinateSystemFactory.CreateFromWkt(
                    "PROJCS[\"ETRS89 / ETRS-TM35\",GEOGCS[\"ETRS89\",DATUM[\"D_ETRS_1989\",SPHEROID[\"GRS_1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",27],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1]]");

            ICoordinateSystem         utm33 = ProjectedCoordinateSystem.WGS84_UTM(33, true);
            ICoordinateTransformation trans = CoordinateTransformationFactory.CreateFromCoordinateSystems(utm35ETRS, utm33);

            var coords = new List <double[]> {
                new double[] { 290586.087, 6714000 },
                new double[] { 290586.392, 6713996.224 },
                new double[] { 290590.133, 6713973.772 }
            };

            var transformedCoords = trans.MathTransform.TransformList(coords);

            Assert.AreNotEqual(290586.087, transformedCoords[0][0]);
            Assert.AreNotEqual(6714000, transformedCoords[0][1]);
        }
Example #27
0
        public void TestNAD()
        {
            var NAD27 = SRIDReader.GetCSbyID(4267);
            var NAD83 = SRIDReader.GetCSbyID(4269);

            // https://github.com/OSGeo/proj-datumgrid/tree/master/north-america
            var grid = GridFile.Open(@"ntv2_0.gsb");

            var ct = TransformationFactory.CreateFromCoordinateSystems(NAD27, NAD83, grid, false);

            // http://www.apsalin.com/nad-conversion.aspx
            // https://www.ngs.noaa.gov/NCAT/

            double[] input    = new[] { -79.378243, 43.664087 };
            double[] expected = new[] { -79.3780316, 43.6641356 };

            var actual = ct.MathTransform.Transform(input);

            CollectionAssert.AreEqual(expected, actual);
        }
Example #28
0
        private static NetTopologySuite.Geometries.Point Wgs84ToWgs84UpsNorth(Point location)
        {
            ICoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;

            if (location.SRID != Convert.ToInt32(wgs84.AuthorityCode))
            {
                throw new Exception("Unsupported coordinate system: " + location.SRID);
            }

            var coordinateSystemFactory         = new CoordinateSystemFactory();
            var coordinateTransformationFactory = new CoordinateTransformationFactory();

            ICoordinateSystem wgs84UpNorth = coordinateSystemFactory.CreateFromWkt("PROJCS[\"WGS 84 / UPS North\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Stereographic_North_Pole\"],PARAMETER[\"standard_parallel_1\",90],PARAMETER[\"central_meridian\",0],PARAMETER[\"scale_factor\",0.994],PARAMETER[\"false_easting\",2000000],PARAMETER[\"false_northing\",2000000],UNIT[\"Meter\",1]]");

            ICoordinateTransformation trans = coordinateTransformationFactory.CreateFromCoordinateSystems(wgs84, wgs84UpNorth);

            var result = trans.MathTransform.Transform(location.Coordinate);

            return(new Point(result));
        }
Example #29
0
        public void TestDiscussion361248_2()
        {
            var csSource = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(18, true);

            var csTarget = CoordinateSystemFactory.CreateFromWkt(
                @"GEOGCS[""WGS 84"",
    DATUM[""WGS_1984"",
        SPHEROID[""WGS 84"",6378137,298.257223563,
            AUTHORITY[""EPSG"",""7030""]],
        AUTHORITY[""EPSG"",""6326""]],
    PRIMEM[""Greenwich"",0,
        AUTHORITY[""EPSG"",""8901""]],
    UNIT[""degree"",0.01745329251994328,
        AUTHORITY[""EPSG"",""9122""]],
    AUTHORITY[""EPSG"",""4326""]]");

            var ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(csSource, csTarget);

            Test("WGS84_UTM(18,N) -> WGS84", csSource, csTarget, new[] { 307821.867, 4219306.387 }, new[] { -77.191769, 38.101147 }, 1e-6);
        }
Example #30
0
        public void TestDiscussion351733()
        {
            var csSource = CoordinateSystemFactory.CreateFromWkt(
                "PROJCS[\"Pulkovo 1942 / Gauss-Kruger zone 14\",GEOGCS[\"Pulkovo 1942\",DATUM[\"Pulkovo_1942\",SPHEROID[\"Krassowsky 1940\",6378245,298.3,AUTHORITY[\"EPSG\",\"7024\"]],TOWGS84[23.92,-141.27,-80.9,-0,0.35,0.82,-0.12],AUTHORITY[\"EPSG\",\"6284\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4284\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",81],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",14500000],PARAMETER[\"false_northing\",0],AUTHORITY[\"EPSG\",\"28414\"],AXIS[\"X\",NORTH],AXIS[\"Y\",EAST]]\"");
            var csTarget = CoordinateSystemFactory.CreateFromWkt(
                "GEOGCS[\"Pulkovo 1942\",DATUM[\"Pulkovo_1942\",SPHEROID[\"Krassowsky 1940\",6378245,298.3,AUTHORITY[\"EPSG\",\"7024\"]],TOWGS84[23.92,-141.27,-80.9,-0,0.35,0.82,-0.12],AUTHORITY[\"EPSG\",\"6284\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4284\"]]\"");

            var ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(csSource, csTarget);

            var pp        = new[] { 14181052.913, 6435927.692 };
            var pg        = ct.MathTransform.Transform(pp);
            var pExpected = new[] { 75.613911283608331, 57.926509119323505 };
            var pp2       = ct.MathTransform.Inverse().Transform(pg);

            Verbose = true;
            Assert.IsTrue(ToleranceLessThan(pg, pExpected, 1e-6),
                          TransformationError("EPSG 28414 -> EPSG 4284", pExpected, pg));
            Assert.IsTrue(ToleranceLessThan(pp, pp2, 1e-3),
                          TransformationError("EPSG 28414 -> Pulkovo 1942", pp, pp2, true));
        }
Example #31
0
        public void TestIssue23773()
        {
            var csUtm18N    = CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(18, true);
            var csUtm18NWkt = CoordinateSystemFactory.CreateFromWkt(
                "PROJCS[\"WGS 84 / UTM zone 18N\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",-75],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],AUTHORITY[\"EPSG\",\"32618\"],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]");
            var csWgs84 = CoordinateSystems.GeographicCoordinateSystem.WGS84;

            var ct  = CoordinateTransformationFactory.CreateFromCoordinateSystems(csUtm18N, csWgs84);
            var ct2 = CoordinateTransformationFactory.CreateFromCoordinateSystems(csUtm18NWkt, csWgs84);

            var putm      = new[] { 307821.867d, 4219306.387d };
            var pgeo      = ct.MathTransform.Transform(putm);
            var pgeoWkt   = ct2.MathTransform.Transform(putm);
            var pExpected = new[] { -77.191769, 38.101147d };

            Assert.IsTrue(ToleranceLessThan(pgeoWkt, pExpected, 0.00001d),
                          TransformationError("UTM18N -> WGS84", pExpected, pgeo));
            Assert.IsTrue(ToleranceLessThan(pgeo, pExpected, 0.00001d),
                          TransformationError("UTM18N -> WGS84", pExpected, pgeo));
        }
        protected void ExecuteTests(ICoordinateSystem source, ICoordinateSystem target, bool inverse, DelegateCoordinateOperation delegado)
        {
            CoordinateTransformationFactory ctf = new CoordinateTransformationFactory();
            ICoordinateTransformation coordinateTransformation = ctf.CreateFromCoordinateSystems(source, target, delegado);
            IMathTransform d = coordinateTransformation.MathTransform;
            IMathTransform i = d.Inverse;

            if( inverse )
                ExecuteTests(i, d);
            else
                ExecuteTests(d, i);
        }
        public void TestDatumTransform()
        {
            ICoordinateSystemFactory cFac = new ICoordinateSystemFactory();
            
            //Define datums
            IHorizontalDatum wgs72 = HorizontalDatum.WGS72;
            IHorizontalDatum ed50 = HorizontalDatum.ED50;

            //Define geographic coordinate systems
            IGeographicCoordinateSystem gcsWGS72 =
                cFac.CreateGeographicCoordinateSystem("WGS72 Geographic", AngularUnit.Degrees, wgs72,
                                                      PrimeMeridian.Greenwich,
                                                      new AxisInfo("East", AxisOrientation.East),
                                                      new AxisInfo("North", AxisOrientation.North));

            IGeographicCoordinateSystem gcsWGS84 =
                cFac.CreateGeographicCoordinateSystem("WGS84 Geographic", AngularUnit.Degrees, HorizontalDatum.WGS84,
                                                      PrimeMeridian.Greenwich,
                                                      new AxisInfo("East", AxisOrientation.East),
                                                      new AxisInfo("North", AxisOrientation.North));

            IGeographicCoordinateSystem gcsED50 =
                cFac.CreateGeographicCoordinateSystem("ED50 Geographic", AngularUnit.Degrees, ed50,
                                                      PrimeMeridian.Greenwich,
                                                      new AxisInfo("East", AxisOrientation.East),
                                                      new AxisInfo("North", AxisOrientation.North));

            //Define geocentric coordinate systems
            IGeocentricCoordinateSystem gcenCsWGS72 =
                cFac.CreateGeocentricCoordinateSystem("WGS72 Geocentric", wgs72, LinearUnit.Metre,
                                                      PrimeMeridian.Greenwich);
            IGeocentricCoordinateSystem gcenCsWGS84 =
                cFac.CreateGeocentricCoordinateSystem("WGS84 Geocentric", HorizontalDatum.WGS84, LinearUnit.Metre,
                                                      PrimeMeridian.Greenwich);
            IGeocentricCoordinateSystem gcenCsED50 =
                cFac.CreateGeocentricCoordinateSystem("ED50 Geocentric", ed50, LinearUnit.Metre, PrimeMeridian.Greenwich);

            //Define projections
            //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5);
            Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>();
            parameters.Add(new ProjectionParameter("latitude_of_origin", 0));
            parameters.Add(new ProjectionParameter("central_meridian", 9));
            parameters.Add(new ProjectionParameter("scale_factor", 0.9996));
            parameters.Add(new ProjectionParameter("false_easting", 500000));
            parameters.Add(new ProjectionParameter("false_northing", 0));
            IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters);
            IProjectedCoordinateSystem utmED50 =
                cFac.CreateProjectedCoordinateSystem("ED50 UTM Zone 32N", gcsED50, projection, LinearUnit.Metre,
                                                     new AxisInfo("East", AxisOrientation.East),
                                                     new AxisInfo("North", AxisOrientation.North));
            IProjectedCoordinateSystem utmWGS84 =
                cFac.CreateProjectedCoordinateSystem("WGS84 UTM Zone 32N", gcsWGS84, projection, LinearUnit.Metre,
                                                     new AxisInfo("East", AxisOrientation.East),
                                                     new AxisInfo("North", AxisOrientation.North));

            //Set TOWGS84 parameters
            wgs72.Wgs84Parameters = new Wgs84ConversionInfo(0, 0, 4.5, 0, 0, 0.554, 0.219);
            ed50.Wgs84Parameters = new Wgs84ConversionInfo(-81.0703, -89.3603, -115.7526,
                                                           -0.48488, -0.02436, -0.41321,
                                                           -0.540645); //Parameters for Denmark

            //Set up coordinate transformations
            ICoordinateTransformationFactory ctFac = new CoordinateTransformationFactory();
            ICoordinateTransformation ctForw = ctFac.CreateFromCoordinateSystems(gcsWGS72, gcenCsWGS72);
                //Geographic->Geocentric (WGS72)
            ICoordinateTransformation ctWGS84_Gcen2Geo = ctFac.CreateFromCoordinateSystems(gcenCsWGS84, gcsWGS84);
                //Geocentric->Geographic (WGS84)
            ICoordinateTransformation ctWGS84_Geo2UTM = ctFac.CreateFromCoordinateSystems(gcsWGS84, utmWGS84);
                //UTM ->Geographic (WGS84)
            ICoordinateTransformation ctED50_UTM2Geo = ctFac.CreateFromCoordinateSystems(utmED50, gcsED50);
                //UTM ->Geographic (ED50)
            ICoordinateTransformation ctED50_Geo2Gcen = ctFac.CreateFromCoordinateSystems(gcsED50, gcenCsED50);
                //Geographic->Geocentric (ED50)

            //Test datum-shift from WGS72 to WGS84
            //Point3D pGeoCenWGS72 = ctForw.MathTransform.Transform(pLongLatWGS72) as Point3D;
            IPoint3D pGeoCenWGS72 = new IPoint3D(3657660.66, 255768.55, 5201382.11);
            ICoordinateTransformation geocen_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(gcenCsWGS72, gcenCsWGS84);
            IPoint3D pGeoCenWGS84 = geocen_ed50_2_Wgs84.MathTransform.Transform(pGeoCenWGS72) as IPoint3D;
            //Point3D pGeoCenWGS84 = wgs72.Wgs84Parameters.Apply(pGeoCenWGS72);

            Assert.IsTrue(toleranceLessThan(new IPoint3D(3657660.78, 255778.43, 5201387.75), pGeoCenWGS84, 0.01));

            ICoordinateTransformation utm_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(utmED50, utmWGS84);
            IPoint pUTMED50 = new IPoint(600000, 6100000);
            IPoint pUTMWGS84 = utm_ed50_2_Wgs84.MathTransform.Transform(pUTMED50);
            Assert.IsTrue(toleranceLessThan(new IPoint(599928.6, 6099790.2), pUTMWGS84, 0.1));
            //Perform reverse
            ICoordinateTransformation utm_Wgs84_2_Ed50 = ctFac.CreateFromCoordinateSystems(utmWGS84, utmED50);
            pUTMED50 = utm_Wgs84_2_Ed50.MathTransform.Transform(pUTMWGS84);
            Assert.IsTrue(toleranceLessThan(new IPoint(600000, 6100000), pUTMED50, 0.1));
            //Assert.IsTrue(Math.Abs((pUTMWGS84 as Point3D).Z - 36.35) < 0.5);
            //Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82);
            //ED50_to_WGS84_Denmark: datum.Wgs84Parameters = new Wgs84ConversionInfo(-89.5, -93.8, 127.6, 0, 0, 4.5, 1.2);
        }
 public void TestGeocentric()
 {
     CoordinateSystemFactory cFac = new CoordinateSystemFactory();
     IGeographicCoordinateSystem gcs =
         cFac.CreateGeographicCoordinateSystem("ETRF89 Geographic", AngularUnit.Degrees, HorizontalDatum.ETRF89,
                                               PrimeMeridian.Greenwich,
                                               new AxisInfo("East", AxisOrientation.East),
                                               new AxisInfo("North", AxisOrientation.North));
     IGeocentricCoordinateSystem gcenCs =
         cFac.CreateGeocentricCoordinateSystem("ETRF89 Geocentric", HorizontalDatum.ETRF89, LinearUnit.Metre,
                                               PrimeMeridian.Greenwich);
     CoordinateTransformationFactory gtFac = new CoordinateTransformationFactory();
     ICoordinateTransformation ct = gtFac.CreateFromCoordinateSystems(gcs, gcenCs);
     Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82);
     Point3D pExpected3D = new Point3D(pExpected.X, pExpected.Y, 73.0);
     Point3D p0 = new Point3D(3771793.97, 140253.34, 5124304.35);
     Point3D p1 = ct.MathTransform.Transform(pExpected3D) as Point3D;
     Point3D p2 = ct.MathTransform.Inverse().Transform(p1) as Point3D;
     Assert.IsTrue(toleranceLessThan(p1, p0, 0.01));
     Assert.IsTrue(toleranceLessThan(p2, pExpected, 0.00001));
 }
        public void TestCassiniSoldnerFactoryEPSG()
        {
            IProjectedCoordinateSystem pcs = CoordinateSystemAuthorityFactory.CreateProjectedCoordinateSystem(30200);
            IGeographicCoordinateSystem gcs = pcs.GeographicCoordinateSystem;

            CoordinateTransformationFactory ctf = new CoordinateTransformationFactory();
            ICoordinateTransformation coordinateTransformation = ctf.CreateFromCoordinateSystems(gcs, pcs);
            IMathTransform d = coordinateTransformation.MathTransform;
            IMathTransform i = d.Inverse;

            TestDirectTransform(d, Sexa2DecimalDegrees(10, 0, 00.000, CardinalPoint.N), Sexa2DecimalDegrees(62, 00, 00.000, CardinalPoint.W), 66644.94, 82536.22, 1E-2);
            TestInverseTransform(i, Sexa2DecimalDegrees(10, 0, 00.000, CardinalPoint.N), Sexa2DecimalDegrees(62, 00, 00.000, CardinalPoint.W), 66644.94, 82536.22, 1E-2);
        }