I am new to working with GIS, and am building a rails app that uses the rgeo gem and PostGIS.
I am trying to use geospatial data to determine the school district for a house. The house is represented by a point, and the school districts are represented by multipolygons. I have successfully plotted both on a map, and all appears to be working correctly, with the point falling inside of one of the polygons.
However, when I try to run the following code to determine which district the house is in, I get back an empty array:
>> point = @property.coords
>> ES_Zone.where{ st_contains(geometry, point) }
=> #<ActiveRecord::Relation []>
I think that the SRIDs are the same on the points and polygons, because the factories for each show SRID 3785.
>> point.class
=> RGeo::Geos::CAPIPointImpl
>> point.factory
=> #<RGeo::Geos::CAPIFactory:0x860c5838 srid=3785 bufres=1 flags=8>
>> ES_Zone.first.geometry.class
=> RGeo::Geos::CAPIMultiPolygonImpl
>> ES_Zone.first.geometry.factory
=> #<RGeo::Geos::CAPIFactory:0x84889648 srid=3785 bufres=1 flags=8>
Any ideas on why this is happening, and suggestions for how to fix it?
ES_Zone.where{ st_contains(geometry, point) }.to_sql
return?