Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializer ignores SRID #137

Open
Simonkampendahl opened this issue Feb 1, 2024 · 3 comments
Open

Serializer ignores SRID #137

Simonkampendahl opened this issue Feb 1, 2024 · 3 comments

Comments

@Simonkampendahl
Copy link

it doesn't matter what SRID is specified, when its deserialized it's always set to 4326.

if i specify SRID with for example:
var t = new NetTopologySuite.Geometries.GeometryFactory().WithSRID(3006); options.SerializerSettings.Converters.Add(new NetTopologySuite.IO.Converters.GeometryConverter());

Then its always setting SRID to 3006.

but i need the user to be able to send in geojson of any SRID, so i can't hardcode a specific SRID, it needs to be read from the input.

Is this not possible?

@airbreather
Copy link
Member

airbreather commented Feb 1, 2024

https://www.rfc-editor.org/rfc/rfc7946#section-4

The coordinate reference system for all GeoJSON coordinates is a
geographic coordinate reference system, using the World Geodetic
System 1984 (WGS 84) [WGS84] datum, with longitude and latitude units
of decimal degrees. This is equivalent to the coordinate reference
system identified by the Open Geospatial Consortium (OGC) URN
urn:ogc:def:crs:OGC::CRS84.

Therefore, I don't see a standard place for us to look for a SRID in the data. You could try using a Feature and then looking for a specific value in its properties after reading it in and converting afterward?

@driekus77
Copy link

We are having same kind of issues with geojson and SRID/CRS:
Our users convert from e.g. autocad to geojson with our without CRS specified. We want todo 2 things:

  • Or Convert to our ("internal") 28992 projection
  • Or forbid the upload, if the incorrect geojson SRID/CRS is recognized

But it seems both options are not possible in NTS with geojson because it only supports WGS84?

Currently we are using the GeometryFactory.Create(28992) hard. So when geojson input is correctly set to this SRID everything works fine.
But when users forget to set the proper SRID to 28992 there seems to be no way to recognize this error?

@driekus77
Copy link

Our SRID/CRS 28992 is only usable for the Netherlands. So currently my workarround is to check if feature(s) are located in the bbox of the Netherlands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants