rgeo 2.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -0
  3. data/README.md +21 -11
  4. data/ext/geos_c_impl/analysis.c +29 -26
  5. data/ext/geos_c_impl/analysis.h +8 -5
  6. data/ext/geos_c_impl/coordinates.c +27 -21
  7. data/ext/geos_c_impl/coordinates.h +5 -2
  8. data/ext/geos_c_impl/errors.c +19 -10
  9. data/ext/geos_c_impl/errors.h +11 -4
  10. data/ext/geos_c_impl/extconf.rb +41 -29
  11. data/ext/geos_c_impl/factory.c +441 -351
  12. data/ext/geos_c_impl/factory.h +98 -55
  13. data/ext/geos_c_impl/geometry.c +563 -384
  14. data/ext/geos_c_impl/geometry.h +10 -3
  15. data/ext/geos_c_impl/geometry_collection.c +288 -316
  16. data/ext/geos_c_impl/geometry_collection.h +6 -18
  17. data/ext/geos_c_impl/globals.c +99 -21
  18. data/ext/geos_c_impl/globals.h +3 -2
  19. data/ext/geos_c_impl/line_string.c +263 -222
  20. data/ext/geos_c_impl/line_string.h +5 -6
  21. data/ext/geos_c_impl/main.c +8 -9
  22. data/ext/geos_c_impl/point.c +62 -65
  23. data/ext/geos_c_impl/point.h +4 -5
  24. data/ext/geos_c_impl/polygon.c +134 -132
  25. data/ext/geos_c_impl/polygon.h +11 -9
  26. data/ext/geos_c_impl/preface.h +10 -12
  27. data/ext/geos_c_impl/ruby_more.c +67 -0
  28. data/ext/geos_c_impl/ruby_more.h +25 -0
  29. data/lib/rgeo/cartesian/analysis.rb +5 -3
  30. data/lib/rgeo/cartesian/bounding_box.rb +74 -79
  31. data/lib/rgeo/cartesian/calculations.rb +64 -33
  32. data/lib/rgeo/cartesian/factory.rb +57 -102
  33. data/lib/rgeo/cartesian/feature_classes.rb +68 -46
  34. data/lib/rgeo/cartesian/feature_methods.rb +67 -25
  35. data/lib/rgeo/cartesian/interface.rb +6 -41
  36. data/lib/rgeo/cartesian/planar_graph.rb +373 -0
  37. data/lib/rgeo/cartesian/sweepline_intersector.rb +147 -0
  38. data/lib/rgeo/cartesian/valid_op.rb +69 -0
  39. data/lib/rgeo/cartesian.rb +3 -0
  40. data/lib/rgeo/coord_sys/cs/entities.rb +299 -99
  41. data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
  42. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +90 -42
  43. data/lib/rgeo/coord_sys.rb +1 -20
  44. data/lib/rgeo/error.rb +15 -0
  45. data/lib/rgeo/feature/curve.rb +0 -11
  46. data/lib/rgeo/feature/factory.rb +26 -36
  47. data/lib/rgeo/feature/factory_generator.rb +6 -14
  48. data/lib/rgeo/feature/geometry.rb +146 -66
  49. data/lib/rgeo/feature/geometry_collection.rb +16 -9
  50. data/lib/rgeo/feature/line_string.rb +4 -5
  51. data/lib/rgeo/feature/linear_ring.rb +0 -1
  52. data/lib/rgeo/feature/multi_curve.rb +0 -6
  53. data/lib/rgeo/feature/multi_surface.rb +3 -4
  54. data/lib/rgeo/feature/point.rb +4 -5
  55. data/lib/rgeo/feature/polygon.rb +1 -2
  56. data/lib/rgeo/feature/surface.rb +3 -4
  57. data/lib/rgeo/feature/types.rb +73 -83
  58. data/lib/rgeo/geographic/factory.rb +98 -125
  59. data/lib/rgeo/geographic/interface.rb +66 -163
  60. data/lib/rgeo/geographic/projected_feature_classes.rb +21 -9
  61. data/lib/rgeo/geographic/projected_feature_methods.rb +67 -42
  62. data/lib/rgeo/geographic/projected_window.rb +36 -22
  63. data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -5
  64. data/lib/rgeo/geographic/simple_mercator_projector.rb +24 -23
  65. data/lib/rgeo/geographic/spherical_feature_classes.rb +29 -9
  66. data/lib/rgeo/geographic/spherical_feature_methods.rb +86 -9
  67. data/lib/rgeo/geographic/spherical_math.rb +17 -20
  68. data/lib/rgeo/geographic.rb +1 -1
  69. data/lib/rgeo/geos/capi_factory.rb +87 -158
  70. data/lib/rgeo/geos/capi_feature_classes.rb +50 -36
  71. data/lib/rgeo/geos/ffi_factory.rb +95 -165
  72. data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
  73. data/lib/rgeo/geos/ffi_feature_methods.rb +105 -126
  74. data/lib/rgeo/geos/interface.rb +20 -59
  75. data/lib/rgeo/geos/utils.rb +3 -3
  76. data/lib/rgeo/geos/zm_factory.rb +53 -95
  77. data/lib/rgeo/geos/zm_feature_methods.rb +30 -32
  78. data/lib/rgeo/geos.rb +8 -8
  79. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +9 -22
  80. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
  81. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +28 -56
  82. data/lib/rgeo/impl_helper/basic_point_methods.rb +2 -14
  83. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +17 -26
  84. data/lib/rgeo/impl_helper/utils.rb +21 -0
  85. data/lib/rgeo/impl_helper/valid_op.rb +350 -0
  86. data/lib/rgeo/impl_helper/validity_check.rb +139 -0
  87. data/lib/rgeo/impl_helper.rb +1 -0
  88. data/lib/rgeo/version.rb +1 -1
  89. data/lib/rgeo/wkrep/wkb_generator.rb +73 -63
  90. data/lib/rgeo/wkrep/wkb_parser.rb +33 -31
  91. data/lib/rgeo/wkrep/wkt_generator.rb +52 -45
  92. data/lib/rgeo/wkrep/wkt_parser.rb +48 -35
  93. data/lib/rgeo.rb +1 -3
  94. metadata +51 -16
  95. data/lib/rgeo/coord_sys/srs_database/entry.rb +0 -107
  96. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +0 -64
  97. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +0 -65
