aqila-mapas 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcdd005345770dfe8a5cfc1161362310be28a4e585806f4737dfecb0033add47
4
- data.tar.gz: 84888482913a8079a135c89e18e2b2c726219d4ba736d97f1bed53ff2a50387e
3
+ metadata.gz: 8878e6c12c3d84b3e024092d066a15604794ac46aa1013063699e66087cdd91b
4
+ data.tar.gz: 06dbb542727a82b0b7770246399bc3991a237ef777534548cffb2e20f0e19129
5
5
  SHA512:
6
- metadata.gz: 8b46c474703f563f8b572e9372f00e820375939c585c7518bcd47fc6b8ae85e694d082bf834902098465f7008a0656325404ea9da8daa5731105f612a1d4c824
7
- data.tar.gz: 1b74682e746abdfd8b6411abda57f28f0d04df428f92c675771ea0f6ca86f05185a662c2175d002e2ff8ec7ad252381565ae463248c5cc7579fcbb1a404958cd
6
+ metadata.gz: 20a988dc16dbb648602a33666687ff098f0c2ad9fe8cc7bf02393b0d93bf782fbf7c7fc23e65370695d528b892d1adb1362e242255c4cee1ab84fc020836a0e8
7
+ data.tar.gz: 24bafa96f8fa18267df07efe09aa62a51e767e191782b673fc71e92fafed69037474ffa0372e64653044ae405292526c1d8376d10fe2a6538f9e08beeec29b73
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aqila-mapas (0.4.4)
4
+ aqila-mapas (0.4.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aqila
4
4
  module Mapas
5
- VERSION = '0.4.4'
5
+ VERSION = '0.4.5'
6
6
  end
7
7
  end
@@ -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
- propriedade = inside_any_propriedade?(point)
14
- talhoes = propriedade&.glebas || glebas
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 talhao if point_inside?(point, coord)
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
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-02 00:00:00.000000000 Z
11
+ date: 2023-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler