ocean-names 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: ef91ec19173f79820a3c26b30d51a9b29964cc1b03fe91aa8de0db18e23eb2c8
4
- data.tar.gz: 4d0ed8778da8f19ee8a28db34ae0640146a19a649dfd59d01c5aad9cdfb18ca4
3
+ metadata.gz: 94e15fe50e72695853517f53d0cde86a54a804d3fceb6ff3a96e5d0c4331b75c
4
+ data.tar.gz: cee05132e42793429052b8b59a4bc7888283d8d96d47c14f8b2802e9eae010a3
5
5
  SHA512:
6
- metadata.gz: 8c13e6bc08996d3fc1953e9830433c1dd811d35d8a73c2f2dea13493ace414ab5b6332ca1e677d54c7502126db99f02a4a5a3625f833270dc621cae2fbfc8d25
7
- data.tar.gz: e0072013b5f4af66332f09894ff75b8b06b60d1241ab7b4450a9792f2702bd78637a9803b82740f17e2a744735857ca208a63c7a015df45093435bbaf3f2732c
6
+ metadata.gz: d8b7eb7b541194d980917ec66334fefad6f911fa39719481a8b589670992ddb05d003cbfe222e4252f737a6d4e76fb37bd8c1b4fbb178f5500315cb88884f5eb
7
+ data.tar.gz: 6bbd725216813df318fad41e2a5f9f12e4a568b0908fc43229f2da1627736f6a12a05774ef256e4638fd5ff8df860a96c389a3e1ca3ccbf1c24f55644c8f2c2d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ocean-names (0.3.4)
4
+ ocean-names (0.4.5)
5
5
  oj (~> 3.3)
6
6
 
7
7
  GEM
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "ocean/names/version"
2
4
  require "ocean/names/polygon"
3
5
  require "oj"
@@ -24,7 +26,7 @@ module Ocean
24
26
  def self.reverse_geocode(lat:, lng:)
25
27
  rec = data.find do |record|
26
28
  # avoid check of obviously false geometries
27
- next unless WITHIN_BOUNDS.(record, lat, lng)
29
+ next unless WITHIN_BOUNDS.(record, lng, lat)
28
30
 
29
31
  # get points from nested arrays
30
32
  points = GET_POINTS.(record["geometry"])
@@ -1,30 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ocean
2
4
  module Names
3
5
  class Polygon
4
- attr_accessor :points
5
-
6
6
  def initialize(points)
7
7
  @points = points
8
8
  @points << points[0] if points[0] != points[-1]
9
9
  end
10
10
 
11
11
  def contains?(lat:, lng:)
12
- last_point = points[-1]
12
+ last_point = @points[-1]
13
13
 
14
14
  odd_node = false
15
15
 
16
16
  x = lng
17
17
  y = lat
18
18
 
19
- points.each do |p|
20
- # p = [lat, lng]
21
- y1 = p.first
22
- x1 = p.last
23
- y2 = last_point.first
24
- x2 = last_point.last
19
+ @points.each do |p|
20
+ # p = [lng, lat]
21
+ x1 = p.first
22
+ y1 = p.last
23
+ x2 = last_point.first
24
+ y2 = last_point.last
25
25
 
26
- if y1 < y && y2 >= y || y2 < y && y1 >= y
27
- odd_node = !odd_node if x1 + (y - y1) / (y2 - y1) * (x2 - x1) < x
26
+ if x1 < x && x2 >= x || x2 < x && x1 >= x
27
+ odd_node = !odd_node if y1 + (x - x1) / (x2 - x1) * (y2 - y1) < y
28
28
  end
29
29
 
30
30
  last_point = p
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ocean
2
4
  module Names
3
- VERSION = "0.4.4"
5
+ VERSION = "0.4.5"
4
6
  end
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-names
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
  - rafael