@@ -6,11 +6,15 @@
6
6
  #
7
7
  # -----------------------------------------------------------------------------
8
8
 
9
+ require "ffi-geos"
10
+
9
11
  module RGeo
10
12
  module Geos
11
13
  module FFIGeometryMethods # :nodoc:
12
14
  include Feature::Instance
13
15
 
16
+ attr_reader :factory, :fg_geom, :_klasses
17
+
14
18
  def initialize(factory, fg_geom, klasses)
15
19
  @factory = factory
16
20
  @fg_geom = fg_geom
@@ -54,11 +58,6 @@ module RGeo
54
58
  @_klasses = nil
55
59
  end
56
60
 
57
- attr_reader :factory
58
- attr_reader :fg_geom
59
-
60
- attr_reader :_klasses # :nodoc:
61
-
62
61
  def initialize_copy(orig)
63
62
  @factory = orig.factory
64
63
  @fg_geom = orig.fg_geom.clone
@@ -75,6 +74,14 @@ module RGeo
75
74
  Utils.ffi_compute_dimension(@fg_geom)
76
75
  end
77
76
 
77
+ def coordinate_dimension
78
+ factory.coordinate_dimension
79
+ end
80
+
81
+ def spatial_dimension
82
+ factory.spatial_dimension
83
+ end
84
+
78
85
  def geometry_type
79
86
  Feature::Geometry
80
87
  end
@@ -84,9 +91,7 @@ module RGeo
84
91
  end
85
92
 
86
93
  def prepare!
87
- if @_fg_prep.is_a?(Integer)
88
- @_fg_prep = ::Geos::PreparedGeometry.new(@fg_geom)
89
- end
94
+ @_fg_prep = ::Geos::PreparedGeometry.new(@fg_geom) if @_fg_prep.is_a?(Integer)
90
95
  self
91
96
  end
92
97
 
@@ -95,11 +100,9 @@ module RGeo
95
100
  end
96
101
 
97
102
  def boundary
