aqila-mapas 0.4.4 → 0.4.6
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/download_tiles_service.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: 1eb2d624222ead0f861f7de6b5a4831c1be525849c1df94a43c1e2c80ca9a1da
|
4
|
+
data.tar.gz: 357481b73dd1d514c5b26575a70619a883750acf83c412570957cf59e47ba5bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66b728f7e94b9389cf686f7675754bf0341fc2d98a8d081d709cb40ab109d9484ec4d776d08a2c15327b726060cc74d0f17fbe1a0d3fd9b9d61028cba9b18df5
|
7
|
+
data.tar.gz: 43ad2e3d3b110b43bc646090fb17ebff4187a6f4b259a3f66533e8e43aee09362efc47b9ca37520bb8528e1eb4af7a2269983d37d32ee59c001f6e0b9f733b9a
|
data/Gemfile.lock
CHANGED
data/lib/aqila/mapas/version.rb
CHANGED
@@ -13,7 +13,7 @@ class Map::DownloadTilesService
|
|
13
13
|
'http://c.tile.openstreetmap.org'
|
14
14
|
].freeze
|
15
15
|
MAP_BOX_SERVER = 'https://api.mapbox.com/styles/v1/mapbox/satellite-v9/tiles/256'
|
16
|
-
MAP_BOX_TOKEN = 'pk.
|
16
|
+
MAP_BOX_TOKEN = 'pk.eyJ1IjoiaW5vdmFjYW8tYWdybzEiLCJhIjoiY2xneHhwdXZ0MDN5OTNpcXF3dTd0dHJwOCJ9.kZoathkPpmDuuc1nDROauA'
|
17
17
|
|
18
18
|
def initialize(options = {})
|
19
19
|
@zoom_min = options[:zoom] || options[:zoom_min]
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lucasferronato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|