rgeo 3.0.0.pre.rc.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/ext/geos_c_impl/factory.c +41 -5
- data/ext/geos_c_impl/factory.h +13 -2
- data/ext/geos_c_impl/geometry.c +151 -122
- data/ext/geos_c_impl/geometry_collection.c +17 -19
- data/ext/geos_c_impl/line_string.c +46 -36
- data/ext/geos_c_impl/point.c +0 -2
- data/ext/geos_c_impl/polygon.c +10 -11
- data/ext/geos_c_impl/polygon.h +1 -1
- data/ext/geos_c_impl/ruby_more.c +7 -0
- data/ext/geos_c_impl/ruby_more.h +8 -0
- data/lib/rgeo/cartesian/analysis.rb +5 -3
- data/lib/rgeo/cartesian/bounding_box.rb +74 -79
- data/lib/rgeo/cartesian/calculations.rb +20 -26
- data/lib/rgeo/cartesian/factory.rb +47 -49
- data/lib/rgeo/cartesian/planar_graph.rb +10 -16
- data/lib/rgeo/cartesian/sweepline_intersector.rb +1 -3
- data/lib/rgeo/cartesian/valid_op.rb +1 -3
- data/lib/rgeo/coord_sys/cs/entities.rb +87 -101
- data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +70 -29
- data/lib/rgeo/feature/curve.rb +0 -1
- data/lib/rgeo/feature/factory.rb +25 -27
- data/lib/rgeo/feature/factory_generator.rb +3 -4
- data/lib/rgeo/feature/geometry.rb +41 -30
- data/lib/rgeo/feature/geometry_collection.rb +3 -4
- data/lib/rgeo/feature/line_string.rb +1 -2
- data/lib/rgeo/feature/linear_ring.rb +0 -1
- data/lib/rgeo/feature/multi_curve.rb +0 -1
- data/lib/rgeo/feature/multi_surface.rb +0 -1
- data/lib/rgeo/feature/point.rb +0 -1
- data/lib/rgeo/feature/polygon.rb +1 -2
- data/lib/rgeo/feature/surface.rb +0 -1
- data/lib/rgeo/feature/types.rb +73 -83
- data/lib/rgeo/geographic/factory.rb +87 -80
- data/lib/rgeo/geographic/interface.rb +40 -23
- data/lib/rgeo/geographic/projected_feature_methods.rb +2 -6
- data/lib/rgeo/geographic/projected_window.rb +35 -21
- data/lib/rgeo/geographic/simple_mercator_projector.rb +25 -13
- data/lib/rgeo/geographic/spherical_feature_methods.rb +8 -3
- data/lib/rgeo/geographic/spherical_math.rb +17 -20
- data/lib/rgeo/geos/capi_factory.rb +50 -50
- data/lib/rgeo/geos/ffi_factory.rb +41 -42
- data/lib/rgeo/geos/ffi_feature_methods.rb +72 -97
- data/lib/rgeo/geos/interface.rb +16 -16
- data/lib/rgeo/geos/utils.rb +3 -3
- data/lib/rgeo/geos/zm_factory.rb +50 -42
- data/lib/rgeo/geos/zm_feature_methods.rb +15 -8
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +4 -4
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +18 -24
- data/lib/rgeo/impl_helper/basic_point_methods.rb +1 -3
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +15 -16
- data/lib/rgeo/impl_helper/utils.rb +3 -9
- data/lib/rgeo/impl_helper/valid_op.rb +12 -16
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +42 -47
- data/lib/rgeo/wkrep/wkb_parser.rb +17 -18
- data/lib/rgeo/wkrep/wkt_generator.rb +23 -16
- data/lib/rgeo/wkrep/wkt_parser.rb +23 -13
- metadata +5 -5
@@ -13,6 +13,8 @@ module RGeo
|
|
13
13
|
module FFIGeometryMethods # :nodoc:
|
14
14
|
include Feature::Instance
|
15
15
|
|
16
|
+
attr_reader :factory, :fg_geom, :_klasses
|
17
|
+
|
16
18
|
def initialize(factory, fg_geom, klasses)
|
17
19
|
@factory = factory
|
18
20
|
@fg_geom = fg_geom
|
@@ -56,11 +58,6 @@ module RGeo
|
|
56
58
|
@_klasses = nil
|
57
59
|
end
|
58
60
|
|
59
|
-
attr_reader :factory
|
60
|
-
attr_reader :fg_geom
|
61
|
-
|
62
|
-
attr_reader :_klasses # :nodoc:
|
63
|
-
|
64
61
|
def initialize_copy(orig)
|
65
62
|
@factory = orig.factory
|
66
63
|
@fg_geom = orig.fg_geom.clone
|
@@ -94,9 +91,7 @@ module RGeo
|
|
94
91
|
end
|
95
92
|
|
96
93
|
def prepare!
|
97
|
-
if @_fg_prep.is_a?(Integer)
|
98
|
-
@_fg_prep = ::Geos::PreparedGeometry.new(@fg_geom)
|
99
|
-
end
|
94
|
+
@_fg_prep = ::Geos::PreparedGeometry.new(@fg_geom) if @_fg_prep.is_a?(Integer)
|
100
95
|
self
|
101
96
|
end
|
102
97
|
|
@@ -149,20 +144,21 @@ module RGeo
|
|
149
144
|
|
150
145
|
# (see RGeo::ImplHelper::ValidityCheck#make_valid)
|
151
146
|
# Only available since GEOS 3.8+
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
147
|
+
if ::Geos::FFIGeos.respond_to?(:GEOSMakeValid_r)
|
148
|
+
def make_valid
|
149
|
+
@factory.wrap_fg_geom(@fg_geom.make_valid, nil)
|
150
|
+
rescue ::Geos::GEOSException
|
151
|
+
raise Error::UnsupportedOperation
|
152
|
+
end
|
153
|
+
end
|
157
154
|
|
158
155
|
def equals?(rhs)
|
159
156
|
return false unless rhs.is_a?(RGeo::Feature::Instance)
|
160
157
|
fg = factory.convert_to_fg_geometry(rhs)
|
161
|
-
|
162
|
-
false
|
158
|
+
|
163
159
|
# GEOS has a bug where empty geometries are not spatially equal
|
164
160
|
# to each other. Work around this case first.
|
165
|
-
|
161
|
+
if fg.empty? && @fg_geom.empty?
|
166
162
|
true
|
167
163
|
else
|
168
164
|
@fg_geom.eql?(fg)
|
@@ -172,83 +168,55 @@ module RGeo
|
|
172
168
|
|
173
169
|
def disjoint?(rhs)
|
174
170
|
fg = factory.convert_to_fg_geometry(rhs)
|
175
|
-
if
|
176
|
-
|
177
|
-
prep ? prep.disjoint?(fg) : @fg_geom.disjoint?(fg)
|
178
|
-
else
|
179
|
-
false
|
180
|
-
end
|
171
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
172
|
+
prep ? prep.disjoint?(fg) : @fg_geom.disjoint?(fg)
|
181
173
|
end
|
182
174
|
|
183
175
|
def intersects?(rhs)
|
184
176
|
fg = factory.convert_to_fg_geometry(rhs)
|
185
|
-
if
|
186
|
-
|
187
|
-
prep ? prep.intersects?(fg) : @fg_geom.intersects?(fg)
|
188
|
-
else
|
189
|
-
false
|
190
|
-
end
|
177
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_1
|
178
|
+
prep ? prep.intersects?(fg) : @fg_geom.intersects?(fg)
|
191
179
|
end
|
192
180
|
|
193
181
|
def touches?(rhs)
|
194
182
|
fg = factory.convert_to_fg_geometry(rhs)
|
195
|
-
if
|
196
|
-
|
197
|
-
prep ? prep.touches?(fg) : @fg_geom.touches?(fg)
|
198
|
-
else
|
199
|
-
false
|
200
|
-
end
|
183
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
184
|
+
prep ? prep.touches?(fg) : @fg_geom.touches?(fg)
|
201
185
|
end
|
202
186
|
|
203
187
|
def crosses?(rhs)
|
204
188
|
fg = factory.convert_to_fg_geometry(rhs)
|
205
|
-
if
|
206
|
-
|
207
|
-
prep ? prep.crosses?(fg) : @fg_geom.crosses?(fg)
|
208
|
-
else
|
209
|
-
false
|
210
|
-
end
|
189
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
190
|
+
prep ? prep.crosses?(fg) : @fg_geom.crosses?(fg)
|
211
191
|
end
|
212
192
|
|
213
193
|
def within?(rhs)
|
214
194
|
fg = factory.convert_to_fg_geometry(rhs)
|
215
|
-
if
|
216
|
-
|
217
|
-
prep ? prep.within?(fg) : @fg_geom.within?(fg)
|
218
|
-
else
|
219
|
-
false
|
220
|
-
end
|
195
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
196
|
+
prep ? prep.within?(fg) : @fg_geom.within?(fg)
|
221
197
|
end
|
222
198
|
|
223
199
|
def contains?(rhs)
|
224
200
|
fg = factory.convert_to_fg_geometry(rhs)
|
225
|
-
if
|
226
|
-
|
227
|
-
prep ? prep.contains?(fg) : @fg_geom.contains?(fg)
|
228
|
-
else
|
229
|
-
false
|
230
|
-
end
|
201
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_1
|
202
|
+
prep ? prep.contains?(fg) : @fg_geom.contains?(fg)
|
231
203
|
end
|
232
204
|
|
233
205
|
def overlaps?(rhs)
|
234
206
|
fg = factory.convert_to_fg_geometry(rhs)
|
235
|
-
if
|
236
|
-
|
237
|
-
prep ? prep.overlaps?(fg) : @fg_geom.overlaps?(fg)
|
238
|
-
else
|
239
|
-
false
|
240
|
-
end
|
207
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
208
|
+
prep ? prep.overlaps?(fg) : @fg_geom.overlaps?(fg)
|
241
209
|
end
|
242
210
|
|
243
211
|
def relate?(rhs, pattern)
|
244
212
|
fg = factory.convert_to_fg_geometry(rhs)
|
245
|
-
|
213
|
+
@fg_geom.relate_pattern(fg, pattern)
|
246
214
|
end
|
247
215
|
alias relate relate? # DEPRECATED
|
248
216
|
|
249
217
|
def distance(rhs)
|
250
218
|
fg = factory.convert_to_fg_geometry(rhs)
|
251
|
-
|
219
|
+
@fg_geom.distance(fg)
|
252
220
|
end
|
253
221
|
|
254
222
|
def buffer(distance)
|
@@ -261,14 +229,14 @@ module RGeo
|
|
261
229
|
|
262
230
|
def intersection(rhs)
|
263
231
|
fg = factory.convert_to_fg_geometry(rhs)
|
264
|
-
|
232
|
+
@factory.wrap_fg_geom(@fg_geom.intersection(fg), nil)
|
265
233
|
end
|
266
234
|
|
267
235
|
alias * intersection
|
268
236
|
|
269
237
|
def union(rhs)
|
270
238
|
fg = factory.convert_to_fg_geometry(rhs)
|
271
|
-
|
239
|
+
@factory.wrap_fg_geom(@fg_geom.union(fg), nil)
|
272
240
|
end
|
273
241
|
|
274
242
|
alias + union
|
@@ -280,18 +248,18 @@ module RGeo
|
|
280
248
|
|
281
249
|
def difference(rhs)
|
282
250
|
fg = factory.convert_to_fg_geometry(rhs)
|
283
|
-
|
251
|
+
@factory.wrap_fg_geom(@fg_geom.difference(fg), nil)
|
284
252
|
end
|
285
253
|
|
286
254
|
alias - difference
|
287
255
|
|
288
256
|
def sym_difference(rhs)
|
289
257
|
fg = factory.convert_to_fg_geometry(rhs)
|
290
|
-
|
258
|
+
@factory.wrap_fg_geom(@fg_geom.sym_difference(fg), nil)
|
291
259
|
end
|
292
260
|
|
293
|
-
def eql?(
|
294
|
-
rep_equals?(
|
261
|
+
def eql?(other)
|
262
|
+
rep_equals?(other)
|
295
263
|
end
|
296
264
|
|
297
265
|
def detach_fg_geom
|
@@ -343,7 +311,7 @@ module RGeo
|
|
343
311
|
end
|
344
312
|
|
345
313
|
def rep_equals?(rhs)
|
346
|
-
rhs.
|
314
|
+
rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
|
347
315
|
Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
|
348
316
|
end
|
349
317
|
|
@@ -372,14 +340,15 @@ module RGeo
|
|
372
340
|
@fg_geom.num_points
|
373
341
|
end
|
374
342
|
|
375
|
-
def point_n(
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
343
|
+
def point_n(idx)
|
344
|
+
return unless idx >= 0 && idx < @fg_geom.num_points
|
345
|
+
|
346
|
+
coord_seq = @fg_geom.coord_seq
|
347
|
+
x = coord_seq.get_x(idx)
|
348
|
+
y = coord_seq.get_y(idx)
|
349
|
+
extra = @factory._has_3d ? [coord_seq.get_z(idx)] : []
|
350
|
+
|
351
|
+
@factory.point(x, y, *extra)
|
383
352
|
end
|
384
353
|
|
385
354
|
def start_point
|
@@ -410,7 +379,7 @@ module RGeo
|
|
410
379
|
end
|
411
380
|
|
412
381
|
def rep_equals?(rhs)
|
413
|
-
rhs.
|
382
|
+
rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
|
414
383
|
Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
|
415
384
|
end
|
416
385
|
|
@@ -464,10 +433,10 @@ module RGeo
|
|
464
433
|
@fg_geom.num_interior_rings
|
465
434
|
end
|
466
435
|
|
467
|
-
def interior_ring_n(
|
468
|
-
|
469
|
-
|
470
|
-
|
436
|
+
def interior_ring_n(idx)
|
437
|
+
return unless idx >= 0 && idx < @fg_geom.num_interior_rings
|
438
|
+
|
439
|
+
@factory.wrap_fg_geom(@fg_geom.interior_ring_n(idx), FFILinearRingImpl)
|
471
440
|
end
|
472
441
|
|
473
442
|
def interior_rings
|
@@ -477,7 +446,7 @@ module RGeo
|
|
477
446
|
end
|
478
447
|
|
479
448
|
def rep_equals?(rhs)
|
480
|
-
if rhs.
|
449
|
+
if rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
|
481
450
|
rhs.exterior_ring.rep_equals?(exterior_ring)
|
482
451
|
sn = @fg_geom.num_interior_rings
|
483
452
|
rn = rhs.num_interior_rings
|
@@ -493,8 +462,10 @@ module RGeo
|
|
493
462
|
|
494
463
|
def hash
|
495
464
|
@hash ||= begin
|
496
|
-
hash = Utils.ffi_coord_seq_hash(
|
497
|
-
|
465
|
+
hash = Utils.ffi_coord_seq_hash(
|
466
|
+
@fg_geom.exterior_ring.coord_seq,
|
467
|
+
[@factory, geometry_type].hash
|
468
|
+
)
|
498
469
|
@fg_geom.interior_rings.inject(hash) do |h, r|
|
499
470
|
Utils.ffi_coord_seq_hash(r.coord_seq, h)
|
500
471
|
end
|
@@ -512,7 +483,7 @@ module RGeo
|
|
512
483
|
end
|
513
484
|
|
514
485
|
def rep_equals?(rhs)
|
515
|
-
if rhs.
|
486
|
+
if rhs.instance_of?(self.class) && rhs.factory.eql?(@factory)
|
516
487
|
size = @fg_geom.num_geometries
|
517
488
|
if size == rhs.num_geometries
|
518
489
|
size.times do |n|
|
@@ -529,19 +500,24 @@ module RGeo
|
|
529
500
|
end
|
530
501
|
alias size num_geometries
|
531
502
|
|
532
|
-
def geometry_n(
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
503
|
+
def geometry_n(idx)
|
504
|
+
return unless idx >= 0 && idx < @fg_geom.num_geometries
|
505
|
+
|
506
|
+
@factory.wrap_fg_geom(
|
507
|
+
@fg_geom.get_geometry_n(idx),
|
508
|
+
@_klasses ? @_klasses[idx] : nil
|
509
|
+
)
|
537
510
|
end
|
538
511
|
|
539
|
-
def [](
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
512
|
+
def [](idx)
|
513
|
+
idx += @fg_geom.num_geometries if idx < 0
|
514
|
+
|
515
|
+
return unless idx >= 0 && idx < @fg_geom.num_geometries
|
516
|
+
|
517
|
+
@factory.wrap_fg_geom(
|
518
|
+
@fg_geom.get_geometry_n(idx),
|
519
|
+
@_klasses ? @_klasses[idx] : nil
|
520
|
+
)
|
545
521
|
end
|
546
522
|
|
547
523
|
def hash
|
@@ -551,8 +527,7 @@ module RGeo
|
|
551
527
|
def each
|
552
528
|
if block_given?
|
553
529
|
@fg_geom.num_geometries.times do |n|
|
554
|
-
yield @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n),
|
555
|
-
@_klasses ? @_klasses[n] : nil)
|
530
|
+
yield @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n), @_klasses ? @_klasses[n] : nil)
|
556
531
|
end
|
557
532
|
self
|
558
533
|
else
|
data/lib/rgeo/geos/interface.rb
CHANGED
@@ -62,13 +62,12 @@ module RGeo
|
|
62
62
|
|
63
63
|
def version
|
64
64
|
unless defined?(@version)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
65
|
+
@version =
|
66
|
+
if RGeo::Geos::CAPI_SUPPORTED
|
67
|
+
RGeo::Geos::CAPIFactory._geos_version.freeze
|
68
|
+
elsif RGeo::Geos::FFI_SUPPORTED
|
69
|
+
::Geos::FFIGeos.GEOSversion.sub(/-CAPI-.*$/, "").freeze
|
70
|
+
end
|
72
71
|
end
|
73
72
|
@version
|
74
73
|
end
|
@@ -163,15 +162,16 @@ module RGeo
|
|
163
162
|
# never automatically generates a prepared geometry (unless you
|
164
163
|
# generate one explicitly using the <tt>prepare!</tt> method).
|
165
164
|
def factory(opts = {})
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
165
|
+
return unless supported?
|
166
|
+
|
167
|
+
native_interface = opts[:native_interface] || Geos.preferred_native_interface
|
168
|
+
|
169
|
+
if opts[:has_z_coordinate] && opts[:has_m_coordinate]
|
170
|
+
ZMFactory.new(opts)
|
171
|
+
elsif native_interface == :ffi
|
172
|
+
FFIFactory.new(opts)
|
173
|
+
else
|
174
|
+
CAPIFactory.create(opts)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
data/lib/rgeo/geos/utils.rb
CHANGED
@@ -49,9 +49,9 @@ module RGeo
|
|
49
49
|
result
|
50
50
|
end
|
51
51
|
|
52
|
-
def ffi_coord_seq_hash(
|
53
|
-
(0...
|
54
|
-
[hash,
|
52
|
+
def ffi_coord_seq_hash(coord_seq, init_hash = 0)
|
53
|
+
(0...coord_seq.length).inject(init_hash) do |hash, i|
|
54
|
+
[hash, coord_seq.get_x(i), coord_seq.get_y(i), coord_seq.get_z(i)].hash
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
data/lib/rgeo/geos/zm_factory.rb
CHANGED
@@ -9,7 +9,6 @@
|
|
9
9
|
module RGeo
|
10
10
|
module Geos
|
11
11
|
# A factory for Geos that handles both Z and M.
|
12
|
-
|
13
12
|
class ZMFactory
|
14
13
|
include Feature::Factory::Instance
|
15
14
|
include ImplHelper::Utils
|
@@ -60,33 +59,37 @@ module RGeo
|
|
60
59
|
end
|
61
60
|
|
62
61
|
wkt_generator = opts[:wkt_generator]
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
@wkt_generator =
|
63
|
+
case wkt_generator
|
64
|
+
when Hash
|
65
|
+
WKRep::WKTGenerator.new(wkt_generator)
|
66
|
+
else
|
67
|
+
WKRep::WKTGenerator.new(convert_case: :upper)
|
68
|
+
end
|
69
69
|
wkb_generator = opts[:wkb_generator]
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
@wkb_generator =
|
71
|
+
case wkb_generator
|
72
|
+
when Hash
|
73
|
+
WKRep::WKBGenerator.new(wkb_generator)
|
74
|
+
else
|
75
|
+
WKRep::WKBGenerator.new
|
76
|
+
end
|
76
77
|
wkt_parser = opts[:wkt_parser]
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
@wkt_parser =
|
79
|
+
case wkt_parser
|
80
|
+
when Hash
|
81
|
+
WKRep::WKTParser.new(self, wkt_parser)
|
82
|
+
else
|
83
|
+
WKRep::WKTParser.new(self)
|
84
|
+
end
|
83
85
|
wkb_parser = opts[:wkb_parser]
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
@wkb_parser =
|
87
|
+
case wkb_parser
|
88
|
+
when Hash
|
89
|
+
WKRep::WKBParser.new(self, wkb_parser)
|
90
|
+
else
|
91
|
+
WKRep::WKBParser.new(self)
|
92
|
+
end
|
90
93
|
end
|
91
94
|
|
92
95
|
# Marshal support
|
@@ -108,11 +111,9 @@ module RGeo
|
|
108
111
|
end
|
109
112
|
|
110
113
|
def marshal_load(data) # :nodoc:
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
coord_sys = nil
|
115
|
-
end
|
114
|
+
cs_class = CoordSys::CONFIG.default_coord_sys_class
|
115
|
+
coord_sys = data["cs"]&.then { |cs| cs_class.create_from_wkt(cs) }
|
116
|
+
|
116
117
|
initialize(
|
117
118
|
native_interface: (data["nffi"] ? :ffi : :capi),
|
118
119
|
has_z_coordinate: data["hasz"],
|
@@ -139,17 +140,16 @@ module RGeo
|
|
139
140
|
coder["wkb_parser"] = @wkb_parser.properties
|
140
141
|
coder["auto_prepare"] = @zfactory.property(:auto_prepare).to_s
|
141
142
|
coder["native_interface"] = @zfactory.is_a?(FFIFactory) ? "ffi" : "capi"
|
142
|
-
|
143
|
-
|
144
|
-
|
143
|
+
|
144
|
+
return unless (coord_sys = @zfactory.coord_sys)
|
145
|
+
|
146
|
+
coder["coord_sys"] = coord_sys.to_wkt
|
145
147
|
end
|
146
148
|
|
147
149
|
def init_with(coder) # :nodoc:
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
coord_sys = nil
|
152
|
-
end
|
150
|
+
cs_class = CoordSys::CONFIG.default_coord_sys_class
|
151
|
+
coord_sys = coder["cs"]&.then { |cs| cs_class.create_from_wkt(cs) }
|
152
|
+
|
153
153
|
initialize(
|
154
154
|
native_interface: coder["native_interface"] == "ffi" ? :ffi : :capi,
|
155
155
|
has_z_coordinate: coder["has_z_coordinate"],
|
@@ -192,8 +192,8 @@ module RGeo
|
|
192
192
|
|
193
193
|
# Factory equivalence test.
|
194
194
|
|
195
|
-
def eql?(
|
196
|
-
|
195
|
+
def eql?(other)
|
196
|
+
other.is_a?(ZMFactory) && other.z_factory == @zfactory
|
197
197
|
end
|
198
198
|
alias == eql?
|
199
199
|
|
@@ -227,7 +227,11 @@ module RGeo
|
|
227
227
|
# See RGeo::Feature::Factory#point
|
228
228
|
|
229
229
|
def point(x, y, z = 0, m = 0)
|
230
|
-
create_feature(
|
230
|
+
create_feature(
|
231
|
+
ZMPointImpl,
|
232
|
+
@zfactory.point(x, y, z),
|
233
|
+
@mfactory.point(x, y, m)
|
234
|
+
)
|
231
235
|
end
|
232
236
|
|
233
237
|
# See RGeo::Feature::Factory#line_string
|
@@ -251,7 +255,11 @@ module RGeo
|
|
251
255
|
# See RGeo::Feature::Factory#polygon
|
252
256
|
|
253
257
|
def polygon(outer_ring, inner_rings = nil)
|
254
|
-
create_feature(
|
258
|
+
create_feature(
|
259
|
+
ZMPolygonImpl,
|
260
|
+
@zfactory.polygon(outer_ring, inner_rings),
|
261
|
+
@mfactory.polygon(outer_ring, inner_rings)
|
262
|
+
)
|
255
263
|
end
|
256
264
|
|
257
265
|
# See RGeo::Feature::Factory#collection
|
@@ -159,12 +159,19 @@ module RGeo
|
|
159
159
|
|
160
160
|
def sym_difference(rhs)
|
161
161
|
rhs = RGeo::Feature.cast(rhs, self)
|
162
|
-
@factory.create_feature(
|
162
|
+
@factory.create_feature(
|
163
|
+
nil,
|
164
|
+
@zgeometry.sym_difference(rhs.z_geometry),
|
165
|
+
@mgeometry.sym_difference(rhs.m_geometry)
|
166
|
+
)
|
163
167
|
end
|
164
168
|
|
165
169
|
def rep_equals?(rhs)
|
166
170
|
rhs = RGeo::Feature.cast(rhs, self)
|
167
|
-
rhs.is_a?(self.class) &&
|
171
|
+
rhs.is_a?(self.class) &&
|
172
|
+
@factory.eql?(rhs.factory) &&
|
173
|
+
@zgeometry.rep_equals?(rhs.z_geometry) &&
|
174
|
+
@mgeometry.rep_equals?(rhs.m_geometry)
|
168
175
|
end
|
169
176
|
|
170
177
|
alias eql? rep_equals?
|
@@ -250,8 +257,8 @@ module RGeo
|
|
250
257
|
@zgeometry.num_points
|
251
258
|
end
|
252
259
|
|
253
|
-
def point_n(
|
254
|
-
@factory.create_feature(ZMPointImpl, @zgeometry.point_n(
|
260
|
+
def point_n(idx)
|
261
|
+
@factory.create_feature(ZMPointImpl, @zgeometry.point_n(idx), @mgeometry.point_n(idx))
|
255
262
|
end
|
256
263
|
|
257
264
|
def points
|
@@ -290,8 +297,8 @@ module RGeo
|
|
290
297
|
@zgeometry.num_interior_rings
|
291
298
|
end
|
292
299
|
|
293
|
-
def interior_ring_n(
|
294
|
-
@factory.create_feature(ZMLineStringImpl, @zgeometry.interior_ring_n(
|
300
|
+
def interior_ring_n(idx)
|
301
|
+
@factory.create_feature(ZMLineStringImpl, @zgeometry.interior_ring_n(idx), @mgeometry.interior_ring_n(idx))
|
295
302
|
end
|
296
303
|
|
297
304
|
def interior_rings
|
@@ -315,8 +322,8 @@ module RGeo
|
|
315
322
|
end
|
316
323
|
alias size num_geometries
|
317
324
|
|
318
|
-
def geometry_n(
|
319
|
-
@factory.create_feature(nil, @zgeometry.geometry_n(
|
325
|
+
def geometry_n(idx)
|
326
|
+
@factory.create_feature(nil, @zgeometry.geometry_n(idx), @mgeometry.geometry_n(idx))
|
320
327
|
end
|
321
328
|
alias [] geometry_n
|
322
329
|
|
@@ -27,12 +27,12 @@ module RGeo
|
|
27
27
|
@elements.size
|
28
28
|
end
|
29
29
|
|
30
|
-
def geometry_n(
|
31
|
-
|
30
|
+
def geometry_n(idx)
|
31
|
+
idx < 0 ? nil : @elements[idx]
|
32
32
|
end
|
33
33
|
|
34
|
-
def [](
|
35
|
-
@elements[
|
34
|
+
def [](idx)
|
35
|
+
@elements[idx]
|
36
36
|
end
|
37
37
|
|
38
38
|
def each(&block)
|