98
- if self.class == FFIGeometryCollectionImpl
99
- nil
100
- else
101
- @factory.wrap_fg_geom(@fg_geom.boundary, nil)
102
- end
103
+ @factory.wrap_fg_geom(@fg_geom.boundary, nil)
104
+ rescue ::Geos::GEOSException
105
+ raise Error::InvalidGeometry, "Operation not supported by GeometryCollection"
103
106
  end
104
107
 
105
108
  def as_text
@@ -117,28 +120,45 @@ module RGeo
117
120
  @fg_geom.empty?
118
121
  end
119
122
 
120
- def is_empty?
121
- warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
122
- empty?
123
- end
124
-
125
123
  def simple?
126
124
  @fg_geom.simple?
127
125
  end
128
126
 
129
- def is_simple?
130
- warn "The is_simple? method is deprecated, please use the simple? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
131
- simple?
127
+ def is_3d?
128
+ factory.property(:has_z_coordinate)
129
+ end
130
+
131
+ def measured?
132
+ factory.property(:has_m_coordinate)
133
+ end
134
+
135
+ def valid?
136
+ @fg_geom.valid?
137
+ end
138
+
139
+ def invalid_reason
140
+ # valid_detail gives solely the reason, or nil if valid, which is
141
+ # what we want.
142
+ fg_geom.valid_detail&.dig(:detail)&.force_encoding(Encoding::UTF_8)
143
+ end
144
+
145
+ # (see RGeo::ImplHelper::ValidityCheck#make_valid)
146
+ # Only available since GEOS 3.8+
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
132
153
  end
133
154
 
134
155
  def equals?(rhs)
135
156
  return false unless rhs.is_a?(RGeo::Feature::Instance)
136
157
  fg = factory.convert_to_fg_geometry(rhs)
137
- if !fg
138
- false
158
+
139
159
  # GEOS has a bug where empty geometries are not spatially equal
140
160
  # to each other. Work around this case first.
141
- elsif fg.empty? && @fg_geom.empty?
161
+ if fg.empty? && @fg_geom.empty?
142
162
  true
143
163
  else
144
164
  @fg_geom.eql?(fg)
@@ -148,83 +168,55 @@ module RGeo
148
168
 
149
169
  def disjoint?(rhs)
150
170
  fg = factory.convert_to_fg_geometry(rhs)
151
- if fg
152
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
153
- prep ? prep.disjoint?(fg) : @fg_geom.disjoint?(fg)
154
- else
155
- false
156
- end
171
+ prep = request_prepared if Utils.ffi_supports_prepared_level_2
172
+ prep ? prep.disjoint?(fg) : @fg_geom.disjoint?(fg)
157
173
  end
158
174
 
159
175
  def intersects?(rhs)
160
176
  fg = factory.convert_to_fg_geometry(rhs)
161
- if fg
162
- prep = request_prepared if Utils.ffi_supports_prepared_level_1
163
- prep ? prep.intersects?(fg) : @fg_geom.intersects?(fg)
164
- else
165
- false
166
- end
177
+ prep = request_prepared if Utils.ffi_supports_prepared_level_1
178
+ prep ? prep.intersects?(fg) : @fg_geom.intersects?(fg)
167
179
  end
168
180
 
169
181
  def touches?(rhs)
170
182
  fg = factory.convert_to_fg_geometry(rhs)
171
- if fg
172
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
173
- prep ? prep.touches?(fg) : @fg_geom.touches?(fg)
174
- else
175
- false
176
- end
183
+ prep = request_prepared if Utils.ffi_supports_prepared_level_2
184
+ prep ? prep.touches?(fg) : @fg_geom.touches?(fg)
177
185
  end
178
186
 
179
187
  def crosses?(rhs)
180
188
  fg = factory.convert_to_fg_geometry(rhs)
181
- if fg
182
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
183
- prep ? prep.crosses?(fg) : @fg_geom.crosses?(fg)
184
- else
185
- false
186
- end
189
+ prep = request_prepared if Utils.ffi_supports_prepared_level_2
190
+ prep ? prep.crosses?(fg) : @fg_geom.crosses?(fg)
187
191
  end
188
192
 
189
193
  def within?(rhs)
190
194
  fg = factory.convert_to_fg_geometry(rhs)
191
- if fg
192
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
193
- prep ? prep.within?(fg) : @fg_geom.within?(fg)
194
- else
195
- false
196
- end
195
+ prep = request_prepared if Utils.ffi_supports_prepared_level_2
196
+ prep ? prep.within?(fg) : @fg_geom.within?(fg)
197
197
  end
