4

What is happening with version 2.0 of Net Topology Suite? My main considerations are:

  • It does not anymore implement Geo API (i like the idea of it)
  • Where is ICoordinateSystem interface (how can I make transform geometry from one coordinate system to another using NTS)?
Rok
  • 451
  • 3
  • 21
  • Facing the same issue with GeoApi `IGeometry` and NTS.IO.GeoJson `Geometry`. I think your first consideration is mostly correct (as this is a Major version update). So currently I'm using older versions until I get time to look into the issue further. – Joel Sep 04 '19 at 16:16

2 Answers2

3

What is happening with version 2.0 of Net Topology Suite?

You can throw a majority of the blame at me for a majority of questions that sound like this.

In general, see https://github.com/NetTopologySuite/NetTopologySuite/wiki/Upgrading-to-2.0-from-1.x for the details of what changed in NetTopologySuite 2.0, including how to migrate from old stuff to new stuff and brief summary explanations for why we pushed for changes that cause so much pain.


  • It does not anymore implement Geo API (i like the idea of it)

We had a lot of discussion on this topic: https://github.com/NetTopologySuite/GeoAPI/issues/70

Short version: it SOUNDS like a good idea to have this separate GeoAPI project as an abstraction for geometry stuff, but over the course of the 10 years that we'd had it around, it became clear that nobody was actually using it as a standalone thing independently of NTS anyway.

It was causing us a lot of friction, it was confusing new users, and ultimately NTS itself is already an abstraction for geometry stuff anyway, so I advocated for us to get rid of it at the same time that we were already making other breaking changes for v2.


Where is ICoordinateSystem interface (how can I make transform geometry from one coordinate system to another using NTS)?

This stuff was implemented by ProjNet4GeoAPI. Since we stopped maintaining the thing that we used to call GeoAPI, we started publishing this under the "ProjNet" package, which had similar changes when moving to v2.

The abstraction for coordinate systems is now the abstract class ProjNet.CoordinateSystems.CoordinateSystem.


Very, very related to both of the above is another one I pushed hard for that we eventually did implement in the v2 transition: https://github.com/NetTopologySuite/GeoAPI/issues/68

Joe Amenta
  • 4,662
  • 2
  • 29
  • 38
0

Check this issue in the NetTopologySuite Issues. You can project. https://github.com/NetTopologySuite/NetTopologySuite/issues/346

Adding to airbreather's comment/code, you will need to change your ICoordinateSystemServices to CoordinateSystemServices AND SRIDs 4326 and 3857 are not already predefined.

/*
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);
        }
JCaldwell
  • 1
  • 1