rgeo 3.0.0.pre.rc.2 → 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 +10 -1
- data/ext/geos_c_impl/analysis.c +26 -23
- data/ext/geos_c_impl/analysis.h +8 -5
- data/ext/geos_c_impl/coordinates.c +27 -21
- data/ext/geos_c_impl/coordinates.h +5 -2
- data/ext/geos_c_impl/errors.c +15 -8
- data/ext/geos_c_impl/errors.h +4 -1
- data/ext/geos_c_impl/extconf.rb +40 -30
- data/ext/geos_c_impl/factory.c +405 -389
- data/ext/geos_c_impl/factory.h +71 -49
- data/ext/geos_c_impl/geometry.c +485 -408
- data/ext/geos_c_impl/geometry.h +5 -5
- data/ext/geos_c_impl/geometry_collection.c +269 -198
- data/ext/geos_c_impl/geometry_collection.h +6 -7
- data/ext/geos_c_impl/globals.c +99 -21
- data/ext/geos_c_impl/globals.h +3 -2
- data/ext/geos_c_impl/line_string.c +261 -220
- data/ext/geos_c_impl/line_string.h +5 -6
- data/ext/geos_c_impl/main.c +8 -9
- data/ext/geos_c_impl/point.c +62 -65
- data/ext/geos_c_impl/point.h +4 -5
- data/ext/geos_c_impl/polygon.c +121 -90
- data/ext/geos_c_impl/polygon.h +11 -9
- data/ext/geos_c_impl/preface.h +4 -13
- data/ext/geos_c_impl/ruby_more.c +39 -37
- data/ext/geos_c_impl/ruby_more.h +11 -2
- 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 +52 -89
- data/lib/rgeo/cartesian/feature_methods.rb +0 -5
- data/lib/rgeo/cartesian/interface.rb +6 -5
- 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 +299 -99
- data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +85 -37
- data/lib/rgeo/coord_sys.rb +1 -9
- data/lib/rgeo/feature/curve.rb +0 -11
- data/lib/rgeo/feature/factory.rb +26 -36
- data/lib/rgeo/feature/factory_generator.rb +6 -11
- data/lib/rgeo/feature/geometry.rb +41 -40
- 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 -6
- 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 +93 -119
- data/lib/rgeo/geographic/interface.rb +62 -116
- data/lib/rgeo/geographic/projected_feature_methods.rb +2 -16
- data/lib/rgeo/geographic/projected_window.rb +36 -22
- data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -3
- data/lib/rgeo/geographic/simple_mercator_projector.rb +24 -21
- data/lib/rgeo/geographic/spherical_feature_methods.rb +8 -8
- data/lib/rgeo/geographic/spherical_math.rb +17 -20
- data/lib/rgeo/geographic.rb +1 -1
- data/lib/rgeo/geos/capi_factory.rb +70 -124
- data/lib/rgeo/geos/capi_feature_classes.rb +0 -29
- data/lib/rgeo/geos/ffi_factory.rb +90 -131
- data/lib/rgeo/geos/ffi_feature_methods.rb +73 -128
- data/lib/rgeo/geos/interface.rb +21 -36
- data/lib/rgeo/geos/utils.rb +3 -3
- data/lib/rgeo/geos/zm_factory.rb +53 -76
- data/lib/rgeo/geos/zm_feature_methods.rb +16 -34
- data/lib/rgeo/geos.rb +2 -5
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +5 -18
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +18 -42
- data/lib/rgeo/impl_helper/basic_point_methods.rb +1 -13
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +16 -25
- data/lib/rgeo/impl_helper/utils.rb +21 -0
- data/lib/rgeo/impl_helper/valid_op.rb +12 -16
- data/lib/rgeo/impl_helper/validity_check.rb +3 -3
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +73 -63
- data/lib/rgeo/wkrep/wkb_parser.rb +33 -31
- data/lib/rgeo/wkrep/wkt_generator.rb +52 -45
- data/lib/rgeo/wkrep/wkt_parser.rb +48 -35
- data/lib/rgeo.rb +1 -3
- metadata +10 -9
@@ -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
|
|
@@ -125,20 +120,10 @@ module RGeo
|
|
125
120
|
@fg_geom.empty?
|
126
121
|
end
|
127
122
|
|
128
|
-
def is_empty?
|
129
|
-
warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
130
|
-
empty?
|
131
|
-
end
|
132
|
-
|
133
123
|
def simple?
|
134
124
|
@fg_geom.simple?
|
135
125
|
end
|
136
126
|
|
137
|
-
def is_simple?
|
138
|
-
warn "The is_simple? method is deprecated, please use the simple? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
139
|
-
simple?
|
140
|
-
end
|
141
|
-
|
142
127
|
def is_3d?
|
143
128
|
factory.property(:has_z_coordinate)
|
144
129
|
end
|
@@ -159,20 +144,21 @@ module RGeo
|
|
159
144
|
|
160
145
|
# (see RGeo::ImplHelper::ValidityCheck#make_valid)
|
161
146
|
# Only available since GEOS 3.8+
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
167
154
|
|
168
155
|
def equals?(rhs)
|
169
156
|
return false unless rhs.is_a?(RGeo::Feature::Instance)
|
170
157
|
fg = factory.convert_to_fg_geometry(rhs)
|
171
|
-
|
172
|
-
false
|
158
|
+
|
173
159
|
# GEOS has a bug where empty geometries are not spatially equal
|
174
160
|
# to each other. Work around this case first.
|
175
|
-
|
161
|
+
if fg.empty? && @fg_geom.empty?
|
176
162
|
true
|
177
163
|
else
|
178
164
|
@fg_geom.eql?(fg)
|
@@ -182,83 +168,55 @@ module RGeo
|
|
182
168
|
|
183
169
|
def disjoint?(rhs)
|
184
170
|
fg = factory.convert_to_fg_geometry(rhs)
|
185
|
-
if
|
186
|
-
|
187
|
-
prep ? prep.disjoint?(fg) : @fg_geom.disjoint?(fg)
|
188
|
-
else
|
189
|
-
false
|
190
|
-
end
|
171
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
172
|
+
prep ? prep.disjoint?(fg) : @fg_geom.disjoint?(fg)
|
191
173
|
end
|
192
174
|
|
193
175
|
def intersects?(rhs)
|
194
176
|
fg = factory.convert_to_fg_geometry(rhs)
|
195
|
-
if
|
196
|
-
|
197
|
-
prep ? prep.intersects?(fg) : @fg_geom.intersects?(fg)
|
198
|
-
else
|
199
|
-
false
|
200
|
-
end
|
177
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_1
|
178
|
+
prep ? prep.intersects?(fg) : @fg_geom.intersects?(fg)
|
201
179
|
end
|
202
180
|
|
203
181
|
def touches?(rhs)
|
204
182
|
fg = factory.convert_to_fg_geometry(rhs)
|
205
|
-
if
|
206
|
-
|
207
|
-
prep ? prep.touches?(fg) : @fg_geom.touches?(fg)
|
208
|
-
else
|
209
|
-
false
|
210
|
-
end
|
183
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
184
|
+
prep ? prep.touches?(fg) : @fg_geom.touches?(fg)
|
211
185
|
end
|
212
186
|
|
213
187
|
def crosses?(rhs)
|
214
188
|
fg = factory.convert_to_fg_geometry(rhs)
|
215
|
-
if
|
216
|
-
|
217
|
-
prep ? prep.crosses?(fg) : @fg_geom.crosses?(fg)
|
218
|
-
else
|
219
|
-
false
|
220
|
-
end
|
189
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
190
|
+
prep ? prep.crosses?(fg) : @fg_geom.crosses?(fg)
|
221
191
|
end
|
222
192
|
|
223
193
|
def within?(rhs)
|
224
194
|
fg = factory.convert_to_fg_geometry(rhs)
|
225
|
-
if
|
226
|
-
|
227
|
-
prep ? prep.within?(fg) : @fg_geom.within?(fg)
|
228
|
-
else
|
229
|
-
false
|
230
|
-
end
|
195
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
196
|
+
prep ? prep.within?(fg) : @fg_geom.within?(fg)
|
231
197
|
end
|
232
198
|
|
233
199
|
def contains?(rhs)
|
234
200
|
fg = factory.convert_to_fg_geometry(rhs)
|
235
|
-
if
|
236
|
-
|
237
|
-
prep ? prep.contains?(fg) : @fg_geom.contains?(fg)
|
238
|
-
else
|
239
|
-
false
|
240
|
-
end
|
201
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_1
|
202
|
+
prep ? prep.contains?(fg) : @fg_geom.contains?(fg)
|
241
203
|
end
|
242
204
|
|
243
205
|
def overlaps?(rhs)
|
244
206
|
fg = factory.convert_to_fg_geometry(rhs)
|
245
|
-
if
|
246
|
-
|
247
|
-
prep ? prep.overlaps?(fg) : @fg_geom.overlaps?(fg)
|
248
|
-
else
|
249
|
-
false
|
250
|
-
end
|
207
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
208
|
+
prep ? prep.overlaps?(fg) : @fg_geom.overlaps?(fg)
|
251
209
|
end
|
252
210
|
|
253
211
|
def relate?(rhs, pattern)
|
254
212
|
fg = factory.convert_to_fg_geometry(rhs)
|
255
|
-
|
213
|
+
@fg_geom.relate_pattern(fg, pattern)
|
256
214
|
end
|
257
215
|
alias relate relate? # DEPRECATED
|
258
216
|
|
259
217
|
def distance(rhs)
|
260
218
|
fg = factory.convert_to_fg_geometry(rhs)
|
261
|
-
|
219
|
+
@fg_geom.distance(fg)
|
262
220
|
end
|
263
221
|
|
264
222
|
def buffer(distance)
|
@@ -271,14 +229,14 @@ module RGeo
|
|
271
229
|
|
272
230
|
def intersection(rhs)
|
273
231
|
fg = factory.convert_to_fg_geometry(rhs)
|
274
|
-
|
232
|
+
@factory.wrap_fg_geom(@fg_geom.intersection(fg), nil)
|
275
233
|
end
|
276
234
|
|
277
235
|
alias * intersection
|
278
236
|
|
279
237
|
def union(rhs)
|
280
238
|
fg = factory.convert_to_fg_geometry(rhs)
|
281
|
-
|
239
|
+
@factory.wrap_fg_geom(@fg_geom.union(fg), nil)
|
282
240
|
end
|
283
241
|
|
284
242
|
alias + union
|
@@ -290,18 +248,18 @@ module RGeo
|
|
290
248
|
|
291
249
|
def difference(rhs)
|
292
250
|
fg = factory.convert_to_fg_geometry(rhs)
|
293
|
-
|
251
|
+
@factory.wrap_fg_geom(@fg_geom.difference(fg), nil)
|
294
252
|
end
|
295
253
|
|
296
254
|
alias - difference
|
297
255
|
|
298
256
|
def sym_difference(rhs)
|
299
257
|
fg = factory.convert_to_fg_geometry(rhs)
|
300
|
-
|
258
|
+
@factory.wrap_fg_geom(@fg_geom.sym_difference(fg), nil)
|
301
259
|
end
|
302
260
|
|
303
|
-
def eql?(
|
304
|
-
rep_equals?(
|
261
|
+
def eql?(other)
|
262
|
+
rep_equals?(other)
|
305
263
|
end
|
306
264
|
|
307
265
|
def detach_fg_geom
|
@@ -353,7 +311,7 @@ module RGeo
|
|
353
311
|
end
|
354
312
|
|
355
313
|
def rep_equals?(rhs)
|
356
|
-
rhs.
|
314
|
+
rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
|
357
315
|
Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
|
358
316
|
end
|
359
317
|
|
@@ -382,14 +340,15 @@ module RGeo
|
|
382
340
|
@fg_geom.num_points
|
383
341
|
end
|
384
342
|
|
385
|
-
def point_n(
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
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)
|
393
352
|
end
|
394
353
|
|
395
354
|
def start_point
|
@@ -415,22 +374,12 @@ module RGeo
|
|
415
374
|
@fg_geom.closed?
|
416
375
|
end
|
417
376
|
|
418
|
-
def is_closed?
|
419
|
-
warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
420
|
-
closed?
|
421
|
-
end
|
422
|
-
|
423
377
|
def ring?
|
424
378
|
@fg_geom.ring?
|
425
379
|
end
|
426
380
|
|
427
|
-
def is_ring?
|
428
|
-
warn "The is_ring? method is deprecated, please use the ring? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
429
|
-
ring?
|
430
|
-
end
|
431
|
-
|
432
381
|
def rep_equals?(rhs)
|
433
|
-
rhs.
|
382
|
+
rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
|
434
383
|
Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
|
435
384
|
end
|
436
385
|
|
@@ -484,10 +433,10 @@ module RGeo
|
|
484
433
|
@fg_geom.num_interior_rings
|
485
434
|
end
|
486
435
|
|
487
|
-
def interior_ring_n(
|
488
|
-
|
489
|
-
|
490
|
-
|
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)
|
491
440
|
end
|
492
441
|
|
493
442
|
def interior_rings
|
@@ -497,7 +446,7 @@ module RGeo
|
|
497
446
|
end
|
498
447
|
|
499
448
|
def rep_equals?(rhs)
|
500
|
-
if rhs.
|
449
|
+
if rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
|
501
450
|
rhs.exterior_ring.rep_equals?(exterior_ring)
|
502
451
|
sn = @fg_geom.num_interior_rings
|
503
452
|
rn = rhs.num_interior_rings
|
@@ -513,8 +462,10 @@ module RGeo
|
|
513
462
|
|
514
463
|
def hash
|
515
464
|
@hash ||= begin
|
516
|
-
hash = Utils.ffi_coord_seq_hash(
|
517
|
-
|
465
|
+
hash = Utils.ffi_coord_seq_hash(
|
466
|
+
@fg_geom.exterior_ring.coord_seq,
|
467
|
+
[@factory, geometry_type].hash
|
468
|
+
)
|
518
469
|
@fg_geom.interior_rings.inject(hash) do |h, r|
|
519
470
|
Utils.ffi_coord_seq_hash(r.coord_seq, h)
|
520
471
|
end
|
@@ -532,7 +483,7 @@ module RGeo
|
|
532
483
|
end
|
533
484
|
|
534
485
|
def rep_equals?(rhs)
|
535
|
-
if rhs.
|
486
|
+
if rhs.instance_of?(self.class) && rhs.factory.eql?(@factory)
|
536
487
|
size = @fg_geom.num_geometries
|
537
488
|
if size == rhs.num_geometries
|
538
489
|
size.times do |n|
|
@@ -549,35 +500,34 @@ module RGeo
|
|
549
500
|
end
|
550
501
|
alias size num_geometries
|
551
502
|
|
552
|
-
def geometry_n(
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
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
|
+
)
|
557
510
|
end
|
558
511
|
|
559
|
-
def [](
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
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
|
+
)
|
565
521
|
end
|
566
522
|
|
567
523
|
def hash
|
568
|
-
@hash ||=
|
569
|
-
hash = [@factory, geometry_type].hash
|
570
|
-
(0...num_geometries).inject(hash) do |h, i|
|
571
|
-
(1_664_525 * h + geometry_n(i).hash).hash
|
572
|
-
end
|
573
|
-
end
|
524
|
+
@hash ||= [@factory, geometry_type, *(0...num_geometries).map { |i| geometry_n(i) }].hash
|
574
525
|
end
|
575
526
|
|
576
527
|
def each
|
577
528
|
if block_given?
|
578
529
|
@fg_geom.num_geometries.times do |n|
|
579
|
-
yield @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n),
|
580
|
-
@_klasses ? @_klasses[n] : nil)
|
530
|
+
yield @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n), @_klasses ? @_klasses[n] : nil)
|
581
531
|
end
|
582
532
|
self
|
583
533
|
else
|
@@ -615,11 +565,6 @@ module RGeo
|
|
615
565
|
true
|
616
566
|
end
|
617
567
|
|
618
|
-
def is_closed?
|
619
|
-
warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
620
|
-
closed?
|
621
|
-
end
|
622
|
-
|
623
568
|
def coordinates
|
624
569
|
each.map(&:coordinates)
|
625
570
|
end
|
data/lib/rgeo/geos/interface.rb
CHANGED
@@ -38,11 +38,6 @@ module RGeo
|
|
38
38
|
ZMGeometryMethods === object && CAPIGeometryMethods === object.z_geometry)
|
39
39
|
end
|
40
40
|
|
41
|
-
def is_capi_geos?(object)
|
42
|
-
warn "The is_capi_geos? method is deprecated, please use the capi_geos? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
43
|
-
capi_geos?(object)
|
44
|
-
end
|
45
|
-
|
46
41
|
# Returns true if the given feature is an FFI GEOS feature, or if
|
47
42
|
# the given factory is an FFI GEOS factory.
|
48
43
|
|
@@ -53,11 +48,6 @@ module RGeo
|
|
53
48
|
ZMGeometryMethods === object && FFIGeometryMethods === object.z_geometry)
|
54
49
|
end
|
55
50
|
|
56
|
-
def is_ffi_geos?(object)
|
57
|
-
warn "The is_ffi_geos? method is deprecated, please use the ffi_geos? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
58
|
-
ffi_geos?(object)
|
59
|
-
end
|
60
|
-
|
61
51
|
# Returns true if the given feature is a GEOS feature, or if the given
|
62
52
|
# factory is a GEOS factory. Does not distinguish between CAPI and FFI.
|
63
53
|
|
@@ -67,23 +57,17 @@ module RGeo
|
|
67
57
|
ZMFactory === object || ZMGeometryMethods === object
|
68
58
|
end
|
69
59
|
|
70
|
-
def is_geos?(object)
|
71
|
-
warn "The is_geos? method is deprecated, please use the geos? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
72
|
-
geos?(object)
|
73
|
-
end
|
74
|
-
|
75
60
|
# Returns the GEOS library version as a string of the format "x.y.z".
|
76
61
|
# Returns nil if GEOS is not available.
|
77
62
|
|
78
63
|
def version
|
79
64
|
unless defined?(@version)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
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
|
87
71
|
end
|
88
72
|
@version
|
89
73
|
end
|
@@ -127,14 +111,14 @@ module RGeo
|
|
127
111
|
# [<tt>:srid</tt>]
|
128
112
|
# Set the SRID returned by geometries created by this factory.
|
129
113
|
# Default is 0.
|
130
|
-
# [<tt>:proj4</tt>]
|
131
|
-
# The coordinate system in Proj4 format, either as a
|
132
|
-
# CoordSys::Proj4 object or as a string or hash representing the
|
133
|
-
# proj4 format. Optional.
|
134
114
|
# [<tt>:coord_sys</tt>]
|
135
115
|
# The coordinate system in OGC form, either as a subclass of
|
136
116
|
# CoordSys::CS::CoordinateSystem, or as a string in WKT format.
|
137
|
-
# Optional.
|
117
|
+
# Optional. If not provided, but <tt>:srid</tt> is, a coord_sys
|
118
|
+
# will be created using the CS::CONFIG.default_coord_sys_class.
|
119
|
+
# [<tt>:coord_sys_class</tt>]
|
120
|
+
# The coordinate system implementation to use if you do not want to
|
121
|
+
# use the CS::CONFIG.default_coord_sys_class. Optional.
|
138
122
|
# [<tt>:has_z_coordinate</tt>]
|
139
123
|
# Support <tt>z_coordinate</tt>. Default is false.
|
140
124
|
# [<tt>:has_m_coordinate</tt>]
|
@@ -178,15 +162,16 @@ module RGeo
|
|
178
162
|
# never automatically generates a prepared geometry (unless you
|
179
163
|
# generate one explicitly using the <tt>prepare!</tt> method).
|
180
164
|
def factory(opts = {})
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
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)
|
190
175
|
end
|
191
176
|
end
|
192
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
|
|