198
198
 
199
199
  def contains?(rhs)
200
200
  fg = factory.convert_to_fg_geometry(rhs)
201
- if fg
202
- prep = request_prepared if Utils.ffi_supports_prepared_level_1
203
- prep ? prep.contains?(fg) : @fg_geom.contains?(fg)
204
- else
205
- false
206
- end
201
+ prep = request_prepared if Utils.ffi_supports_prepared_level_1
202
+ prep ? prep.contains?(fg) : @fg_geom.contains?(fg)
207
203
  end
208
204
 
209
205
  def overlaps?(rhs)
210
206
  fg = factory.convert_to_fg_geometry(rhs)
211
- if fg
212
- prep = request_prepared if Utils.ffi_supports_prepared_level_2
213
- prep ? prep.overlaps?(fg) : @fg_geom.overlaps?(fg)
214
- else
215
- false
216
- end
207
+ prep = request_prepared if Utils.ffi_supports_prepared_level_2
208
+ prep ? prep.overlaps?(fg) : @fg_geom.overlaps?(fg)
217
209
  end
218
210
 
219
211
  def relate?(rhs, pattern)
220
212
  fg = factory.convert_to_fg_geometry(rhs)
221
- fg ? @fg_geom.relate_pattern(fg, pattern) : nil
213
+ @fg_geom.relate_pattern(fg, pattern)
222
214
  end
223
215
  alias relate relate? # DEPRECATED
224
216
 
225
217
  def distance(rhs)
226
218
  fg = factory.convert_to_fg_geometry(rhs)
227
- fg ? @fg_geom.distance(fg) : nil
219
+ @fg_geom.distance(fg)
228
220
  end
229
221
 
230
222
  def buffer(distance)
@@ -237,14 +229,14 @@ module RGeo
237
229
 
238
230
  def intersection(rhs)
239
231
  fg = factory.convert_to_fg_geometry(rhs)
240
- fg ? @factory.wrap_fg_geom(@fg_geom.intersection(fg), nil) : nil
232
+ @factory.wrap_fg_geom(@fg_geom.intersection(fg), nil)
241
233
  end
242
234
 
243
235
  alias * intersection
244
236
 
245
237
  def union(rhs)
246
238
  fg = factory.convert_to_fg_geometry(rhs)
247
- fg ? @factory.wrap_fg_geom(@fg_geom.union(fg), nil) : nil
239
+ @factory.wrap_fg_geom(@fg_geom.union(fg), nil)
248
240
  end
249
241
 
250
242
  alias + union
@@ -256,18 +248,18 @@ module RGeo
256
248
 
257
249
  def difference(rhs)
258
250
  fg = factory.convert_to_fg_geometry(rhs)
259
- fg ? @factory.wrap_fg_geom(@fg_geom.difference(fg), nil) : nil
251
+ @factory.wrap_fg_geom(@fg_geom.difference(fg), nil)
260
252
  end
261
253
 
262
254
  alias - difference
263
255
 
264
256
  def sym_difference(rhs)
265
257
  fg = factory.convert_to_fg_geometry(rhs)
266
- fg ? @factory.wrap_fg_geom(@fg_geom.sym_difference(fg), nil) : nil
258
+ @factory.wrap_fg_geom(@fg_geom.sym_difference(fg), nil)
267
259
  end
268
260
 
269
- def eql?(rhs)
270
- rep_equals?(rhs)
261
+ def eql?(other)
262
+ rep_equals?(other)
271
263
  end
272
264
 
273
265
  def detach_fg_geom
@@ -319,7 +311,7 @@ module RGeo
319
311
  end
320
312
 
321
313
  def rep_equals?(rhs)
322
- rhs.class == self.class && rhs.factory.eql?(@factory) &&
314
+ rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
323
315
  Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
324
316
  end
325
317
 
@@ -348,14 +340,15 @@ module RGeo
348
340
  @fg_geom.num_points
349
341
  end
350
342
 
351
- def point_n(n)
352
- if n >= 0 && n < @fg_geom.num_points
353
- coord_seq = @fg_geom.coord_seq
354
- x = coord_seq.get_x(n)
355
- y = coord_seq.get_y(n)
356
- extra = @factory._has_3d ? [coord_seq.get_z(n)] : []
357
- @factory.point(x, y, *extra)
358
- end
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)
359
352
  end
