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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49cfd37dcf766f5758e4ed80757e6a966622888c
4
- data.tar.gz: fca64a7df1f7dfb8ed2cf00f4ff6be1c8e0ddc5f
3
+ metadata.gz: 035d25dd66d005eece9a769dd4038e956c2cff60
4
+ data.tar.gz: 2067cc049ddcd8a068a0e7fa2099131df29f5675
5
5
  SHA512:
6
- metadata.gz: 3a5c67c0d1523e77ff65c743f3e148c79387a3f67daf4c60d2a26020c0ede6498a407dce9c5a1d6f0a143966e9dbf017ecc134412c0bbef0abc5ef277fbc5a2f
7
- data.tar.gz: 7fcfee079394e072071d604c8f94f58b4eac5fef14e6590546880c66ea17324a32e113c4768e2b5be042db2c7705eed6eaeae2e520acebef138e64b13df5c11f
6
+ metadata.gz: 00c24d8ba4513d9c32221d10951bfed25d3713fec5d1bc253568115d97dd002e99550d585b8c8d75f7a0561d36124a2cd789a9fa8b51f7011d9bdbce9e614172
7
+ data.tar.gz: 4273e547c6844d4e5901089af25ba87874250bd776b493fd2793ddd6299f49c00c80674920cac641c7714472907e5cdd8f1cd75f507371f4b91a4601589ea10f
@@ -7,24 +7,44 @@ module Terraformer
7
7
  end
8
8
 
9
9
  def distance_and_bearing_to obj
10
- case obj
11
- when Point
12
- first_coordinate.distance_and_bearing_to obj.first_coordinate
10
+ dabt = case obj
11
+ when Point
12
+ [first_coordinate.distance_and_bearing_to(obj.first_coordinate)]
13
13
 
14
- # todo other cases
15
- end
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
@@ -1,3 +1,3 @@
1
1
  module Terraformer
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
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.2
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-27 00:00:00.000000000 Z
11
+ date: 2014-05-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: