filosganga / geogson

GeoJSON support for Google gson library
Apache License 2.0
68 stars 29 forks source link

In the case that the Feature is unlocated, a JSON null value for the member with the name "geometry" should be present #64

Open tk4638 opened 5 years ago

tk4638 commented 5 years ago

Hi All, I am looking at the specification https://tools.ietf.org/html/rfc7946#page-11 and there is :

3.2. Feature Object

A Feature object represents a spatially bounded thing. Every Feature object is a GeoJSON object no matter where it occurs in a GeoJSON text.

o A Feature object has a "type" member with the value "Feature".

o A Feature object has a member with the name "geometry". The value of the geometry member SHALL be either a Geometry object as defined above or, in the case that the Feature is unlocated, a JSON null value.

Based on that a null value for the Geometry object should be allowed.

In the latest version in https://github.com/filosganga/geogson/blob/master/core/src/main/java/com/github/filosganga/geogson/model/Feature.java line 69 : public Feature build() { if(geometry == null) { throw new IllegalStateException("geometry is required to build a Feature"); } return new Feature(geometry, properties, id); } this is not followed.

In the version 1.2.21 it was possible to create/write a null value for the geometry BUT was not possible to read it.

Do you agree that this should be address in order to follow the specification ? Thank you !

filosganga commented 2 years ago

Thank you for reporting, and sorry for the huge delay, it looks like it is abug