rgeo/rgeo-geojson

Error when I add a geo_factory

Closed this issue · 1 comments

I'm trying to parse a Geojson file but I get the following error when I add a geo_factory:
RGeo::Error::InvalidGeometry: LinearRing failed ring test

This is the code I used

@geo_factory = RGeo::Geographic.spherical_factory(srid: 4326)
governorates = RGeo::GeoJSON.decode(File.open('./stanford-bb409wq6265-geojson.json').read, geo_factory: @geo_factory)

Is there's a way around this issue?

Your geojson likely contains geometries with self-intersections. The default behavior of factories is to raise an InvalidGeometry error when this is the case. You can get around this but creating the factory with the uses_lenient_assertions flag.

RGeo::Geographic.spherical_factory(srid: 4326, uses_lenient_assertions: true)

Note that there is no guarantee that methods called on an invalid geometry will return the correct result (i.e. area will likely be wrong).