360
353
 
361
354
  def start_point
@@ -381,22 +374,12 @@ module RGeo
381
374
  @fg_geom.closed?
382
375
  end
383
376
 
384
- def is_closed?
385
- warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
386
- closed?
387
- end
388
-
389
377
  def ring?
390
378
  @fg_geom.ring?
391
379
  end
392
380
 
393
- def is_ring?
394
- warn "The is_ring? method is deprecated, please use the ring? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
395
- ring?
396
- end
397
-
398
381
  def rep_equals?(rhs)
399
- rhs.class == self.class && rhs.factory.eql?(@factory) &&
382
+ rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
400
383
  Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
401
384
  end
402
385
 
@@ -450,10 +433,10 @@ module RGeo
450
433
  @fg_geom.num_interior_rings
451
434
  end
452
435
 
453
- def interior_ring_n(n)
454
- if n >= 0 && n < @fg_geom.num_interior_rings
455
- @factory.wrap_fg_geom(@fg_geom.interior_ring_n(n), FFILinearRingImpl)
456
- end
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)
457
440
  end
458
441
 
459
442
  def interior_rings
@@ -463,7 +446,7 @@ module RGeo
463
446
  end
464
447
 
465
448
  def rep_equals?(rhs)
466
- if rhs.class == self.class && rhs.factory.eql?(@factory) &&
449
+ if rhs.instance_of?(self.class) && rhs.factory.eql?(@factory) &&
467
450
  rhs.exterior_ring.rep_equals?(exterior_ring)
468
451
  sn = @fg_geom.num_interior_rings
469
452
  rn = rhs.num_interior_rings
@@ -479,8 +462,10 @@ module RGeo
479
462
 
480
463
  def hash
481
464
  @hash ||= begin
482
- hash = Utils.ffi_coord_seq_hash(@fg_geom.exterior_ring.coord_seq,
483
- [@factory, geometry_type].hash)
465
+ hash = Utils.ffi_coord_seq_hash(
466
+ @fg_geom.exterior_ring.coord_seq,
467
+ [@factory, geometry_type].hash
468
+ )
484
469
  @fg_geom.interior_rings.inject(hash) do |h, r|
485
470
  Utils.ffi_coord_seq_hash(r.coord_seq, h)
486
471
  end
@@ -498,7 +483,7 @@ module RGeo
498
483
  end
499
484
 
500
485
  def rep_equals?(rhs)
501
- if rhs.class == self.class && rhs.factory.eql?(@factory)
486
+ if rhs.instance_of?(self.class) && rhs.factory.eql?(@factory)
502
487
  size = @fg_geom.num_geometries
503
488
  if size == rhs.num_geometries
504
489
  size.times do |n|
@@ -515,35 +500,34 @@ module RGeo
515
500
  end
516
501
  alias size num_geometries
517
502
 
518
- def geometry_n(n)
519
- if n >= 0 && n < @fg_geom.num_geometries
520
- @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n),
521
- @_klasses ? @_klasses[n] : nil)
522
- end
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
+ )
523
510
  end
524
511
 
525
- def [](n)
526
- n += @fg_geom.num_geometries if n < 0
527
- if n >= 0 && n < @fg_geom.num_geometries
528
- @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n),
529
- @_klasses ? @_klasses[n] : nil)
530
- end
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
+ )
531
521
  end
532
522
 
533
523
  def hash
534
- @hash ||= begin
535
- hash = [@factory, geometry_type].hash
536
- (0...num_geometries).inject(hash) do |h, i|
537
- (1_664_525 * h + geometry_n(i).hash).hash
538
- end
539
- end
524
+ @hash ||= [@factory, geometry_type, *(0...num_geometries).map { |i| geometry_n(i) }].hash
540
525
  end
541
526
 
542
527
  def each
543
528
  if block_given?
544
529
  @fg_geom.num_geometries.times do |n|
545
- yield @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n),
546
- @_klasses ? @_klasses[n] : nil)
530
+ yield @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n), @_klasses ? @_klasses[n] : nil)
547
531
  end
548
532
  self
549
533
  else
@@ -581,11 +565,6 @@ module RGeo
581
565
  true
