charta 0.1.12 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +13 -0
- data/lib/charta.rb +4 -0
- data/lib/charta/bounding_box.rb +4 -0
- data/lib/charta/coordinates.rb +65 -0
- data/lib/charta/ewkt_serializer.rb +92 -0
- data/lib/charta/geo_json.rb +9 -124
- data/lib/charta/geometry.rb +81 -51
- data/lib/charta/point.rb +5 -0
- data/lib/charta/polygon.rb +5 -0
- data/lib/charta/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3bdf87fdffb17cf24b38fb76b86d84593bc3f6ca0d0d3e8ffcf5df3d76d3db1f
|
4
|
+
data.tar.gz: bda9a9fd027f0bfdb514a7de6e92429977dc55e5fe7db38c27f6a59a871df875
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a808aff9f3da978cd293d0084e9c2a61c7a414fe259ca71821ed195afc50f57e99b7d352e0651723dfa7379d70881dfbf01c4d2959e5602c121e94a78bf14b90
|
7
|
+
data.tar.gz: 54a3e3e081602b978bd4b60d9c8bbbf894d22e14b501715f34278ba48c4ee76489b29b92f2f51419ccb311cd046f9871865240565385b6f5848a63a2b257b09c
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
ADDED
data/lib/charta.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Gathers geomatic calculations
|
2
2
|
# Completes RGeo
|
3
|
+
require 'bigdecimal'
|
4
|
+
require 'bigdecimal/util'
|
3
5
|
require 'rgeo'
|
6
|
+
require 'charta/coordinates'
|
7
|
+
require 'charta/ewkt_serializer'
|
4
8
|
require 'charta/geometry'
|
5
9
|
require 'charta/geometry_collection'
|
6
10
|
require 'charta/point'
|
data/lib/charta/bounding_box.rb
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
module Charta
|
2
|
+
module Coordinates
|
3
|
+
class << self
|
4
|
+
|
5
|
+
# Force coordinates to 2D
|
6
|
+
def flatten(hash)
|
7
|
+
map_coordinates(hash) { |position| position[0..1] }
|
8
|
+
end
|
9
|
+
|
10
|
+
def map_coordinates(hash, &block)
|
11
|
+
case hash['type']
|
12
|
+
when 'FeatureCollection'
|
13
|
+
map_feature_collection_coordinates hash, &block
|
14
|
+
when 'Feature'
|
15
|
+
map_feature_coordinates hash, &block
|
16
|
+
else
|
17
|
+
map_geometry_coordinates hash, &block
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def normalize_4326_geometry(json)
|
22
|
+
map_coordinates json do |(x, y)|
|
23
|
+
[((x + 180.to_d) % 360.to_d) - 180.to_d, ((y + 90.to_d) % 180.to_d) - 90.to_d]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def map_feature_collection_coordinates(hash, &block)
|
30
|
+
hash.merge 'features' => hash['features'].map { |feature| map_feature_coordinates feature, &block }
|
31
|
+
end
|
32
|
+
|
33
|
+
def map_feature_coordinates(hash, &block)
|
34
|
+
hash.merge 'geometry' => map_geometry_coordinates(hash['geometry'], &block)
|
35
|
+
end
|
36
|
+
|
37
|
+
def map_geometry_coordinates(hash, &block)
|
38
|
+
if hash['type'] == 'GeometryCollection'
|
39
|
+
map_geometry_collection_coordinates hash, &block
|
40
|
+
else
|
41
|
+
coordinates = hash['coordinates']
|
42
|
+
mapped =
|
43
|
+
case hash['type']
|
44
|
+
when 'Point' then
|
45
|
+
block.call coordinates
|
46
|
+
when 'MultiPoint', 'LineString'
|
47
|
+
coordinates.map(&block)
|
48
|
+
when 'MultiLineString', 'Polygon'
|
49
|
+
coordinates.map { |line| line.map(&block) }
|
50
|
+
when 'MultiPolygon'
|
51
|
+
coordinates.map { |poly| poly.map { |line| line.map(&block) } }
|
52
|
+
else
|
53
|
+
raise StandardError, "Cannot handle: #{hash['type'].inspect}. In #{hash.inspect}"
|
54
|
+
end
|
55
|
+
|
56
|
+
hash.merge 'coordinates' => mapped
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def map_geometry_collection_coordinates(hash, &block)
|
61
|
+
hash.merge 'geometries' => hash['geometries'].map { |geometry| map_geometry_coordinates(geometry, &block) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Charta
|
2
|
+
module EwktSerializer
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def object_to_ewkt(hash)
|
6
|
+
type = hash[:type] || hash['type']
|
7
|
+
send("#{type.gsub(/(.)([A-Z])/, '\1_\2').downcase}_to_ewkt", hash)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def feature_collection_to_ewkt(hash)
|
13
|
+
return 'GEOMETRYCOLLECTION EMPTY' if hash['features'].nil?
|
14
|
+
'GEOMETRYCOLLECTION(' + hash['features'].collect do |feature|
|
15
|
+
object_to_ewkt(feature)
|
16
|
+
end.join(', ') + ')'
|
17
|
+
end
|
18
|
+
|
19
|
+
def geometry_collection_to_ewkt(hash)
|
20
|
+
return 'GEOMETRYCOLLECTION EMPTY' if hash['geometries'].nil?
|
21
|
+
'GEOMETRYCOLLECTION(' + hash['geometries'].collect do |feature|
|
22
|
+
object_to_ewkt(feature)
|
23
|
+
end.join(', ') + ')'
|
24
|
+
end
|
25
|
+
|
26
|
+
def feature_to_ewkt(hash)
|
27
|
+
object_to_ewkt(hash['geometry'])
|
28
|
+
end
|
29
|
+
|
30
|
+
def point_to_ewkt(hash)
|
31
|
+
return 'POINT EMPTY' if hash['coordinates'].nil?
|
32
|
+
'POINT(' + hash['coordinates'].join(' ') + ')'
|
33
|
+
end
|
34
|
+
|
35
|
+
def line_string_to_ewkt(hash)
|
36
|
+
return 'LINESTRING EMPTY' if hash['coordinates'].nil?
|
37
|
+
'LINESTRING(' + hash['coordinates'].collect do |point|
|
38
|
+
point.join(' ')
|
39
|
+
end.join(', ') + ')'
|
40
|
+
end
|
41
|
+
|
42
|
+
def polygon_to_ewkt(hash)
|
43
|
+
return 'POLYGON EMPTY' if hash['coordinates'].nil?
|
44
|
+
'POLYGON(' + hash['coordinates'].collect do |hole|
|
45
|
+
'(' + hole.collect do |point|
|
46
|
+
point.join(' ')
|
47
|
+
end.join(', ') + ')'
|
48
|
+
end.join(', ') + ')'
|
49
|
+
end
|
50
|
+
|
51
|
+
def multi_point_to_ewkt(hash)
|
52
|
+
return 'MULTIPOINT EMPTY' if hash['coordinates'].nil?
|
53
|
+
'MULTIPOINT(' + hash['coordinates'].collect do |point|
|
54
|
+
'(' + point.join(' ') + ')'
|
55
|
+
end.join(', ') + ')'
|
56
|
+
end
|
57
|
+
|
58
|
+
def multi_line_string_to_ewkt(hash)
|
59
|
+
return 'MULTILINESTRING EMPTY' if hash['coordinates'].nil?
|
60
|
+
'MULTILINESTRING(' + hash['coordinates'].collect do |line|
|
61
|
+
'(' + line.collect do |point|
|
62
|
+
point.join(' ')
|
63
|
+
end.join(', ') + ')'
|
64
|
+
end.join(', ') + ')'
|
65
|
+
end
|
66
|
+
|
67
|
+
def multipolygon_to_ewkt(hash)
|
68
|
+
return 'MULTIPOLYGON EMPTY' if hash['coordinates'].nil?
|
69
|
+
'MULTIPOLYGON(' + hash['coordinates'].collect do |polygon|
|
70
|
+
'(' + polygon.collect do |hole|
|
71
|
+
'(' + hole.collect do |point|
|
72
|
+
point.join(' ')
|
73
|
+
end.join(', ') + ')'
|
74
|
+
end.join(', ') + ')'
|
75
|
+
end.join(', ') + ')'
|
76
|
+
end
|
77
|
+
|
78
|
+
# for PostGIS ST_ASGeoJSON compatibility
|
79
|
+
def multi_polygon_to_ewkt(hash)
|
80
|
+
return 'MULTIPOLYGON EMPTY' if hash['coordinates'].nil?
|
81
|
+
'MULTIPOLYGON(' + hash['coordinates'].collect do |polygon|
|
82
|
+
'(' + polygon.collect do |hole|
|
83
|
+
'(' + hole.collect do |point|
|
84
|
+
point.join(' ')
|
85
|
+
end.join(', ') + ')'
|
86
|
+
end.join(', ') + ')'
|
87
|
+
end.join(', ') + ')'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
data/lib/charta/geo_json.rb
CHANGED
@@ -7,12 +7,14 @@ module Charta
|
|
7
7
|
|
8
8
|
def initialize(data, srid = :WGS84)
|
9
9
|
srid ||= :WGS84
|
10
|
-
@json =
|
10
|
+
@json = Coordinates.flatten(data.is_a?(Hash) ? data : JSON.parse(data))
|
11
11
|
lsrid = @json['crs']['properties']['name'] if @json.is_a?(Hash) &&
|
12
12
|
@json['crs'].is_a?(Hash) &&
|
13
13
|
@json['crs']['properties'].is_a?(Hash)
|
14
14
|
lsrid ||= srid
|
15
15
|
@srid = ::Charta.find_srid(lsrid)
|
16
|
+
|
17
|
+
@json = Coordinates.normalize_4326_geometry(@json) if @srid.to_i == 4326
|
16
18
|
end
|
17
19
|
|
18
20
|
def geom
|
@@ -24,7 +26,7 @@ module Charta
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def to_ewkt
|
27
|
-
"SRID=#{
|
29
|
+
"SRID=#{srid};" + EwktSerializer.object_to_ewkt(@json)
|
28
30
|
end
|
29
31
|
|
30
32
|
def valid?
|
@@ -42,131 +44,14 @@ module Charta
|
|
42
44
|
false
|
43
45
|
end
|
44
46
|
|
45
|
-
# Force coordinates to 2D
|
46
47
|
def flatten(hash)
|
47
|
-
|
48
|
-
flatten_feature_collection(hash)
|
49
|
-
elsif hash['type'] == 'Feature'
|
50
|
-
flatten_feature(hash)
|
51
|
-
else
|
52
|
-
flatten_geometry(hash)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def flatten_feature_collection(hash)
|
57
|
-
hash.merge('features' => hash['features'].map { |f| flatten_feature(f) })
|
58
|
-
end
|
59
|
-
|
60
|
-
def flatten_feature(hash)
|
61
|
-
hash.merge('geometry' => flatten_geometry(hash['geometry']))
|
62
|
-
end
|
63
|
-
|
64
|
-
def flatten_geometry(hash)
|
65
|
-
coordinates = hash['coordinates']
|
66
|
-
flattened =
|
67
|
-
case hash['type']
|
68
|
-
when 'Point' then
|
69
|
-
flatten_position(coordinates)
|
70
|
-
when 'MultiPoint', 'LineString'
|
71
|
-
coordinates.map { |p| flatten_position(p) }
|
72
|
-
when 'MultiLineString', 'Polygon'
|
73
|
-
coordinates.map { |l| l.map { |p| flatten_position(p) } }
|
74
|
-
when 'MultiPolygon'
|
75
|
-
coordinates.map { |m| m.map { |l| l.map { |p| flatten_position(p) } } }
|
76
|
-
when 'GeometryCollection' then
|
77
|
-
return hash.merge('geometries' => hash['geometries'].map { |g| flatten_geometry(g) })
|
78
|
-
else
|
79
|
-
raise StandardError, "Cannot handle: #{hash['type'].inspect}. In #{hash.inspect}"
|
80
|
-
end
|
81
|
-
|
82
|
-
hash.merge('coordinates' => flattened)
|
83
|
-
end
|
84
|
-
|
85
|
-
def flatten_position(position)
|
86
|
-
position[0..1]
|
87
|
-
end
|
88
|
-
|
89
|
-
def object_to_ewkt(hash)
|
90
|
-
type = hash[:type] || hash['type']
|
91
|
-
send("#{type.gsub(/(.)([A-Z])/, '\1_\2').downcase}_to_ewkt", hash)
|
92
|
-
end
|
93
|
-
|
94
|
-
def feature_collection_to_ewkt(hash)
|
95
|
-
return 'GEOMETRYCOLLECTION EMPTY' if hash['features'].nil?
|
96
|
-
'GEOMETRYCOLLECTION(' + hash['features'].collect do |feature|
|
97
|
-
object_to_ewkt(feature)
|
98
|
-
end.join(', ') + ')'
|
99
|
-
end
|
100
|
-
|
101
|
-
def geometry_collection_to_ewkt(hash)
|
102
|
-
return 'GEOMETRYCOLLECTION EMPTY' if hash['geometries'].nil?
|
103
|
-
'GEOMETRYCOLLECTION(' + hash['geometries'].collect do |feature|
|
104
|
-
object_to_ewkt(feature)
|
105
|
-
end.join(', ') + ')'
|
106
|
-
end
|
107
|
-
|
108
|
-
def feature_to_ewkt(hash)
|
109
|
-
object_to_ewkt(hash['geometry'])
|
110
|
-
end
|
111
|
-
|
112
|
-
def point_to_ewkt(hash)
|
113
|
-
return 'POINT EMPTY' if hash['coordinates'].nil?
|
114
|
-
'POINT(' + hash['coordinates'].join(' ') + ')'
|
115
|
-
end
|
116
|
-
|
117
|
-
def line_string_to_ewkt(hash)
|
118
|
-
return 'LINESTRING EMPTY' if hash['coordinates'].nil?
|
119
|
-
'LINESTRING(' + hash['coordinates'].collect do |point|
|
120
|
-
point.join(' ')
|
121
|
-
end.join(', ') + ')'
|
122
|
-
end
|
123
|
-
|
124
|
-
def polygon_to_ewkt(hash)
|
125
|
-
return 'POLYGON EMPTY' if hash['coordinates'].nil?
|
126
|
-
'POLYGON(' + hash['coordinates'].collect do |hole|
|
127
|
-
'(' + hole.collect do |point|
|
128
|
-
point.join(' ')
|
129
|
-
end.join(', ') + ')'
|
130
|
-
end.join(', ') + ')'
|
131
|
-
end
|
132
|
-
|
133
|
-
def multi_point_to_ewkt(hash)
|
134
|
-
return 'MULTIPOINT EMPTY' if hash['coordinates'].nil?
|
135
|
-
'MULTIPOINT(' + hash['coordinates'].collect do |point|
|
136
|
-
'(' + point.join(' ') + ')'
|
137
|
-
end.join(', ') + ')'
|
138
|
-
end
|
139
|
-
|
140
|
-
def multi_line_string_to_ewkt(hash)
|
141
|
-
return 'MULTILINESTRING EMPTY' if hash['coordinates'].nil?
|
142
|
-
'MULTILINESTRING(' + hash['coordinates'].collect do |line|
|
143
|
-
'(' + line.collect do |point|
|
144
|
-
point.join(' ')
|
145
|
-
end.join(', ') + ')'
|
146
|
-
end.join(', ') + ')'
|
147
|
-
end
|
148
|
-
|
149
|
-
def multipolygon_to_ewkt(hash)
|
150
|
-
return 'MULTIPOLYGON EMPTY' if hash['coordinates'].nil?
|
151
|
-
'MULTIPOLYGON(' + hash['coordinates'].collect do |polygon|
|
152
|
-
'(' + polygon.collect do |hole|
|
153
|
-
'(' + hole.collect do |point|
|
154
|
-
point.join(' ')
|
155
|
-
end.join(', ') + ')'
|
156
|
-
end.join(', ') + ')'
|
157
|
-
end.join(', ') + ')'
|
48
|
+
Coordinates.flatten hash
|
158
49
|
end
|
159
50
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
'(' + polygon.collect do |hole|
|
165
|
-
'(' + hole.collect do |point|
|
166
|
-
point.join(' ')
|
167
|
-
end.join(', ') + ')'
|
168
|
-
end.join(', ') + ')'
|
169
|
-
end.join(', ') + ')'
|
51
|
+
%i[object_to_ewkt feature_collection_to_ewkt geometry_collection_to_ewkt feature_to_ewkt point_to_ewkt line_string_to_ewkt polygon_to_ewkt multi_point_to_ewkt multi_line_string_to_ewkt multipolygon_to_ewkt multi_polygon_to_ewkt].each do |m|
|
52
|
+
define_method m do |*args|
|
53
|
+
EwktSerializer.send m, *args
|
54
|
+
end
|
170
55
|
end
|
171
56
|
end
|
172
57
|
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,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/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.17
|
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: []
|
@@ -130,6 +130,7 @@ extensions: []
|
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
132
|
- ".gitignore"
|
133
|
+
- ".gitlab-ci.yml"
|
133
134
|
- ".travis.yml"
|
134
135
|
- CODE_OF_CONDUCT.md
|
135
136
|
- Gemfile
|
@@ -139,6 +140,8 @@ files:
|
|
139
140
|
- charta.gemspec
|
140
141
|
- lib/charta.rb
|
141
142
|
- lib/charta/bounding_box.rb
|
143
|
+
- lib/charta/coordinates.rb
|
144
|
+
- lib/charta/ewkt_serializer.rb
|
142
145
|
- lib/charta/geo_json.rb
|
143
146
|
- lib/charta/geojson_import.rb
|
144
147
|
- lib/charta/geometry.rb
|
@@ -156,7 +159,7 @@ homepage: https://github.com/ekylibre/charta
|
|
156
159
|
licenses:
|
157
160
|
- MIT
|
158
161
|
metadata: {}
|
159
|
-
post_install_message:
|
162
|
+
post_install_message:
|
160
163
|
rdoc_options: []
|
161
164
|
require_paths:
|
162
165
|
- lib
|
@@ -171,9 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
174
|
- !ruby/object:Gem::Version
|
172
175
|
version: '0'
|
173
176
|
requirements: []
|
174
|
-
|
175
|
-
|
176
|
-
signing_key:
|
177
|
+
rubygems_version: 3.0.3
|
178
|
+
signing_key:
|
177
179
|
specification_version: 4
|
178
180
|
summary: Simple tool over geos and co
|
179
181
|
test_files: []
|