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

Fix handling of GeoJSON Z and M coordinates #188

Open
s3cur3 opened this issue Oct 9, 2023 · 1 comment
Open

Fix handling of GeoJSON Z and M coordinates #188

s3cur3 opened this issue Oct 9, 2023 · 1 comment

Comments

@s3cur3
Copy link
Contributor

s3cur3 commented Oct 9, 2023

Per the discussion on #171, there's an existing bug in our handling of Z and M coordinates in the GeoJSON decoder.

GeoJSON does not recognize any such geometry type as PointZ, LineStringZ, etc. Indeed, if you give these to PostGIS, you'll get an error. However, when GeoJSON types such as LineString are given with the 3rd position present in coordinates, we should assume it is Z, as the spec indicates, and parse it into the correct 'Z' type. This means that a LineString GeoJSON could be decoded into either Geo.LineString or Geo.LineStringZ, depending on the data.

Rather than making this a breaking change, I think we could maintain backward compatibility with past versions of geo by continuing to accept the Z-variant types, as long as we also accept 3-position coordinates as Z types as well.

Since GeoJSON has no notion of an M coordinate, we should continue to strip out 4th or greater positions on GeoJSON decode, such as 'M'. Decode 4+ member coordinates into 3 member 'Z' types.

@s3cur3
Copy link
Contributor Author

s3cur3 commented Aug 30, 2024

At this time, I don't have a professional use for Z and M coordinates, so I'm rather loathe to make big changes here without knowing the real-world use cases. If somebody has a stake in this, I'd love to hear your thoughts on how to handle it.

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

No branches or pull requests

1 participant