Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >> point = @property.coords
- >> ES_Zone.where{ st_contains(geometry, point) }
- => #<ActiveRecord::Relation []>
- >> 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>
- scope :containing, -> (point) { where("#{self.table_name}.geometry && ?", point) }
- SELECT id, the_geom FROM thetable
- WHERE
- the_geom && 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'
- AND
- ST_Contains(the_geom,'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
Add Comment
Please, Sign In to add comment