I am using the rgeo ruby library to parse out geojson polygons. The behavior is to return nil when calling decode on a polygon with duplicate points as in the following example:
geom = {:geom=>{"type"=>"Polygon", "coordinates"=>[[[-82.5721, 28.0245], [-82.5721, 28.0245] ... }
geo_factory = RGeo::Cartesian.factory(:srid => 4326)
rgeo_geom = RGeo::GeoJSON.decode(geom, json_parser: :json, geo_factory: geo_factory)
Due to the repeated point at the beginning, rgeo_geom will be nil after this code is executed.
What is the most efficient way to clean this polygon? Is there a built in rgeo feature or should I roll my own?
To be clear I would like to remove only consecutive duplicate points as this is what causes the library to return nil for the above code. I am also not looking for in db solutions such as postgis st_removerepeatedpoints, but am essentially looking for this behavior executed in ruby.