NetTopologySuite / ProjNet4GeoAPI

.NET Spatial Reference and Projection Engine
GNU Lesser General Public License v2.1
273 stars 83 forks source link

NetTopologySuite.Core compatibility ? #63

Closed Rumpelstinsk closed 4 years ago

Rumpelstinsk commented 4 years ago

I know I can use your proyect in an EF Core project, as you comment here: https://github.com/NetTopologySuite/GeoAPI/issues/71#issuecomment-555014067

However NetTopologySuite, has a special nugget for core: NetTopologySuite.Core. Using this nugget throws some exception on running. For example, this piece of code:

public static void from3857to4326(Geometry item, out double lat, out double lng)
        {
            // Coordinate systems
            var cs4326 = GeographicCoordinateSystem.WGS84;
            var cs3857 = ProjectedCoordinateSystem.WebMercator;

            // Transformation
            var ctfac = new CoordinateTransformationFactory();
            var trans = ctfac.CreateFromCoordinateSystems(cs3857, cs4326);

            double[] fromPoint = new double[] { item.Coordinates[0].X, item.Coordinates[0].Y };
            double[] toPoint = trans.MathTransform.Transform(fromPoint);
            lng = toPoint[0];
            lat = toPoint[1];
        }

Throws this exception:

Method not found: 'GeoAPI.Geometries.Coordinate[] NetTopologySuite.Geometries.Geometry.get_Coordinates()'.'

So,

FObermaier commented 4 years ago

You are mistaken. NetTopologySuite.Core is an older version (latest v1.15.3). It was necessary because of the license change from LGPL2 to BSD3, because the old package contained code that we could not re-license.

The package you want to use is NetTopologySuite v2.0.0, You can use it along with ProjNet v2.0.0

Avoid using anything that relies on GeoAPI, NetTopologySuite v2.0.0 integrated improved GeoAPI v1.7.5 functionality.

Rumpelstinsk commented 4 years ago

Oh! I didn't know that. Thanks for the help :)