rgeo-geojson 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +17 -5
- data/README.md +9 -9
- data/lib/rgeo/geo_json.rb +1 -0
- data/lib/rgeo/geo_json/coder.rb +3 -29
- data/lib/rgeo/geo_json/interface.rb +0 -24
- data/lib/rgeo/geo_json/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d19417fa49fc036ec401b5d31bcd199127f4763271ea4dabf9ba71c42f52c597
|
4
|
+
data.tar.gz: 5cc770263b8cf0fabaab1afc4e5460ba09286817eb6e6c5141ceb60a79e141fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2674558dd3cc38448be259d1559b8e8e30a6320a35c20d09c6ddb7e16a02cd5c6ef78cbf6629793781921a6dcae8ce5360ade73fb9e0b35b7cc52c362c2dcc80
|
7
|
+
data.tar.gz: 42cbf6b73fede00bd88970eb29cecdd6a6128450615cd366da2bae91a40243182ed17dccbd21c7e7f97a8a9622f1f9ac402f2ff9b64545eb69b0f5cb488bc302
|
data/History.md
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
-
### 0.
|
1
|
+
### 2.0.0 / 2018-01-13
|
2
|
+
|
3
|
+
* Remove :json_parser option #38
|
4
|
+
* Use stdlib JSON parser
|
5
|
+
|
6
|
+
|
7
|
+
### 1.0.0 / 2017-12-02
|
8
|
+
|
9
|
+
* Require ruby 2.1+
|
10
|
+
* Require rgeo 1.0+ #36
|
11
|
+
|
12
|
+
|
13
|
+
### 0.4.2 / 2016-01-05
|
2
14
|
|
3
15
|
* Fix Feature#inspect #21
|
4
16
|
|
@@ -10,9 +22,9 @@
|
|
10
22
|
|
11
23
|
### 0.4.0 / 2015-12-28
|
12
24
|
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
25
|
+
* Remove error handling for missing parser gems
|
26
|
+
* Remove class variables in Coder
|
27
|
+
* Remove rgeo/geo_json.rb
|
16
28
|
|
17
29
|
|
18
30
|
### 0.3.3 / 2015-12-23
|
@@ -24,7 +36,7 @@
|
|
24
36
|
### 0.3.2 / 2015-12-10
|
25
37
|
|
26
38
|
* Faster coordinates methods (tneems) #18
|
27
|
-
*
|
39
|
+
* Require rgeo 0.5.0+
|
28
40
|
|
29
41
|
|
30
42
|
### 0.3.1 / 2014-05-29
|
data/README.md
CHANGED
@@ -25,13 +25,13 @@ Example:
|
|
25
25
|
require 'rgeo/geo_json'
|
26
26
|
|
27
27
|
str1 = '{"type":"Point","coordinates":[1,2]}'
|
28
|
-
geom = RGeo::GeoJSON.decode(str1
|
29
|
-
geom.as_text # => "POINT(1.0 2.0)"
|
28
|
+
geom = RGeo::GeoJSON.decode(str1)
|
29
|
+
geom.as_text # => "POINT (1.0 2.0)"
|
30
30
|
|
31
31
|
str2 = '{"type":"Feature","geometry":{"type":"Point","coordinates":[2.5,4.0]},"properties":{"color":"red"}}'
|
32
|
-
feature = RGeo::GeoJSON.decode(str2
|
32
|
+
feature = RGeo::GeoJSON.decode(str2)
|
33
33
|
feature['color'] # => 'red'
|
34
|
-
feature.geometry.as_text # => "POINT(2.5 4.0)"
|
34
|
+
feature.geometry.as_text # => "POINT (2.5 4.0)"
|
35
35
|
|
36
36
|
hash = RGeo::GeoJSON.encode(feature)
|
37
37
|
hash.to_json == str2 # => true
|
@@ -39,10 +39,10 @@ hash.to_json == str2 # => true
|
|
39
39
|
|
40
40
|
## Install
|
41
41
|
|
42
|
-
`RGeo::GeoJSON`
|
42
|
+
`RGeo::GeoJSON` requires:
|
43
43
|
|
44
|
-
* Ruby 1.
|
45
|
-
* rgeo 0.
|
44
|
+
* Ruby 2.1.0 or later
|
45
|
+
* rgeo 1.0.0 or later
|
46
46
|
|
47
47
|
Include in your bundle:
|
48
48
|
|
@@ -56,7 +56,7 @@ Install `rgeo-geojson` as a gem:
|
|
56
56
|
gem install rgeo-geojson
|
57
57
|
```
|
58
58
|
|
59
|
-
See the README for the
|
59
|
+
See the README for the `rgeo` gem, a required dependency, for further installation information.
|
60
60
|
|
61
61
|
### Development and support
|
62
62
|
|
@@ -72,7 +72,7 @@ Report bugs on Github issues at http://github.com/rgeo/rgeo-geojson/issues
|
|
72
72
|
|
73
73
|
RGeo was created by Daniel Azuma (http://www.daniel-azuma.com).
|
74
74
|
|
75
|
-
Development is supported by [Pirq](http://www.pirq.com) and
|
75
|
+
Development is/was supported by [Pirq](http://www.pirq.com) and
|
76
76
|
[Neighborland](https://neighborland.com).
|
77
77
|
|
78
78
|
### License
|
data/lib/rgeo/geo_json.rb
CHANGED
data/lib/rgeo/geo_json/coder.rb
CHANGED
@@ -20,37 +20,9 @@ module RGeo
|
|
20
20
|
# RGeo::GeoJSON::EntityFactory, which generates objects of type
|
21
21
|
# RGeo::GeoJSON::Feature or RGeo::GeoJSON::FeatureCollection.
|
22
22
|
# See RGeo::GeoJSON::EntityFactory for more information.
|
23
|
-
# [<tt>:json_parser</tt>]
|
24
|
-
# Specifies a JSON parser to use when decoding a String or IO
|
25
|
-
# object. The value may be a Proc object taking the string as the
|
26
|
-
# sole argument and returning the JSON hash, or it may be one of
|
27
|
-
# the special values <tt>:json</tt>, <tt>:yajl</tt>, or
|
28
|
-
# <tt>:active_support</tt>. Setting one of those special values
|
29
|
-
# will require the corresponding library to be available. Note
|
30
|
-
# that the <tt>:json</tt> library is present in the standard
|
31
|
-
# library in Ruby 1.9.
|
32
|
-
# If a parser is not specified, then the decode method will not
|
33
|
-
# accept a String or IO object; it will require a Hash.
|
34
|
-
|
35
23
|
def initialize(opts = {})
|
36
24
|
@geo_factory = opts[:geo_factory] || RGeo::Cartesian.preferred_factory
|
37
25
|
@entity_factory = opts[:entity_factory] || EntityFactory.instance
|
38
|
-
@json_parser = opts[:json_parser]
|
39
|
-
case @json_parser
|
40
|
-
when :json
|
41
|
-
require "json" unless defined?(JSON)
|
42
|
-
@json_parser = proc { |str| JSON.parse(str) }
|
43
|
-
when :yajl
|
44
|
-
require "yajl" unless defined?(Yajl)
|
45
|
-
@json_parser = proc { |str| Yajl::Parser.new.parse(str) }
|
46
|
-
when :active_support
|
47
|
-
require "active_support/json" unless defined?(ActiveSupport::JSON)
|
48
|
-
@json_parser = proc { |str| ActiveSupport::JSON.decode(str) }
|
49
|
-
when Proc, nil
|
50
|
-
# Leave as is
|
51
|
-
else
|
52
|
-
raise ::ArgumentError, "Unrecognzied json_parser: #{@json_parser.inspect}"
|
53
|
-
end
|
54
26
|
@num_coordinates = 2
|
55
27
|
@num_coordinates += 1 if @geo_factory.property(:has_z_coordinate)
|
56
28
|
@num_coordinates += 1 if @geo_factory.property(:has_m_coordinate)
|
@@ -92,7 +64,7 @@ module RGeo
|
|
92
64
|
input = input.read rescue nil
|
93
65
|
end
|
94
66
|
if input.is_a?(String)
|
95
|
-
input =
|
67
|
+
input = JSON.parse(input)
|
96
68
|
end
|
97
69
|
unless input.is_a?(Hash)
|
98
70
|
return nil
|
@@ -124,6 +96,8 @@ module RGeo
|
|
124
96
|
|
125
97
|
attr_reader :entity_factory
|
126
98
|
|
99
|
+
private
|
100
|
+
|
127
101
|
def _encode_feature(object) # :nodoc:
|
128
102
|
json = {
|
129
103
|
"type" => "Feature",
|
@@ -31,18 +31,6 @@ module RGeo
|
|
31
31
|
# RGeo::GeoJSON::EntityFactory, which generates objects of type
|
32
32
|
# RGeo::GeoJSON::Feature or RGeo::GeoJSON::FeatureCollection.
|
33
33
|
# See RGeo::GeoJSON::EntityFactory for more information.
|
34
|
-
# [<tt>:json_parser</tt>]
|
35
|
-
# Specifies a JSON parser to use when decoding a String or IO
|
36
|
-
# object. The value may be a Proc object taking the string as the
|
37
|
-
# sole argument and returning the JSON hash, or it may be one of
|
38
|
-
# the special values <tt>:json</tt>, <tt>:yajl</tt>, or
|
39
|
-
# <tt>:active_support</tt>. Setting one of those special values
|
40
|
-
# will require the corresponding library to be available. Note
|
41
|
-
# that the <tt>:json</tt> library is present in the standard
|
42
|
-
# library in Ruby 1.9, but requires the "json" gem in Ruby 1.8.
|
43
|
-
# If a parser is not specified, then the decode method will not
|
44
|
-
# accept a String or IO object; it will require a Hash.
|
45
|
-
|
46
34
|
def decode(input_, opts = {})
|
47
35
|
Coder.new(opts).decode(input_)
|
48
36
|
end
|
@@ -63,18 +51,6 @@ module RGeo
|
|
63
51
|
# RGeo::GeoJSON::EntityFactory, which generates objects of type
|
64
52
|
# RGeo::GeoJSON::Feature or RGeo::GeoJSON::FeatureCollection.
|
65
53
|
# See RGeo::GeoJSON::EntityFactory for more information.
|
66
|
-
# [<tt>:json_parser</tt>]
|
67
|
-
# Specifies a JSON parser to use when decoding a String or IO
|
68
|
-
# object. The value may be a Proc object taking the string as the
|
69
|
-
# sole argument and returning the JSON hash, or it may be one of
|
70
|
-
# the special values <tt>:json</tt>, <tt>:yajl</tt>, or
|
71
|
-
# <tt>:active_support</tt>. Setting one of those special values
|
72
|
-
# will require the corresponding library to be available. Note
|
73
|
-
# that the <tt>:json</tt> library is present in the standard
|
74
|
-
# library in Ruby 1.9, but requires the "json" gem in Ruby 1.8.
|
75
|
-
# If a parser is not specified, then the decode method will not
|
76
|
-
# accept a String or IO object; it will require a Hash.
|
77
|
-
|
78
54
|
def coder(opts = {})
|
79
55
|
Coder.new(opts)
|
80
56
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rgeo
|
@@ -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.
|
108
|
+
rubygems_version: 2.7.4
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Convert RGeo data to and from GeoJSON.
|