terraformer 0.0.3 → 0.0.4

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: 035d25dd66d005eece9a769dd4038e956c2cff60
4
- data.tar.gz: 2067cc049ddcd8a068a0e7fa2099131df29f5675
3
+ metadata.gz: 133b3a2bf058e3848e2d20d733d6e3874a518073
4
+ data.tar.gz: aea180ce419297a6dac946bb2a34696fa4e8d9b9
5
5
  SHA512:
6
- metadata.gz: 00c24d8ba4513d9c32221d10951bfed25d3713fec5d1bc253568115d97dd002e99550d585b8c8d75f7a0561d36124a2cd789a9fa8b51f7011d9bdbce9e614172
7
- data.tar.gz: 4273e547c6844d4e5901089af25ba87874250bd776b493fd2793ddd6299f49c00c80674920cac641c7714472907e5cdd8f1cd75f507371f4b91a4601589ea10f
6
+ metadata.gz: 3b92245ec569ec1c43d3a7f9db1e3d743749c4c2f48ec7d200298df745d856350ade2f1155530d9ace206214a2e4c5e016e160b61c8fbaefe5074e40f9a3da6d
7
+ data.tar.gz: d1adfba18548b2f91b3594b6d7a660e1f4516dc06a40d39ddbaecd09ca7872b73e7bd3d9d08a6038673c50c560cb6e84ae190658b1a4d249b09bf6e206fd92e8
@@ -8,5 +8,8 @@ class BigDecimal
8
8
  (self * Terraformer::RADIANS_PER_DEGREE).round Terraformer::PRECISION
9
9
  end
10
10
 
11
- end
11
+ def to_json *args
12
+ finite? ? to_f.to_json : NilClass::AS_JSON
13
+ end
12
14
 
15
+ end
@@ -33,8 +33,6 @@ module Terraformer
33
33
 
34
34
  case format
35
35
  when :bbox
36
- # yikes!
37
- bbox.extend BBox
38
36
  bbox
39
37
  when :polygon
40
38
  Polygon.new [[bbox[0], bbox[1]],
@@ -55,15 +53,13 @@ module Terraformer
55
53
  else
56
54
  bbox = array.reduce box do |b, lonlat|
57
55
  lon, lat = *lonlat
58
- set = ->(d, i, t){ b[i] = d if b[i].nil? or d.send(t, b[i]) }
56
+ set = ->(d, i, t){ b[i] = d if b[i].nil? or d.send(t, b[i])}
59
57
  set[lon, X1, :<]
60
58
  set[lon, X2, :>]
61
59
  set[lat, Y1, :<]
62
60
  set[lat, Y2, :>]
63
61
  b
64
62
  end
65
- # yikes!
66
- bbox.extend BBox
67
63
  bbox
68
64
  end
69
65
  end
@@ -99,7 +99,7 @@ module Terraformer
99
99
  end
100
100
 
101
101
  def to_json *args
102
- [x, y, z].map! {|e| e.to_f if e}.compact.to_json(*args)
102
+ compact.to_json(*args)
103
103
  end
104
104
 
105
105
  def to_point
@@ -22,11 +22,13 @@ module Terraformer
22
22
  end
23
23
  end
24
24
 
25
- def to_hash
26
- {
25
+ def to_hash *args
26
+ h = {
27
27
  type: type,
28
28
  coordinates: coordinates
29
29
  }
30
+ h[:bbox] = bbox if Hash === args.last and args.last[:include_bbox]
31
+ h
30
32
  end
31
33
 
32
34
  def to_mercator
@@ -1,3 +1,3 @@
1
1
  module Terraformer
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
data/lib/terraformer.rb CHANGED
@@ -70,22 +70,13 @@ module Terraformer
70
70
  end
71
71
 
72
72
  def to_json *args
73
- h = self.to_hash
74
- h[:bbox] = bbox if Hash === args.last and args.pop[:include_bbox]
73
+ h = self.to_hash *args
74
+ args.pop if Hash === args.last
75
75
  h.to_json *args
76
76
  end
77
77
 
78
78
  end
79
79
 
80
- # yikes!
81
- module BBox
82
-
83
- def to_json *args
84
- map {|e| e.to_f if e}.to_json *args
85
- end
86
-
87
- end
88
-
89
80
  end
90
81
 
91
82
  require 'terraformer/coordinate'
@@ -101,3 +92,5 @@ require 'terraformer/polygon'
101
92
  require 'terraformer/multi_polygon'
102
93
  require 'terraformer/convex_hull'
103
94
  require 'terraformer/circle'
95
+
96
+ require 'terraformer/version'
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.3
4
+ version: 0.0.4
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-28 00:00:00.000000000 Z
11
+ date: 2014-05-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: