chuyentt / geojson_vi

An Open-Source Dart and Flutter Library for Efficiently Handling GeoJSON Data in Compliance with RFC 7946
https://pub.dev/packages/geojson_vi
MIT License
15 stars 10 forks source link

GeoJSON Feature with null geometry #24

Closed aloh86 closed 2 months ago

aloh86 commented 2 months ago

Describe the bug According to the spec (https://datatracker.ietf.org/doc/html/rfc7946#section-3.2), a Feature should allow for a null geometry value. However, GeoJSONFeature.fromMap(...) asserts that the geometry key must have a geometry object.

I am trying to use the NWS Weather API for weather alerts, and the feature geometry for weather alerts are often null. Example source: https://api.weather.gov/alerts/active/area/OR (may have to change OR to another U.S. state abbreviation as active alerts changes according to weather).

image

To Reproduce Steps to reproduce the behavior:

  1. Pass a GeoJSON feature with a geometry value of null to GeoJSONFeature.fromMap(...)
  2. Program will assert that map['geometry'] must be an object of non-null value.

Expected behavior Allow the value for geometry to be null.

Version geojson_vi version 2.2.4

chuyentt commented 2 months ago

Hi @aloh86,

I have fixed the issue regarding the GeoJSONFeature and GeoJSONFeatureCollection not allowing null geometry values according to the GeoJSON spec section 3.2. Now, both classes support null geometry values as required. Additionally, bbox calculations have been updated to handle features with null geometry.

You can update to version 2.2.5 to get this fix.

Let me know if you have any further issues or questions!

Best regards, Chuyen

aloh86 commented 2 months ago

Great! Thanks, @chuyentt!