rgeo/rgeo-geojson

Decode empty FeatureCollection should not return nil

pedros007 opened this issue · 1 comments

Decoding an empty FeatureCollection returns nil:

RGeo::GeoJSON.decode('{"features": [], "type": "FeatureCollection"}{"features": [], "type": "FeatureCollection"}',  json_parser: :json)
=> nil

I would think it should return an empty RGeo::GeoJSON::FeatureCollection instead, like so:

feats = RGeo::GeoJSON.decode('{"features": [], "type": "FeatureCollection"}{"features": [], "type": "FeatureCollection"}',  json_parser: :json)
=> #<RGeo::GeoJSON::FeatureCollection:0x3465520>
feats.count
=> 0

Woops, copy/paste error, this works fine!

RGeo::GeoJSON.decode('{"features": [], "type": "FeatureCollection"}',  json_parser: :json)
=> #<RGeo::GeoJSON::FeatureCollection:0x340b3e0>