terraformer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/terraformer/point.rb +29 -9
- data/lib/terraformer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035d25dd66d005eece9a769dd4038e956c2cff60
|
4
|
+
data.tar.gz: 2067cc049ddcd8a068a0e7fa2099131df29f5675
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00c24d8ba4513d9c32221d10951bfed25d3713fec5d1bc253568115d97dd002e99550d585b8c8d75f7a0561d36124a2cd789a9fa8b51f7011d9bdbce9e614172
|
7
|
+
data.tar.gz: 4273e547c6844d4e5901089af25ba87874250bd776b493fd2793ddd6299f49c00c80674920cac641c7714472907e5cdd8f1cd75f507371f4b91a4601589ea10f
|
data/lib/terraformer/point.rb
CHANGED
@@ -7,24 +7,44 @@ module Terraformer
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def distance_and_bearing_to obj
|
10
|
-
case obj
|
11
|
-
|
12
|
-
|
10
|
+
dabt = case obj
|
11
|
+
when Point
|
12
|
+
[first_coordinate.distance_and_bearing_to(obj.first_coordinate)]
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
when MultiPoint
|
15
|
+
obj.coordinates.map {|c| first_coordinate.distance_and_bearing_to c}
|
16
|
+
|
17
|
+
when LineString
|
18
|
+
obj.coordinates.map {|c| first_coordinate.distance_and_bearing_to c}
|
19
|
+
|
20
|
+
when MultiLineString
|
21
|
+
obj.line_strings.map {|ls| distance_and_bearing_to ls}
|
22
|
+
|
23
|
+
when Polygon
|
24
|
+
obj.line_strings[0].coordinates.map {|c| first_coordinate.distance_and_bearing_to c}
|
25
|
+
|
26
|
+
when MultiPolygon
|
27
|
+
obj.polygons.map {|p| distance_and_bearing_to p}
|
28
|
+
|
29
|
+
# todo other cases
|
30
|
+
|
31
|
+
else
|
32
|
+
raise ArgumentError.new "unsupported type: #{obj.type rescue obj.class}"
|
33
|
+
end
|
34
|
+
dabt.flatten!
|
35
|
+
dabt.minmax_by {|db| db[:distance]}
|
16
36
|
end
|
17
37
|
|
18
|
-
def distance_to obj
|
19
|
-
distance_and_bearing_to(obj)[:distance]
|
38
|
+
def distance_to obj, minmax = :min
|
39
|
+
distance_and_bearing_to(obj)[minmax == :min ? 0 : 1][:distance]
|
20
40
|
end
|
21
41
|
|
22
42
|
def initial_bearing_to obj
|
23
|
-
distance_and_bearing_to(obj)[:bearing][:initial]
|
43
|
+
distance_and_bearing_to(obj)[0][:bearing][:initial]
|
24
44
|
end
|
25
45
|
|
26
46
|
def final_bearing_to obj
|
27
|
-
distance_and_bearing_to(obj)[:bearing][:final]
|
47
|
+
distance_and_bearing_to(obj)[0][:bearing][:final]
|
28
48
|
end
|
29
49
|
|
30
50
|
def contains? obj
|
data/lib/terraformer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraformer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenichi Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email:
|