Class: Map::PolygonService
- Inherits:
-
Object
- Object
- Map::PolygonService
- Defined in:
- lib/map/polygon_service.rb
Constant Summary collapse
- CACHE_EXPIRES =
1.hours
Instance Method Summary collapse
- #glebas ⇒ Object
-
#initialize(glebas = nil) ⇒ PolygonService
constructor
A new instance of PolygonService.
- #inside_any_gleba?(point) ⇒ Boolean
- #inside_polygons?(point, polygons) ⇒ Boolean
Constructor Details
#initialize(glebas = nil) ⇒ PolygonService
Returns a new instance of PolygonService.
6 7 8 |
# File 'lib/map/polygon_service.rb', line 6 def initialize(glebas = nil) @glebas = glebas end |
Instance Method Details
#glebas ⇒ Object
21 22 23 |
# File 'lib/map/polygon_service.rb', line 21 def glebas @glebas ||= Gleba.select(:cd_gleba, :cd_propriedade, :arquivo_kml, :descricao).active.with_kml end |
#inside_any_gleba?(point) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/map/polygon_service.rb', line 10 def inside_any_gleba?(point) glebas.each do |gleba| coords = polygon(gleba) coords.each do |coord| return gleba if point_inside?(point, coord) end end nil end |
#inside_polygons?(point, polygons) ⇒ Boolean
25 26 27 28 29 |
# File 'lib/map/polygon_service.rb', line 25 def inside_polygons?(point, polygons) polygons.any? do |polygon| point_inside?(point, polygon) end end |