为什么NetTopologySuite v2.0没有实现GeoAPI?

Rok*_*Rok 5 nettopologysuite

Net Topology Suite 2.0 版本发生了什么?我的主要考虑是:

  • 它不再实现 Geo API(我喜欢它的想法)
  • 接口在哪里ICoordinateSystem(如何使用 NTS 将几何图形从一个坐标系转换到另一个坐标系)?

小智 0

在 NetTopologySuite 问题中检查此问题。你可以投影。 https://github.com/NetTopologySuite/NetTopologySuite/issues/346

添加到airbreather 的注释/代码中,您需要将IColinedSystemServices 更改为CoordinateSystemServices 并且SRID 4326 和3857 尚未预定义。

/*
static readonly ICoordinateSystemServices _coordinateSystemServices = new CoordinateSystemServices(
    new CoordinateSystemFactory(), new CoordinateTransformationFactory(),
    new Dictionary<int, string>
 */
static readonly CoordinateSystemServices _coordinateSystemServices = new CoordinateSystemServices(
    new CoordinateSystemFactory(), new CoordinateTransformationFactory(),
    new Dictionary<int, string>
{
    [4326] = @"
    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""]]
    ",
//(additional projections....)

""
}

        public static Geometry ProjectTo(this Geometry geometry, int srid)
        {
            var transformation = _coordinateSystemServices.CreateTransformation(geometry.SRID, srid);
            return Transform(geometry, transformation.MathTransform);
        }
Run Code Online (Sandbox Code Playgroud)