0

我正在尝试使用 NetTopologySuite 将我的坐标转换为不同的坐标系。但我无法让它工作。我最初的转换是从 WGS84 转到 Lambert72。

我在 stackoverflow 的某个地方找到了这个示例,但我无法让它工作:

public static double CalculateDistance(this MvxCoordinates baseLocation, double targetLat, double targetLon)
    {
        CoordinateSystemFactory csFact = new CoordinateSystemFactory();
        CoordinateTransformationFactory ctFact = new CoordinateTransformationFactory();

        ICoordinateSystem utm35ETRS = Coo.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]]");

        IProjectedCoordinateSystem utm33 = ProjectedCoordinateSystem.WGS84_UTM(33, true);

        ICoordinateTransformation trans = ctFact.CreateFromCoordinateSystems(utm35ETRS, utm33);

        Coordinate[] points = new Coordinate[]
        {
            new Coordinate(290586.087, 6714000), new Coordinate(290586.392, 6713996.224),
            new Coordinate(290590.133, 6713973.772), new Coordinate(290594.111, 6713957.416),
            new Coordinate(290596.615, 6713943.567), new Coordinate(290596.701, 6713939.485)
        };

        //Coordinate[] tpoints = trans.MathTransform.TransformList(points).ToArray();
        //for (int i = 0; i < points.Length; i++)
        //    Assert.That(tpoints[i].Equals(trans.MathTransform.Transform(points[i])));
    }

这段代码最大的问题是它使用 ProjNET4GeoAPI,这与 Xamarin 核心项目不兼容

4

1 回答 1

1

ProjNet4GeoAPI 的最新预发布版本现在支持 .NET Standard 1.0 和 .NET Standard 2.0 目标。

于 2018-04-10T11:50:56.963 回答