charta 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +2 -2
- data/lib/charta/geometry.rb +81 -51
- data/lib/charta/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27a2e5f7689bcfa650af268dd6a6f0d8a62bdea6cc20fdc3b7e4b372d62205c8
|
4
|
+
data.tar.gz: 39cb1fb8023d04d19e211323987dd2a80231e616e34c81134729e7b7a231fbf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff3edbf296fe4736cd84da7a689ce5e2df6605aa1a181827b80bebc1e9d2131744b25bd491ebc180f946af615de60acba5f2463d2e97f1ab409f3d8fdb0c35fb
|
7
|
+
data.tar.gz: 1c418aba1d2113235ad8886a425a1a8ab49120d1bea3bdfb4dd7d2476b45f4022da4ac7503e67f8a2dd1272182e9d11174f5119b94f02d3eedbc708f92896824
|
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/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,6 +219,7 @@ 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)
|
@@ -203,10 +227,16 @@ module Charta
|
|
203
227
|
feature.intersection(other_geometry.feature)
|
204
228
|
end
|
205
229
|
|
230
|
+
def intersects?(other)
|
231
|
+
other_geometry = Charta.new_geometry(other).transform(srid)
|
232
|
+
feature.intersects?(other_geometry.feature)
|
233
|
+
end
|
234
|
+
|
206
235
|
def difference(other)
|
207
236
|
other_geometry = Charta.new_geometry(other).transform(srid)
|
208
237
|
feature.difference(other_geometry.feature)
|
209
238
|
end
|
239
|
+
|
210
240
|
alias - difference
|
211
241
|
|
212
242
|
def bounding_box
|
@@ -288,52 +318,52 @@ module Charta
|
|
288
318
|
|
289
319
|
private
|
290
320
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
321
|
+
def geos_factory(srid)
|
322
|
+
RGeo::Geos.factory(
|
323
|
+
srid: srid,
|
324
|
+
wkt_generator: {
|
325
|
+
type_format: :ewkt,
|
326
|
+
emit_ewkt_srid: true,
|
327
|
+
convert_case: :upper
|
328
|
+
},
|
329
|
+
wkt_parser: {
|
330
|
+
support_ewkt: true
|
331
|
+
},
|
332
|
+
wkb_generator: {
|
333
|
+
type_format: :ewkb,
|
334
|
+
emit_ewkb_srid: true,
|
335
|
+
hex_format: true
|
336
|
+
},
|
337
|
+
wkb_parser: {
|
338
|
+
support_ewkb: true
|
339
|
+
}
|
340
|
+
)
|
341
|
+
end
|
312
342
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
343
|
+
def projected_factory(srid)
|
344
|
+
proj4 = '+proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'
|
345
|
+
RGeo::Geographic.projected_factory(
|
346
|
+
srid: srid,
|
347
|
+
wkt_generator: {
|
348
|
+
type_format: :ewkt,
|
349
|
+
emit_ewkt_srid: true,
|
350
|
+
convert_case: :upper
|
351
|
+
},
|
352
|
+
wkt_parser: {
|
353
|
+
support_ewkt: true
|
354
|
+
},
|
355
|
+
wkb_generator: {
|
356
|
+
type_format: :ewkb,
|
357
|
+
emit_ewkb_srid: true,
|
358
|
+
hex_format: true
|
359
|
+
},
|
360
|
+
wkb_parser: {
|
361
|
+
support_ewkb: true
|
362
|
+
},
|
363
|
+
projection_srid: 6933,
|
364
|
+
projection_proj4: proj4
|
365
|
+
)
|
366
|
+
end
|
337
367
|
end
|
338
368
|
end
|
339
369
|
end
|
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.16
|
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-09-08 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,8 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
rubygems_version: 3.0.
|
178
|
-
signing_key:
|
177
|
+
rubygems_version: 3.0.3
|
178
|
+
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Simple tool over geos and co
|
181
181
|
test_files: []
|