582
566
  end
583
567
 
584
- def is_closed?
585
- warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
586
- closed?
587
- end
588
-
589
568
  def coordinates
590
569
  each.map(&:coordinates)
591
570
  end
@@ -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
- if RGeo::Geos::CAPI_SUPPORTED
81
- @version = RGeo::Geos::CAPIFactory._geos_version.freeze
82
- elsif RGeo::Geos::FFI_SUPPORTED
83
- @version = ::Geos::FFIGeos.GEOSversion.sub(/-CAPI-.*$/, "").freeze
84
- else
85
- @version = nil
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
@@ -116,13 +100,6 @@ module RGeo
116
100
  # Specifies which native interface to use. Possible values are
117
101
  # <tt>:capi</tt> and <tt>:ffi</tt>. The default is the value
118
102
  # of the preferred_native_interface.
119
- # [<tt>:uses_lenient_multi_polygon_assertions</tt>]
120
- # If set to true, assertion checking on MultiPolygon is disabled.
121
- # This may speed up creation of MultiPolygon objects, at the
122
- # expense of not doing the proper checking for OGC MultiPolygon
123
- # compliance. See RGeo::Feature::MultiPolygon for details on
124
- # the MultiPolygon assertions. Default is false. Also called
125
- # <tt>:lenient_multi_polygon_assertions</tt>.
126
103
  # [<tt>:buffer_resolution</tt>]
127
104
  # The resolution of buffers around geometries created by this
128
105
  # factory. This controls the number of line segments used to
@@ -134,19 +111,14 @@ module RGeo
134
111
  # [<tt>:srid</tt>]
135
112
  # Set the SRID returned by geometries created by this factory.
136
113
  # Default is 0.
137
- # [<tt>:proj4</tt>]
138
- # The coordinate system in Proj4 format, either as a
139
- # CoordSys::Proj4 object or as a string or hash representing the
140
- # proj4 format. Optional.
141
114
  # [<tt>:coord_sys</tt>]
142
115
  # The coordinate system in OGC form, either as a subclass of
143
116
  # CoordSys::CS::CoordinateSystem, or as a string in WKT format.
144
- # Optional.
145
- # [<tt>:srs_database</tt>]
146
- # Optional. If provided, the object should respond to #get and
147
- # #clear_cache. If both this and an SRID are
148
- # provided, they are used to look up the proj4 and coord_sys
149
- # objects from a spatial reference system database.
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.
150
122
  # [<tt>:has_z_coordinate</tt>]
151
123
  # Support <tt>z_coordinate</tt>. Default is false.
152
124
  # [<tt>:has_m_coordinate</tt>]
@@ -190,28 +162,17 @@ module RGeo
190
162
  # never automatically generates a prepared geometry (unless you
191
163
  # generate one explicitly using the <tt>prepare!</tt> method).
192
164
  def factory(opts = {})
193
- if supported?
194
- native_interface = opts[:native_interface] || Geos.preferred_native_interface
195
- if opts[:has_z_coordinate] && opts[:has_m_coordinate]
196
- ZMFactory.new(opts)
197
- elsif native_interface == :ffi
198
- FFIFactory.new(opts)
199
- else
200
- CAPIFactory.create(opts)
201
- end
202
- end
203
- end
165
+ return unless supported?
204
166
 
205
- # Returns a Feature::FactoryGenerator that creates Geos-backed
206
- # factories. The given options are used as the default options.
207
- #
208
- # A common case for this is to provide the <tt>:srs_database</tt>
209
- # as a default. Then, the factory generator need only be passed
210
- # an SRID and it will automatically fetch the appropriate Proj4
211
- # and CoordSys objects.
167
+ native_interface = opts[:native_interface] || Geos.preferred_native_interface
212
168
 
213
- def factory_generator(defaults = {})
214
- proc { |c| factory(defaults.merge(c)) }
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
+ end
215
176
  end
216
177
  end
217
178
  end
@@ -49,9 +49,9 @@ module RGeo
49
49
  result
50
50
  end
51
51
 
52
- def ffi_coord_seq_hash(cs, hash = 0)
53
- (0...cs.length).inject(hash) do |h, i|
54
- [hash, cs.get_x(i), cs.get_y(i), cs.get_z(i)].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