rgeo-geojson 2.0.0 → 2.1.0

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
  SHA256:
3
- metadata.gz: d19417fa49fc036ec401b5d31bcd199127f4763271ea4dabf9ba71c42f52c597
4
- data.tar.gz: 5cc770263b8cf0fabaab1afc4e5460ba09286817eb6e6c5141ceb60a79e141fe
3
+ metadata.gz: 31e3acae0a1cc1b8b417a6e66a03ea7b162cc598f6a48dfaf73a93535d13bbd9
4
+ data.tar.gz: 31eb694d0d74d5fb8d41b6c6d1b07017ec71aefd080678a27565b60bb037e29b
5
5
  SHA512:
6
- metadata.gz: 2674558dd3cc38448be259d1559b8e8e30a6320a35c20d09c6ddb7e16a02cd5c6ef78cbf6629793781921a6dcae8ce5360ade73fb9e0b35b7cc52c362c2dcc80
7
- data.tar.gz: 42cbf6b73fede00bd88970eb29cecdd6a6128450615cd366da2bae91a40243182ed17dccbd21c7e7f97a8a9622f1f9ac402f2ff9b64545eb69b0f5cb488bc302
6
+ metadata.gz: 181c8f3958610b3df6f6c830af066590b438fd3955cdd9cdfe7c80a00791a7038d9db37c711412380f4fd11a8f56b308c7fb7c50cfbc7b2c8bd3988dc680d90a
7
+ data.tar.gz: f3d13428ed86ee87c6850626df4cc6146170f89b163d47d3db8226f03b21096fd40badafb178e59205418daf354e1f5d549776a382c22f2145c7a69ae65d1d63
data/History.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 2.1.0 / 2018-11-27
2
+
3
+ * Allow rgeo 2.0
4
+ * Require ruby 2.3+
5
+
6
+
1
7
  ### 2.0.0 / 2018-01-13
2
8
 
3
9
  * Remove :json_parser option #38
@@ -44,14 +44,14 @@ module RGeo
44
44
  if @entity_factory.is_feature_collection?(object)
45
45
  {
46
46
  "type" => "FeatureCollection",
47
- "features" => @entity_factory.map_feature_collection(object) { |f| _encode_feature(f) },
47
+ "features" => @entity_factory.map_feature_collection(object) { |f| encode_feature(f) },
48
48
  }
49
49
  elsif @entity_factory.is_feature?(object)
50
- _encode_feature(object)
50
+ encode_feature(object)
51
51
  elsif object.nil?
52
52
  nil
53
53
  else
54
- _encode_geometry(object)
54
+ encode_geometry(object)
55
55
  end
56
56
  end
57
57
 
@@ -66,9 +66,8 @@ module RGeo
66
66
  if input.is_a?(String)
67
67
  input = JSON.parse(input)
68
68
  end
69
- unless input.is_a?(Hash)
70
- return nil
71
- end
69
+ return unless input.is_a?(Hash)
70
+
72
71
  case input["type"]
73
72
  when "FeatureCollection"
74
73
  features = input["features"]
@@ -76,14 +75,14 @@ module RGeo
76
75
  decoded_features = []
77
76
  features.each do |f|
78
77
  if f["type"] == "Feature"
79
- decoded_features << _decode_feature(f)
78
+ decoded_features << decode_feature(f)
80
79
  end
81
80
  end
82
81
  @entity_factory.feature_collection(decoded_features)
83
82
  when "Feature"
84
- _decode_feature(input)
83
+ decode_feature(input)
85
84
  else
86
- _decode_geometry(input)
85
+ decode_geometry(input)
87
86
  end
88
87
  end
89
88
 
@@ -98,10 +97,10 @@ module RGeo
98
97
 
99
98
  private
100
99
 
