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

Deserializing unknown Geometries? #184

Open
FrankyBoy opened this issue Nov 19, 2024 · 4 comments
Open

Deserializing unknown Geometries? #184

FrankyBoy opened this issue Nov 19, 2024 · 4 comments

Comments

@FrankyBoy
Copy link

Is there any way to just generically convert a Geometry into whatever type is specified in the GeoJSON itself? I.e. I have a DB column that might be anything from Point to MultiPolygon, so doing JsonConvert.DeserializeObject<SomeSpecificGeomTypeHere>(data.geom) does not work for obvious reasons.

If there is, this should really be documented.

@xfischer
Copy link
Member

Hi ! I think this will work : JsonConvert.DeserializeObject<IGeometryObject>

Good point about the documentation. Where would you like it to be documented? The code itself?

@xfischer
Copy link
Member

@FrankyBoy
Copy link
Author

Hi, so either JsonConvert.DeserializeObject<IGeometryObject>(data.geom, new GeometryConverter()) or JsonConvert.DeserializeObject<IGeoJsonObject>(data.geom, new GeoJsonConverter()) seemed to do the trick. To me it's unclear what the difference between those is as they both seem to produce the same result.

Where it should be documented? I'd say the README as that seems to be the only up to date documentation / reference out there, and the converters are not shown at all there (or explanations what the different converters are meant for).

@xfischer
Copy link
Member

Yeah I admit I also feel confused about that and wonder why it has been designed this way.

IGeometryObject is a minimal internal contract, the constraint of implementing this is only to be able to state which geometry type we are

IGeoJsonObject is more exhaustive, as it adds bounding box and CRS, it is a bridge made for adherence to GeoJSON specs IMHO.

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

2 participants