charta 0.1.13 → 0.1.18
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 +5 -5
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +2 -2
- data/lib/charta.rb +2 -0
- data/lib/charta/bounding_box.rb +4 -0
- data/lib/charta/coordinates.rb +2 -2
- data/lib/charta/geometry.rb +83 -52
- data/lib/charta/point.rb +5 -0
- data/lib/charta/polygon.rb +5 -0
- data/lib/charta/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 305d47070fc660134d7a4bed344db7efb555c9729a30e771af105a263c6aee01
|
4
|
+
data.tar.gz: 4cfab59ae1d9f4034eb066bcf05e3a4c49b117604879e3e1e282a50e2c234f64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cc82941e2062fa2309c294dc02b912528faf4a4893b34ee4a719a62ecd77422a1ff97d7c0255246dc4b9b014b2839bff6f7169e38d4be78cbb883d83352c26d
|
7
|
+
data.tar.gz: 2193fbd5aa27ddca33cbd4ef3257168d2c567d1b8e4eb3def8ae2bcaed05e22aaeb82e8f6a17640955a7d92ff38835ab2d41a4f7f1e8dd01193db9fdab8dc31d
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
@@ -2,7 +2,7 @@ stages:
|
|
2
2
|
- test
|
3
3
|
|
4
4
|
test:
|
5
|
-
image: registry.gitlab.com/ekylibre/docker-base-images/ruby2.3:
|
5
|
+
image: registry.gitlab.com/ekylibre/docker-base-images/ruby2.3:1
|
6
6
|
before_script:
|
7
7
|
- bundle install --path vendor/bundle
|
8
8
|
cache:
|
@@ -10,4 +10,4 @@ test:
|
|
10
10
|
paths:
|
11
11
|
- vendor/bundle
|
12
12
|
script:
|
13
|
-
- bundle exec rake test
|
13
|
+
- bundle exec rake test
|
data/lib/charta.rb
CHANGED
data/lib/charta/bounding_box.rb
CHANGED
data/lib/charta/coordinates.rb
CHANGED
@@ -20,7 +20,7 @@ module Charta
|
|
20
20
|
|
21
21
|
def normalize_4326_geometry(json)
|
22
22
|
map_coordinates json do |(x, y)|
|
23
|
-
[((x + 180) % 360) - 180, ((y + 90) % 180) - 90]
|
23
|
+
[((x + 180.to_d) % 360.to_d) - 180.to_d, ((y + 90.to_d) % 180.to_d) - 90.to_d]
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -58,7 +58,7 @@ module Charta
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def map_geometry_collection_coordinates(hash, &block)
|
61
|
-
hash.merge 'geometries' =>
|
61
|
+
hash.merge 'geometries' => hash['geometries'].map { |geometry| map_geometry_coordinates(geometry, &block) }
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/lib/charta/geometry.rb
CHANGED
@@ -43,6 +43,7 @@ module Charta
|
|
43
43
|
def to_text
|
44
44
|
feature.as_text.match(/\ASRID=.*;(.*)/)[1]
|
45
45
|
end
|
46
|
+
|
46
47
|
alias as_text to_text
|
47
48
|
alias to_wkt to_text
|
48
49
|
|
@@ -50,6 +51,7 @@ module Charta
|
|
50
51
|
def to_ewkt
|
51
52
|
Charta.generate_ewkt(feature).to_s
|
52
53
|
end
|
54
|
+
|
53
55
|
alias to_s to_ewkt
|
54
56
|
|
55
57
|
def ewkt
|
@@ -62,6 +64,7 @@ module Charta
|
|
62
64
|
generator = RGeo::WKRep::WKBGenerator.new(tag_format: :ewkbt, emit_ewkbt_srid: true)
|
63
65
|
generator.generate(feature)
|
64
66
|
end
|
67
|
+
|
65
68
|
alias to_ewkb to_binary
|
66
69
|
|
67
70
|
# Pas bien compris le fonctionnement
|
@@ -85,6 +88,7 @@ module Charta
|
|
85
88
|
def to_geojson
|
86
89
|
to_json_object.to_json
|
87
90
|
end
|
91
|
+
|
88
92
|
alias to_json to_geojson
|
89
93
|
|
90
94
|
# Returns object in JSON (Hash)
|
@@ -110,12 +114,24 @@ module Charta
|
|
110
114
|
|
111
115
|
# Returns true if Geometry is a Surface
|
112
116
|
def surface?
|
113
|
-
|
117
|
+
if collection?
|
118
|
+
feature.any? { |geometry| Charta.new_geometry(geometry).surface? }
|
119
|
+
else
|
120
|
+
[RGeo::Feature::Polygon, RGeo::Feature::MultiPolygon].include? feature.geometry_type
|
121
|
+
end
|
114
122
|
end
|
115
123
|
|
116
124
|
# Returns area in unit corresponding to the SRS
|
117
125
|
def area
|
118
|
-
surface?
|
126
|
+
if surface?
|
127
|
+
if collection?
|
128
|
+
feature.sum { |geometry| Charta.new_geometry(geometry).area }
|
129
|
+
else
|
130
|
+
feature.area
|
131
|
+
end
|
132
|
+
else
|
133
|
+
0
|
134
|
+
end
|
119
135
|
end
|
120
136
|
|
121
137
|
# Returns true if this Geometry is an empty geometrycollection, polygon,
|
@@ -123,6 +139,7 @@ module Charta
|
|
123
139
|
def empty?
|
124
140
|
feature.is_empty?
|
125
141
|
end
|
142
|
+
|
126
143
|
alias blank? empty?
|
127
144
|
|
128
145
|
# Computes the geometric center of a geometry, or equivalently, the center
|
@@ -142,10 +159,16 @@ module Charta
|
|
142
159
|
|
143
160
|
def convert_to(new_type)
|
144
161
|
case new_type
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
162
|
+
when type then
|
163
|
+
self
|
164
|
+
when :multi_point then
|
165
|
+
flatten_multi(:point)
|
166
|
+
when :multi_line_string then
|
167
|
+
flatten_multi(:line_string)
|
168
|
+
when :multi_polygon then
|
169
|
+
flatten_multi(:polygon)
|
170
|
+
else
|
171
|
+
self
|
149
172
|
end
|
150
173
|
end
|
151
174
|
|
@@ -196,17 +219,25 @@ module Charta
|
|
196
219
|
other_geometry = Charta.new_geometry(other).transform(srid)
|
197
220
|
feature.union(other_geometry.feature)
|
198
221
|
end
|
222
|
+
|
199
223
|
alias + merge
|
200
224
|
|
201
225
|
def intersection(other)
|
202
226
|
other_geometry = Charta.new_geometry(other).transform(srid)
|
203
|
-
|
227
|
+
|
228
|
+
Charta.new_geometry(feature.intersection(other_geometry.feature))
|
229
|
+
end
|
230
|
+
|
231
|
+
def intersects?(other)
|
232
|
+
other_geometry = Charta.new_geometry(other).transform(srid)
|
233
|
+
feature.intersects?(other_geometry.feature)
|
204
234
|
end
|
205
235
|
|
206
236
|
def difference(other)
|
207
237
|
other_geometry = Charta.new_geometry(other).transform(srid)
|
208
238
|
feature.difference(other_geometry.feature)
|
209
239
|
end
|
240
|
+
|
210
241
|
alias - difference
|
211
242
|
|
212
243
|
def bounding_box
|
@@ -288,52 +319,52 @@ module Charta
|
|
288
319
|
|
289
320
|
private
|
290
321
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
322
|
+
def geos_factory(srid)
|
323
|
+
RGeo::Geos.factory(
|
324
|
+
srid: srid,
|
325
|
+
wkt_generator: {
|
326
|
+
type_format: :ewkt,
|
327
|
+
emit_ewkt_srid: true,
|
328
|
+
convert_case: :upper
|
329
|
+
},
|
330
|
+
wkt_parser: {
|
331
|
+
support_ewkt: true
|
332
|
+
},
|
333
|
+
wkb_generator: {
|
334
|
+
type_format: :ewkb,
|
335
|
+
emit_ewkb_srid: true,
|
336
|
+
hex_format: true
|
337
|
+
},
|
338
|
+
wkb_parser: {
|
339
|
+
support_ewkb: true
|
340
|
+
}
|
341
|
+
)
|
342
|
+
end
|
312
343
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
344
|
+
def projected_factory(srid)
|
345
|
+
proj4 = '+proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'
|
346
|
+
RGeo::Geographic.projected_factory(
|
347
|
+
srid: srid,
|
348
|
+
wkt_generator: {
|
349
|
+
type_format: :ewkt,
|
350
|
+
emit_ewkt_srid: true,
|
351
|
+
convert_case: :upper
|
352
|
+
},
|
353
|
+
wkt_parser: {
|
354
|
+
support_ewkt: true
|
355
|
+
},
|
356
|
+
wkb_generator: {
|
357
|
+
type_format: :ewkb,
|
358
|
+
emit_ewkb_srid: true,
|
359
|
+
hex_format: true
|
360
|
+
},
|
361
|
+
wkb_parser: {
|
362
|
+
support_ewkb: true
|
363
|
+
},
|
364
|
+
projection_srid: 6933,
|
365
|
+
projection_proj4: proj4
|
366
|
+
)
|
367
|
+
end
|
337
368
|
end
|
338
369
|
end
|
339
370
|
end
|
data/lib/charta/point.rb
CHANGED
data/lib/charta/polygon.rb
CHANGED
data/lib/charta/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: charta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice TEXIER
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description:
|
125
|
+
description:
|
126
126
|
email:
|
127
127
|
- brice@ekylibre.com
|
128
128
|
executables: []
|
@@ -159,7 +159,7 @@ homepage: https://github.com/ekylibre/charta
|
|
159
159
|
licenses:
|
160
160
|
- MIT
|
161
161
|
metadata: {}
|
162
|
-
post_install_message:
|
162
|
+
post_install_message:
|
163
163
|
rdoc_options: []
|
164
164
|
require_paths:
|
165
165
|
- lib
|
@@ -174,9 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
|
178
|
-
|
179
|
-
signing_key:
|
177
|
+
rubygems_version: 3.0.3
|
178
|
+
signing_key:
|
180
179
|
specification_version: 4
|
181
180
|
summary: Simple tool over geos and co
|
182
181
|
test_files: []
|