terraformer 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/terraformer.rb +2 -1
- data/lib/terraformer/circle.rb +1 -1
- data/lib/terraformer/version.rb +1 -1
- data/test/examples/cascadiagons.geojson +154 -0
- data/test/terraformer_spec.rb +19 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94f290a9625b7c0820cf1489bc822ec82f24243d
|
4
|
+
data.tar.gz: 8ccdb74b6538360ca45f7af6bc2e6c5ba84cdcd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21a14a49544eb19c39f96f6d7a8061f060600985b0e15820dcb06aa5f99ad9ea9036140400906139855acc2050120d32186774c249235b062a267cce252d302e
|
7
|
+
data.tar.gz: a98fe28abc34063e50b8b269c3cf4c0a83ceb7a9613f11d7b05761cdeb902cc937b6b123c4c8b2bacfa1d45e719ce0cb2bb04b7251616dcfa8128bc0dae1c559
|
data/.gitignore
CHANGED
data/lib/terraformer.rb
CHANGED
@@ -45,7 +45,7 @@ module Terraformer
|
|
45
45
|
# is determined by +type+ property.
|
46
46
|
#
|
47
47
|
def self.parse geojson
|
48
|
-
if String
|
48
|
+
if geojson.is_a?(String) or geojson.respond_to?(:read)
|
49
49
|
geojson = File.read geojson if File.readable? geojson
|
50
50
|
geojson = JSON.parse geojson
|
51
51
|
end
|
@@ -62,6 +62,7 @@ module Terraformer
|
|
62
62
|
#
|
63
63
|
def self.geojson_io data
|
64
64
|
require 'launchy'
|
65
|
+
require 'uri'
|
65
66
|
Launchy.open "http://geojson.io/#data=data:application/json,#{URI.encode_www_form_component data.to_json}"
|
66
67
|
end
|
67
68
|
|
data/lib/terraformer/circle.rb
CHANGED
@@ -4,7 +4,7 @@ module Terraformer
|
|
4
4
|
|
5
5
|
attr_accessor :polygon
|
6
6
|
attr_reader :center, :radius, :resolution
|
7
|
-
def_delegators :@polygon, :contains?, :within?, :intersects?, :to_feature, :to_json, :to_hash
|
7
|
+
def_delegators :@polygon, :bbox, :contains?, :within?, :intersects?, :to_feature, :to_json, :to_hash
|
8
8
|
|
9
9
|
def initialize c, r, res = DEFAULT_BUFFER_RESOLUTION
|
10
10
|
self.center = c
|
data/lib/terraformer/version.rb
CHANGED
@@ -0,0 +1,154 @@
|
|
1
|
+
{
|
2
|
+
"type": "FeatureCollection",
|
3
|
+
"features": [
|
4
|
+
{
|
5
|
+
"type": "Feature",
|
6
|
+
"properties": {},
|
7
|
+
"geometry": {
|
8
|
+
"type": "Polygon",
|
9
|
+
"coordinates": [
|
10
|
+
[
|
11
|
+
[
|
12
|
+
-123.46435546875,
|
13
|
+
48.58932584966972
|
14
|
+
],
|
15
|
+
[
|
16
|
+
-125.39794921875,
|
17
|
+
47.204642388766935
|
18
|
+
],
|
19
|
+
[
|
20
|
+
-125.17822265625,
|
21
|
+
43.46886761482923
|
22
|
+
],
|
23
|
+
[
|
24
|
+
-120.78369140624999,
|
25
|
+
41.96765920367816
|
26
|
+
],
|
27
|
+
[
|
28
|
+
-117.42187500000001,
|
29
|
+
44.43377984606825
|
30
|
+
],
|
31
|
+
[
|
32
|
+
-117.22412109375,
|
33
|
+
46.46813299215554
|
34
|
+
],
|
35
|
+
[
|
36
|
+
-119.99267578124999,
|
37
|
+
48.48748647988415
|
38
|
+
],
|
39
|
+
[
|
40
|
+
-123.46435546875,
|
41
|
+
48.58932584966972
|
42
|
+
]
|
43
|
+
]
|
44
|
+
]
|
45
|
+
}
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"type": "Feature",
|
49
|
+
"properties": {},
|
50
|
+
"geometry": {
|
51
|
+
"type": "Polygon",
|
52
|
+
"coordinates": [
|
53
|
+
[
|
54
|
+
[
|
55
|
+
-118.21289062499999,
|
56
|
+
47.88688085106898
|
57
|
+
],
|
58
|
+
[
|
59
|
+
-121.728515625,
|
60
|
+
46.27103747280261
|
61
|
+
],
|
62
|
+
[
|
63
|
+
-121.04736328125,
|
64
|
+
44.040218713142146
|
65
|
+
],
|
66
|
+
[
|
67
|
+
-117.90527343750001,
|
68
|
+
42.601619944327965
|
69
|
+
],
|
70
|
+
[
|
71
|
+
-114.80712890625,
|
72
|
+
44.98034238084973
|
73
|
+
],
|
74
|
+
[
|
75
|
+
-118.21289062499999,
|
76
|
+
47.88688085106898
|
77
|
+
]
|
78
|
+
]
|
79
|
+
]
|
80
|
+
}
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"type": "Feature",
|
84
|
+
"properties": {},
|
85
|
+
"geometry": {
|
86
|
+
"type": "Polygon",
|
87
|
+
"coordinates": [
|
88
|
+
[
|
89
|
+
[
|
90
|
+
-120.89355468749999,
|
91
|
+
46.22545288226939
|
92
|
+
],
|
93
|
+
[
|
94
|
+
-120.69580078125001,
|
95
|
+
44.88701247981298
|
96
|
+
],
|
97
|
+
[
|
98
|
+
-119.35546875000001,
|
99
|
+
44.69989765840321
|
100
|
+
],
|
101
|
+
[
|
102
|
+
-118.71826171875,
|
103
|
+
45.24395342262324
|
104
|
+
],
|
105
|
+
[
|
106
|
+
-118.564453125,
|
107
|
+
45.920587344733654
|
108
|
+
],
|
109
|
+
[
|
110
|
+
-118.30078125,
|
111
|
+
45.259422036351694
|
112
|
+
],
|
113
|
+
[
|
114
|
+
-117.99316406249999,
|
115
|
+
45.460130637921004
|
116
|
+
],
|
117
|
+
[
|
118
|
+
-117.94921874999999,
|
119
|
+
45.72152152227954
|
120
|
+
],
|
121
|
+
[
|
122
|
+
-117.68554687499999,
|
123
|
+
46.31658418182218
|
124
|
+
],
|
125
|
+
[
|
126
|
+
-118.30078125,
|
127
|
+
46.619261036171515
|
128
|
+
],
|
129
|
+
[
|
130
|
+
-119.20166015625,
|
131
|
+
45.96642454131025
|
132
|
+
],
|
133
|
+
[
|
134
|
+
-119.46533203125,
|
135
|
+
46.58906908309182
|
136
|
+
],
|
137
|
+
[
|
138
|
+
-119.72900390625001,
|
139
|
+
46.01222384063236
|
140
|
+
],
|
141
|
+
[
|
142
|
+
-119.90478515625,
|
143
|
+
46.76996843356982
|
144
|
+
],
|
145
|
+
[
|
146
|
+
-120.89355468749999,
|
147
|
+
46.22545288226939
|
148
|
+
]
|
149
|
+
]
|
150
|
+
]
|
151
|
+
}
|
152
|
+
}
|
153
|
+
]
|
154
|
+
}
|
data/test/terraformer_spec.rb
CHANGED
@@ -54,6 +54,25 @@ describe Terraformer do
|
|
54
54
|
p.coordinates[1][1].must_equal Terraformer::Coordinate.new 103, 3
|
55
55
|
end
|
56
56
|
|
57
|
+
it 'parses geojson files' do
|
58
|
+
file = File.open('test/examples/point.geojson')
|
59
|
+
p = Terraformer.parse file
|
60
|
+
p.dont_be_terrible_ok
|
61
|
+
p.type.must_equal 'Point'
|
62
|
+
p.coordinates.must_be_instance_of Terraformer::Coordinate
|
63
|
+
p.coordinates.must_equal Terraformer::Coordinate.new 100, 0
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'parses the target of a Pathname' do
|
67
|
+
require "pathname"
|
68
|
+
path = Pathname.new('test/examples/point.geojson')
|
69
|
+
p = Terraformer.parse path
|
70
|
+
p.dont_be_terrible_ok
|
71
|
+
p.type.must_equal 'Point'
|
72
|
+
p.coordinates.must_be_instance_of Terraformer::Coordinate
|
73
|
+
p.coordinates.must_equal Terraformer::Coordinate.new 100, 0
|
74
|
+
end
|
75
|
+
|
57
76
|
it 'parses polygons' do
|
58
77
|
p = Terraformer.parse EXAMPLES[:polygon]
|
59
78
|
p.dont_be_terrible_ok
|
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.9
|
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-
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: launchy
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- terraformer.gemspec
|
61
61
|
- test/arcgis_spec.rb
|
62
62
|
- test/convex_hull_spec.rb
|
63
|
+
- test/examples/cascadiagons.geojson
|
63
64
|
- test/examples/circle.geojson
|
64
65
|
- test/examples/geometry_collection.geojson
|
65
66
|
- test/examples/line_string.geojson
|
@@ -95,13 +96,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
version: '0'
|
96
97
|
requirements: []
|
97
98
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.4.
|
99
|
+
rubygems_version: 2.4.5
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: ''
|
102
103
|
test_files:
|
103
104
|
- test/arcgis_spec.rb
|
104
105
|
- test/convex_hull_spec.rb
|
106
|
+
- test/examples/cascadiagons.geojson
|
105
107
|
- test/examples/circle.geojson
|
106
108
|
- test/examples/geometry_collection.geojson
|
107
109
|
- test/examples/line_string.geojson
|