How to determine if a latitude, longitude fall within a feature (polygon) of a geojson feature collection?
backward-crazy-mage-puppy-36 opened this issue · 2 comments
I have been through the documentation and wasn't able to find anything on checking to see if a [lat, long] point falls within a feature of a geojson feature collection. Mapbox / leaflet have a getBounds([lat, long]) function that can be run on a geojson feature object to determine whether the point falls within the shape. I was wondering if there is anything similar available in rgeo-geojson, if not what would be the best way for me to go about writing such a function.
Thanks.
The main rgeo library provides this functionality (because it's shared across geometries coming in from GeoJSON, Shapefiles, and databases). The documentation isn't very inviting, but if you can figure out how to work with geometry features, then you can use the within?
method to answer your question: http://www.rubydoc.info/gems/rgeo/RGeo/Feature/Geometry#within%3F-instance_method
Indeed RGeo::Feature::Geometry#within?
does the trick. There is also a #contains?
method.
I'm closing this issue since it is related to https://github.com/rgeo/rgeo. And I've added the documentation tag which will help us building a getting started guide.