101
- def _encode_feature(object) # :nodoc:
100
+ def encode_feature(object)
102
101
  json = {
103
102
  "type" => "Feature",
104
- "geometry" => _encode_geometry(@entity_factory.get_feature_geometry(object)),
103
+ "geometry" => encode_geometry(@entity_factory.get_feature_geometry(object)),
105
104
  "properties" => @entity_factory.get_feature_properties(object).dup,
106
105
  }
107
106
  id = @entity_factory.get_feature_id(object)
@@ -109,7 +108,7 @@ module RGeo
109
108
  json
110
109
  end
111
110
 
112
- def _encode_geometry(object) # :nodoc:
111
+ def encode_geometry(object)
113
112
  case object
114
113
  when RGeo::Feature::Point
115
114
  {
@@ -144,77 +143,77 @@ module RGeo
144
143
  when RGeo::Feature::GeometryCollection
145
144
  {
146
145
  "type" => "GeometryCollection",
147
- "geometries" => object.map { |geom| _encode_geometry(geom) }
146
+ "geometries" => object.map { |geom| encode_geometry(geom) }
148
147
  }
149
148
  else
150
149
  nil
151
150
  end
152
151
  end
153
152
 
154
- def _decode_feature(input) # :nodoc:
153
+ def decode_feature(input)
155
154
  geometry = input["geometry"]
156
155
  if geometry
157
- geometry = _decode_geometry(geometry)
158
- return nil unless geometry
156
+ geometry = decode_geometry(geometry)
157
+ return unless geometry
159
158
  end
160
159
  @entity_factory.feature(geometry, input["id"], input["properties"])
161
160
  end
162
161
 
163
- def _decode_geometry(input) # :nodoc:
162
+ def decode_geometry(input)
164
163
  case input["type"]
165
164
  when "GeometryCollection"
166
- _decode_geometry_collection(input)
165
+ decode_geometry_collection(input)
167
166
  when "Point"
168
- _decode_point_coords(input["coordinates"])
167
+ decode_point_coords(input["coordinates"])
169
168
  when "LineString"
170
- _decode_line_string_coords(input["coordinates"])
169
+ decode_line_string_coords(input["coordinates"])
171
170
  when "Polygon"
172
- _decode_polygon_coords(input["coordinates"])
171
+ decode_polygon_coords(input["coordinates"])
173
172
  when "MultiPoint"
174
- _decode_multi_point_coords(input["coordinates"])
173
+ decode_multi_point_coords(input["coordinates"])
175
174
  when "MultiLineString"
176
- _decode_multi_line_string_coords(input["coordinates"])
175
+ decode_multi_line_string_coords(input["coordinates"])
177
176
  when "MultiPolygon"
178
- _decode_multi_polygon_coords(input["coordinates"])
177
+ decode_multi_polygon_coords(input["coordinates"])
179
178
  else
180
179
  nil
181
180
  end
182
181
  end
183
182
 
184
- def _decode_geometry_collection(input) # :nodoc:
185
- geometries_ = input["geometries"]
186
- geometries_ = [] unless geometries_.is_a?(Array)
187
- decoded_geometries_ = []
188
- geometries_.each do |g_|
189
- g_ = _decode_geometry(g_)
190
- decoded_geometries_ << g_ if g_
183
+ def decode_geometry_collection(input)
184
+ geometries = input["geometries"]
185
+ geometries = [] unless geometries.is_a?(Array)
186
+ decoded_geometries = []
187
+ geometries.each do |geometry|
188
+ geometry = decode_geometry(geometry)
189
+ decoded_geometries << geometry if geometry
191
190
  end
192
- @geo_factory.collection(decoded_geometries_)
191
+ @geo_factory.collection(decoded_geometries)
193
192
  end
194
193
 
195
- def _decode_point_coords(point_coords) # :nodoc:
196
- return nil unless point_coords.is_a?(Array)
194
+ def decode_point_coords(point_coords)
195
+ return unless point_coords.is_a?(Array)
197
196
  @geo_factory.point(*(point_coords[0...@num_coordinates].map(&:to_f))) rescue nil
198
197
  end
199
198
 
200
- def _decode_line_string_coords(line_coords) # :nodoc:
201
- return nil unless line_coords.is_a?(Array)
199
+ def decode_line_string_coords(line_coords)
200
+ return unless line_coords.is_a?(Array)
202
201
  points = []
203
202
  line_coords.each do |point_coords|
204
- point = _decode_point_coords(point_coords)
203
+ point = decode_point_coords(point_coords)
205
204
  points << point if point
206
205
  end
207
206
  @geo_factory.line_string(points)
208
207
  end
209
208
 
210
- def _decode_polygon_coords(poly_coords) # :nodoc:
211
- return nil unless poly_coords.is_a?(Array)
209
+ def decode_polygon_coords(poly_coords)
210
+ return unless poly_coords.is_a?(Array)
212
211
  rings = []
213
212
  poly_coords.each do |ring_coords|
214
- return nil unless ring_coords.is_a?(Array)
213
+ return unless ring_coords.is_a?(Array)
215
214
  points = []
216
215
  ring_coords.each do |point_coords|
217
- point = _decode_point_coords(point_coords)
216
+ point = decode_point_coords(point_coords)
218
217
  points << point if point
219
218
  end
220
219
  ring = @geo_factory.linear_ring(points)
@@ -227,31 +226,31 @@ module RGeo
227
226
  end
228
227
  end
229
228
 
230
- def _decode_multi_point_coords(multi_point_coords) # :nodoc:
231
- return nil unless multi_point_coords.is_a?(Array)
229
+ def decode_multi_point_coords(multi_point_coords)
230
+ return unless multi_point_coords.is_a?(Array)
232
231
  points = []
233
232
  multi_point_coords.each do |point_coords|
234
- point = _decode_point_coords(point_coords)
233
+ point = decode_point_coords(point_coords)
235
234
  points << point if point
236
235
  end
237
236
  @geo_factory.multi_point(points)
238
237
  end
239
238
 
240
- def _decode_multi_line_string_coords(multi_line_coords) # :nodoc:
241
- return nil unless multi_line_coords.is_a?(Array)
239
+ def decode_multi_line_string_coords(multi_line_coords)
240
+ return unless multi_line_coords.is_a?(Array)
242
241
  lines = []
243
242
  multi_line_coords.each do |line_coords|
244
- line = _decode_line_string_coords(line_coords)
243
+ line = decode_line_string_coords(line_coords)
245
244
  lines << line if line
246
245
  end
247
246
  @geo_factory.multi_line_string(lines)
248
247
  end
249
248
 
250
- def _decode_multi_polygon_coords(multi_polygon_coords) # :nodoc:
251
- return nil unless multi_polygon_coords.is_a?(Array)
249
+ def decode_multi_polygon_coords(multi_polygon_coords)
250
+ return unless multi_polygon_coords.is_a?(Array)
252
251
  polygons = []
253
252
  multi_polygon_coords.each do |poly_coords|
254
- poly = _decode_polygon_coords(poly_coords)
253
+ poly = decode_polygon_coords(poly_coords)
255
254
  polygons << poly if poly
256
255
  end
257
256
  @geo_factory.multi_polygon(polygons)
@@ -1,5 +1,5 @@
1
1
  module RGeo
2
2
  module GeoJSON
3
- VERSION = "2.0.0".freeze
3
+ VERSION = "2.1.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgeo-geojson
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-13 00:00:00.000000000 Z
12
+ date: 2018-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rgeo
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '1.0'
20
+ version: 1.0.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '1.0'
27
+ version: 1.0.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -97,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
97
  requirements:
98
98
  - - ">="
99
99
  - !ruby/object:Gem::Version
100
- version: 2.1.0
100
+ version: 2.3.0
101
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - ">="
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.7.4
108
+ rubygems_version: 2.7.8
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Convert RGeo data to and from GeoJSON.