charta 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitlab-ci.yml +14 -0
- data/charta.gemspec +5 -5
- data/lib/charta/geometry.rb +71 -59
- data/lib/charta/version.rb +1 -1
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e1a6955069e9535ef7d8b3b7e72a38902f161a5c040a6ba3e86ebf010ddcf7c
|
4
|
+
data.tar.gz: c413fb93fdb9ccf1328b58d7a721a1eca54c219e5ca54bc61066df2a4ccce1ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4457d1afc0c7289e3748a07a95b9422e797edee230447bb90bfa6423614dc9133f330aab1acb8be0a485b8de4172673933c3d7c493602a29422053d45435f12
|
7
|
+
data.tar.gz: 33942453f7c1863b13b2011a05923ffcdeae0098899ea50bd8ee7b012be3a135564d95b030bc781aedaca57237fa4f8ffd5e1701010e73f4169dc8ec3699ed2e
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
stages:
|
2
|
+
- test
|
3
|
+
|
4
|
+
test:
|
5
|
+
image: registry.gitlab.com/ekylibre/docker-base-images/ruby2.3:master
|
6
|
+
before_script:
|
7
|
+
- gem install bundler
|
8
|
+
- bundle install --path vendor/bundle
|
9
|
+
cache:
|
10
|
+
key: bundle
|
11
|
+
paths:
|
12
|
+
- vendor/bundle
|
13
|
+
script:
|
14
|
+
- bundle exec rake test
|
data/charta.gemspec
CHANGED
@@ -18,12 +18,12 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_dependency 'nokogiri', '>= 1.7.0'
|
21
|
-
spec.add_dependency 'rgeo', '~> 1.0
|
21
|
+
spec.add_dependency 'rgeo', '~> 1.0'
|
22
22
|
spec.add_dependency 'json', '>= 1.8.0'
|
23
|
-
spec.add_dependency 'rgeo-geojson', '~> 1.0
|
24
|
-
spec.add_dependency 'rgeo-proj4', '~> 1.0
|
25
|
-
spec.add_dependency 'activesupport', '
|
26
|
-
spec.add_development_dependency 'bundler', '~>
|
23
|
+
spec.add_dependency 'rgeo-geojson', '~> 1.0'
|
24
|
+
spec.add_dependency 'rgeo-proj4', '~> 1.0'
|
25
|
+
spec.add_dependency 'activesupport', '~> 5.0'
|
26
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
27
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
28
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
29
29
|
spec.add_development_dependency 'byebug'
|
data/lib/charta/geometry.rb
CHANGED
@@ -6,8 +6,6 @@ require 'active_support/core_ext/module/delegation'
|
|
6
6
|
module Charta
|
7
7
|
# Represents a Geometry with SRID
|
8
8
|
class Geometry
|
9
|
-
delegate_missing_to :to_rgeo
|
10
|
-
|
11
9
|
def initialize(feature, properties = {})
|
12
10
|
self.feature = feature
|
13
11
|
@properties = properties
|
@@ -36,16 +34,12 @@ module Charta
|
|
36
34
|
feature.srid.to_i
|
37
35
|
end
|
38
36
|
|
39
|
-
# Returns the underlaying object managed by Charta: the RGeo feature
|
40
|
-
def to_rgeo
|
41
|
-
feature
|
42
|
-
end
|
43
|
-
|
44
37
|
# Returns the Well-Known Text (WKT) representation of the geometry/geography
|
45
38
|
# without SRID metadata
|
46
39
|
def to_text
|
47
40
|
feature.as_text.match(/\ASRID=.*;(.*)/)[1]
|
48
41
|
end
|
42
|
+
|
49
43
|
alias as_text to_text
|
50
44
|
alias to_wkt to_text
|
51
45
|
|
@@ -53,6 +47,7 @@ module Charta
|
|
53
47
|
def to_ewkt
|
54
48
|
Charta.generate_ewkt(feature).to_s
|
55
49
|
end
|
50
|
+
|
56
51
|
alias to_s to_ewkt
|
57
52
|
|
58
53
|
def ewkt
|
@@ -65,6 +60,7 @@ module Charta
|
|
65
60
|
generator = RGeo::WKRep::WKBGenerator.new(tag_format: :ewkbt, emit_ewkbt_srid: true)
|
66
61
|
generator.generate(feature)
|
67
62
|
end
|
63
|
+
|
68
64
|
alias to_ewkb to_binary
|
69
65
|
|
70
66
|
# Pas bien compris le fonctionnement
|
@@ -88,6 +84,7 @@ module Charta
|
|
88
84
|
def to_geojson
|
89
85
|
to_json_object.to_json
|
90
86
|
end
|
87
|
+
|
91
88
|
alias to_json to_geojson
|
92
89
|
|
93
90
|
# Returns object in JSON (Hash)
|
@@ -126,6 +123,7 @@ module Charta
|
|
126
123
|
def empty?
|
127
124
|
feature.is_empty?
|
128
125
|
end
|
126
|
+
|
129
127
|
alias blank? empty?
|
130
128
|
|
131
129
|
# Computes the geometric center of a geometry, or equivalently, the center
|
@@ -199,6 +197,7 @@ module Charta
|
|
199
197
|
other_geometry = Charta.new_geometry(other).transform(srid)
|
200
198
|
feature.union(other_geometry.feature)
|
201
199
|
end
|
200
|
+
|
202
201
|
alias + merge
|
203
202
|
|
204
203
|
def intersection(other)
|
@@ -210,6 +209,7 @@ module Charta
|
|
210
209
|
other_geometry = Charta.new_geometry(other).transform(srid)
|
211
210
|
feature.difference(other_geometry.feature)
|
212
211
|
end
|
212
|
+
|
213
213
|
alias - difference
|
214
214
|
|
215
215
|
def bounding_box
|
@@ -234,8 +234,7 @@ module Charta
|
|
234
234
|
Charta.find_srid(name_or_srid)
|
235
235
|
end
|
236
236
|
|
237
|
-
#
|
238
|
-
# serialization in time.
|
237
|
+
# Returns the underlaying object managed by Charta: the RGeo feature
|
239
238
|
def feature
|
240
239
|
unless defined? @feature
|
241
240
|
if defined? @ewkt
|
@@ -248,6 +247,8 @@ module Charta
|
|
248
247
|
@feature.dup
|
249
248
|
end
|
250
249
|
|
250
|
+
alias to_rgeo feature
|
251
|
+
|
251
252
|
def feature=(new_feature)
|
252
253
|
raise ArgumentError, "Feature can't be nil" if new_feature.nil?
|
253
254
|
@feature = new_feature
|
@@ -279,7 +280,7 @@ module Charta
|
|
279
280
|
|
280
281
|
def from_ewkt(ewkt)
|
281
282
|
# Cleans empty geometries
|
282
|
-
ewkt.gsub
|
283
|
+
ewkt = ewkt.gsub(/(GEOMETRYCOLLECTION|GEOMETRY|((MULTI)?(POINT|LINESTRING|POLYGON)))\(\)/, '\1 EMPTY')
|
283
284
|
srs = ewkt.split(/[\=\;]+/)[0..1]
|
284
285
|
srid = nil
|
285
286
|
srid = srs[1] if srs[0] =~ /srid/i
|
@@ -291,57 +292,68 @@ module Charta
|
|
291
292
|
|
292
293
|
private
|
293
294
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
295
|
+
def geos_factory(srid)
|
296
|
+
RGeo::Geos.factory(
|
297
|
+
srid: srid,
|
298
|
+
wkt_generator: {
|
299
|
+
type_format: :ewkt,
|
300
|
+
emit_ewkt_srid: true,
|
301
|
+
convert_case: :upper
|
302
|
+
},
|
303
|
+
wkt_parser: {
|
304
|
+
support_ewkt: true
|
305
|
+
},
|
306
|
+
wkb_generator: {
|
307
|
+
type_format: :ewkb,
|
308
|
+
emit_ewkb_srid: true,
|
309
|
+
hex_format: true
|
310
|
+
},
|
311
|
+
wkb_parser: {
|
312
|
+
support_ewkb: true
|
313
|
+
}
|
314
|
+
)
|
315
|
+
end
|
315
316
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
317
|
+
def projected_factory(srid)
|
318
|
+
proj4 = '+proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'
|
319
|
+
RGeo::Geographic.projected_factory(
|
320
|
+
srid: srid,
|
321
|
+
wkt_generator: {
|
322
|
+
type_format: :ewkt,
|
323
|
+
emit_ewkt_srid: true,
|
324
|
+
convert_case: :upper
|
325
|
+
},
|
326
|
+
wkt_parser: {
|
327
|
+
support_ewkt: true
|
328
|
+
},
|
329
|
+
wkb_generator: {
|
330
|
+
type_format: :ewkb,
|
331
|
+
emit_ewkb_srid: true,
|
332
|
+
hex_format: true
|
333
|
+
},
|
334
|
+
wkb_parser: {
|
335
|
+
support_ewkb: true
|
336
|
+
},
|
337
|
+
projection_srid: 6933,
|
338
|
+
projection_proj4: proj4
|
339
|
+
)
|
340
|
+
end
|
341
|
+
|
342
|
+
def method_missing(name, *args, &block)
|
343
|
+
target = to_rgeo
|
344
|
+
if target.respond_to? name
|
345
|
+
target.send name, *args
|
346
|
+
else
|
347
|
+
raise StandardError.new("Method #{name} does not exist for #{self.class.name}")
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
def respond_to_missing?(name, include_private = false)
|
352
|
+
return false if name == :init_with
|
353
|
+
return true if to_rgeo.respond_to? name, include_private
|
354
|
+
super
|
355
|
+
end
|
341
356
|
|
342
|
-
def respond_to_missing?(name, include_private = false)
|
343
|
-
return false if name == :init_with
|
344
|
-
super
|
345
357
|
end
|
346
358
|
end
|
347
359
|
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice TEXIER
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,56 +58,56 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0
|
61
|
+
version: '1.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0
|
68
|
+
version: '1.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rgeo-proj4
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0
|
75
|
+
version: '1.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: activesupport
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '5.
|
89
|
+
version: '5.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '5.
|
96
|
+
version: '5.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '2.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '2.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,6 +158,7 @@ extensions: []
|
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
160
|
- ".gitignore"
|
161
|
+
- ".gitlab-ci.yml"
|
161
162
|
- ".travis.yml"
|
162
163
|
- CODE_OF_CONDUCT.md
|
163
164
|
- Gemfile
|
@@ -199,8 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
200
|
- !ruby/object:Gem::Version
|
200
201
|
version: '0'
|
201
202
|
requirements: []
|
202
|
-
|
203
|
-
rubygems_version: 2.6.14
|
203
|
+
rubygems_version: 3.0.1
|
204
204
|
signing_key:
|
205
205
|
specification_version: 4
|
206
206
|
summary: Simple tool over geos and co
|