aqila-mapas 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/aqila/mapas/version.rb +1 -1
- data/lib/map/polygon_service.rb +3 -27
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8878e6c12c3d84b3e024092d066a15604794ac46aa1013063699e66087cdd91b
|
4
|
+
data.tar.gz: 06dbb542727a82b0b7770246399bc3991a237ef777534548cffb2e20f0e19129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20a988dc16dbb648602a33666687ff098f0c2ad9fe8cc7bf02393b0d93bf782fbf7c7fc23e65370695d528b892d1adb1362e242255c4cee1ab84fc020836a0e8
|
7
|
+
data.tar.gz: 24bafa96f8fa18267df07efe09aa62a51e767e191782b673fc71e92fafed69037474ffa0372e64653044ae405292526c1d8376d10fe2a6538f9e08beeec29b73
|
data/Gemfile.lock
CHANGED
data/lib/aqila/mapas/version.rb
CHANGED
data/lib/map/polygon_service.rb
CHANGED
@@ -2,20 +2,16 @@
|
|
2
2
|
|
3
3
|
class Map::PolygonService
|
4
4
|
CACHE_EXPIRES = 1.hours
|
5
|
-
POS_LATITUDE = 1
|
6
|
-
POS_LONGITUDE = 0
|
7
5
|
|
8
6
|
def initialize(glebas = nil)
|
9
7
|
@glebas = glebas
|
10
8
|
end
|
11
9
|
|
12
10
|
def inside_any_gleba?(point)
|
13
|
-
|
14
|
-
|
15
|
-
talhoes.each do |talhao|
|
16
|
-
coords = polygon(talhao)
|
11
|
+
glebas.each do |gleba|
|
12
|
+
coords = polygon(gleba)
|
17
13
|
coords.each do |coord|
|
18
|
-
return
|
14
|
+
return gleba if point_inside?(point, coord)
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
@@ -26,34 +22,14 @@ class Map::PolygonService
|
|
26
22
|
@glebas ||= Gleba.select(:cd_gleba, :cd_propriedade, :arquivo_kml, :descricao).active.with_kml
|
27
23
|
end
|
28
24
|
|
29
|
-
def propriedades
|
30
|
-
@propriedades ||= Propriedade.includes(:glebas).select(:cd_propriedade, :descricao).active
|
31
|
-
end
|
32
|
-
|
33
25
|
def inside_polygons?(point, polygons)
|
34
26
|
polygons.any? do |polygon|
|
35
27
|
point_inside?(point, polygon)
|
36
28
|
end
|
37
29
|
end
|
38
30
|
|
39
|
-
def inside_any_propriedade?(point)
|
40
|
-
propriedades.each do |propriedade|
|
41
|
-
return propriedade if point_inside_bounds?(point, propriedade.bounds)
|
42
|
-
end
|
43
|
-
|
44
|
-
nil
|
45
|
-
end
|
46
|
-
|
47
31
|
private
|
48
32
|
|
49
|
-
def point_inside_bounds?(point, bounds)
|
50
|
-
latitude = (point[:latitude] || point['latitude']).to_f
|
51
|
-
longitude = (point[:longitude] || point['longitude']).to_f
|
52
|
-
|
53
|
-
latitude.to_f.between?(bounds[:south_west][POS_LATITUDE].to_f, bounds[:north_east][POS_LATITUDE].to_f) &&
|
54
|
-
longitude.to_f.between?(bounds[:south_west][POS_LONGITUDE].to_f, bounds[:north_east][POS_LONGITUDE].to_f)
|
55
|
-
end
|
56
|
-
|
57
33
|
# Algoritmo portado de código javascript
|
58
34
|
# ray-casting algorithm based on
|
59
35
|
# http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aqila-mapas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lucasferronato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|