Guest User

Untitled

a guest
Mar 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. >> point = @property.coords
  2. >> ES_Zone.where{ st_contains(geometry, point) }
  3. => #<ActiveRecord::Relation []>
  4.  
  5. >> point.class
  6. => RGeo::Geos::CAPIPointImpl
  7. >> point.factory
  8. => #<RGeo::Geos::CAPIFactory:0x860c5838 srid=3785 bufres=1 flags=8>
  9.  
  10. >> ES_Zone.first.geometry.class
  11. => RGeo::Geos::CAPIMultiPolygonImpl
  12. >> ES_Zone.first.geometry.factory
  13. => #<RGeo::Geos::CAPIFactory:0x84889648 srid=3785 bufres=1 flags=8>
  14.  
  15. scope :containing, -> (point) { where("#{self.table_name}.geometry && ?", point) }
  16.  
  17. SELECT id, the_geom FROM thetable
  18. WHERE
  19. the_geom && 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'
  20. AND
  21. ST_Contains(the_geom,'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
Add Comment
Please, Sign In to add comment