georust / geojson

Library for serializing the GeoJSON vector GIS file format
https://crates.io/crates/geojson
Apache License 2.0
272 stars 59 forks source link

geojson should parse empty point. #231

Open michaelkirk opened 1 year ago

michaelkirk commented 1 year ago

(Edit: whoops I initially created the issue before filling out the description, sorry!).

See: https://github.com/georust/geozero/pull/161

Though the spec says:

A position is an array of numbers. There MUST be two or more elements.

Later it also says:

GeoJSON processors MAY interpret Geometry objects with empty "coordinates" arrays as null objects.

I interpret that to mean that the first quote is actually a little imprecise. It should be "There MUST be two or more elements, or it can be empty in the case of a point".

Note this might be a little tricky because geo_types doesn't represent POINT EMPTY, except as Option, which doesn't always mesh well with our existing APIs.

So if we add support for this, we'll want to make sure that we address any inconsistencies - we likely need a new error class for the case of converting an empty geojson point to a geo_types::Point.