felt / geo

A collection of GIS functions for Elixir
MIT License
649 stars 88 forks source link

Feature object with null geometry is not supported #195

Open carstenpiepel opened 1 year ago

carstenpiepel commented 1 year ago

The GeoJSON spec supports "unlocated" Feature objects where the "geometry" member is a JSON null value. The Geo library simply ignores Features of this kind, even if they have their properties populated. A real-world web service that returns GeoJSON of this type is the National Weather Service Alert API, https://api.weather.gov/zones.

I looked into resolving this issue via a pull request but I am not comfortable contributing structural changes to the library without further discussion. I would appreciate help with this issue.

s3cur3 commented 2 months ago

Sigh. Yeah, filtering these out was probably the wrong choice in #176—I knew at the time that the GeoJSON spec hinted that features with no geometry might be desired. I'll look into making these work.

s3cur3 commented 2 months ago

@carstenpiepel Thoughts on what the best way to handle this might be? My initial thought was a %GeometryCollection{} with an empty list of geometries, but the GeoJSON spec warns:

To maximize interoperability, implementations SHOULD avoid nested GeometryCollections.

Should we therefore implement a new struct like %Geo.Null{coordinates: nil, properties: %{}, properties: %{}}? It's... kind of ugly. 😕