cartesian_for_geo 1.1.1 → 2.0.0
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 +4 -4
- data/lib/cartesian_for_geo.rb +17 -6
- data/lib/cartesian_for_geo/version.rb +1 -1
- 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: d5815b13b033fea94b353ea63a41909a024b624d0d89dddb33154a5535904b2f
|
4
|
+
data.tar.gz: 1c7484349baf363c29f79e9263ab2ce2a57c9dc85f23f764230e62435a25e117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14d4d03fb3d5287bef11734e34b1894ac296ce4dce7d9ece2b539e53d2d6682de8340ba1130db92cdd59c6fc4ecb03ab1f1bd6b9737b528adc634494b99703b9
|
7
|
+
data.tar.gz: cc924ea13ba9c4f4d7e4a555965a419b9362cc1f6017d469561b3884291b76425507fb82e85754fe5a412ce7c1befa6dae43a820ebd820705844dd1b82d302d3
|
data/lib/cartesian_for_geo.rb
CHANGED
@@ -23,10 +23,9 @@ module CartesianForGeo
|
|
23
23
|
include Comparable
|
24
24
|
|
25
25
|
attr_accessor :lat, :lng
|
26
|
-
attr_reader :coords
|
26
|
+
attr_reader :coords, :order
|
27
27
|
|
28
28
|
alias to_a coords
|
29
|
-
alias lat_lng coords
|
30
29
|
|
31
30
|
class << self
|
32
31
|
alias [] new
|
@@ -39,6 +38,7 @@ module CartesianForGeo
|
|
39
38
|
def initialize(*coords)
|
40
39
|
@coords = coords.flatten
|
41
40
|
@lat, @lng = @coords
|
41
|
+
@order = :lat_lng
|
42
42
|
end
|
43
43
|
|
44
44
|
def side
|
@@ -54,11 +54,19 @@ module CartesianForGeo
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def to_s
|
57
|
-
empty? ? '' : "(#{
|
57
|
+
empty? ? '' : "(#{coords.join(',')})"
|
58
58
|
end
|
59
59
|
|
60
|
-
def lng_lat
|
61
|
-
|
60
|
+
def lng_lat!
|
61
|
+
@order = :lng_lat
|
62
|
+
@coords = [@lng, @lat]
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
def lat_lng!
|
67
|
+
@order = :lat_lng
|
68
|
+
@coords = [@lat, @lng]
|
69
|
+
self
|
62
70
|
end
|
63
71
|
|
64
72
|
def to_json(*)
|
@@ -70,7 +78,10 @@ module CartesianForGeo
|
|
70
78
|
end
|
71
79
|
|
72
80
|
def <=>(other)
|
73
|
-
[
|
81
|
+
[
|
82
|
+
to_a,
|
83
|
+
other.to_a.public_send(order == other.order ? :itself : :reverse)
|
84
|
+
].map { |cord| cord.map { |f| f.round 9 } }.reduce(:<=>)
|
74
85
|
end
|
75
86
|
end
|
76
87
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cartesian_for_geo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Tyurin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gorilla_patch
|