ffi-geos 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +2 -2
  3. data/.rbenv-vars +1 -0
  4. data/.rubocop.yml +538 -92
  5. data/.rubocop_todo.yml +28 -18
  6. data/ffi-geos.gemspec +2 -2
  7. data/lib/ffi-geos/coordinate_sequence.rb +2 -1
  8. data/lib/ffi-geos/geometry.rb +95 -1
  9. data/lib/ffi-geos/point.rb +9 -0
  10. data/lib/ffi-geos/version.rb +1 -1
  11. data/lib/ffi-geos.rb +78 -3
  12. data/test/coordinate_sequence_tests.rb +22 -4
  13. data/test/geojson_reader_tests.rb +6 -2
  14. data/test/geometry/area_tests.rb +18 -0
  15. data/test/geometry/boundary_tests.rb +36 -0
  16. data/test/geometry/buffer_tests.rb +116 -0
  17. data/test/geometry/build_area_tests.rb +20 -0
  18. data/test/geometry/centroid_tests.rb +37 -0
  19. data/test/geometry/clip_by_rect_tests.rb +56 -0
  20. data/test/geometry/clone_tests.rb +29 -0
  21. data/test/geometry/concave_hull_of_polygons_tests.rb +28 -0
  22. data/test/geometry/concave_hull_tests.rb +38 -0
  23. data/test/geometry/convex_hull_tests.rb +26 -0
  24. data/test/geometry/coord_seq_tests.rb +27 -0
  25. data/test/geometry/delaunay_triangulation_tests.rb +82 -0
  26. data/test/geometry/densify_tests.rb +95 -0
  27. data/test/geometry/difference_tests.rb +108 -0
  28. data/test/geometry/dimensions_tests.rb +46 -0
  29. data/test/geometry/distance_tests.rb +29 -0
  30. data/test/geometry/dump_points_tests.rb +60 -0
  31. data/test/geometry/dup_tests.rb +29 -0
  32. data/test/geometry/empty_tests.rb +23 -0
  33. data/test/geometry/envelope_tests.rb +26 -0
  34. data/test/geometry/equal_identical_tests.rb +78 -0
  35. data/test/geometry/equal_tests.rb +62 -0
  36. data/test/geometry/exterior_ring_tests.rb +27 -0
  37. data/test/geometry/extract_unique_points_tests.rb +41 -0
  38. data/test/geometry/frecet_distance_tests.rb +24 -0
  39. data/test/geometry/get_geometry_n_tests.rb +21 -0
  40. data/test/geometry/hausdorff_distance_tests.rb +46 -0
  41. data/test/geometry/hilbert_code_tests.rb +45 -0
  42. data/test/geometry/interior_ring_n_tests.rb +64 -0
  43. data/test/geometry/interior_rings_tests.rb +36 -0
  44. data/test/geometry/interpolate_tests.rb +49 -0
  45. data/test/geometry/intersection_tests.rb +49 -0
  46. data/test/geometry/largest_empty_circle_tests.rb +26 -0
  47. data/test/geometry/length_tests.rb +18 -0
  48. data/test/geometry/line_merge_directed_tests.rb +28 -0
  49. data/test/geometry/line_merge_tests.rb +25 -0
  50. data/test/geometry/line_string_enumerator_tests.rb +20 -0
  51. data/test/geometry/line_substring_tests.rb +76 -0
  52. data/test/geometry/make_valid_tests.rb +27 -0
  53. data/test/geometry/maximum_inscribed_circle_tests.rb +21 -0
  54. data/test/geometry/minimum_bounding_circle_tests.rb +23 -0
  55. data/test/geometry/minimum_clearance_tests.rb +58 -0
  56. data/test/geometry/minimum_rotated_rectangle_tests.rb +28 -0
  57. data/test/geometry/minimum_width_tests.rb +26 -0
  58. data/test/geometry/misc_tests.rb +24 -0
  59. data/test/geometry/nearest_points_tests.rb +46 -0
  60. data/test/geometry/node_tests.rb +22 -0
  61. data/test/geometry/normalize_tests.rb +34 -0
  62. data/test/geometry/num_coordinates_tests.rb +39 -0
  63. data/test/geometry/num_goemetries_tests.rb +35 -0
  64. data/test/geometry/num_interior_rings_tests.rb +28 -0
  65. data/test/geometry/orient_polygons_tests.rb +101 -0
  66. data/test/geometry/point_on_surface_tests.rb +37 -0
  67. data/test/geometry/polygon_hull_simplify_tests.rb +55 -0
  68. data/test/geometry/polygonize_tests.rb +173 -0
  69. data/test/geometry/precision_tests.rb +42 -0
  70. data/test/geometry/project_tests.rb +56 -0
  71. data/test/geometry/relate_tests.rb +73 -0
  72. data/test/geometry/relationships_tests.rb +138 -0
  73. data/test/geometry/reverse_tests.rb +44 -0
  74. data/test/geometry/ring_tests.rb +18 -0
  75. data/test/geometry/shared_path_tests.rb +31 -0
  76. data/test/geometry/simple_tests.rb +18 -0
  77. data/test/geometry/simplify_tests.rb +21 -0
  78. data/test/geometry/snap_tests.rb +20 -0
  79. data/test/geometry/srid_copy_policy_tests.rb +94 -0
  80. data/test/geometry/start_and_end_point_tests.rb +24 -0
  81. data/test/geometry/sym_difference_tests.rb +114 -0
  82. data/test/geometry/topology_preserve_simplify_tests.rb +21 -0
  83. data/test/geometry/union_tests.rb +216 -0
  84. data/test/geometry/valid_tests.rb +56 -0
  85. data/test/geometry/voronoi_diagram_tests.rb +62 -0
  86. data/test/geometry_collection_tests.rb +14 -2
  87. data/test/interrupt_tests.rb +1 -1
  88. data/test/line_string_tests.rb +24 -3
  89. data/test/misc_tests.rb +1 -1
  90. data/test/point/has_m_tests.rb +43 -0
  91. data/test/point/x_y_z_m_tests.rb +51 -0
  92. data/test/point_tests.rb +25 -3
  93. data/test/polygon_tests.rb +14 -1
  94. data/test/prepared_geometry_tests.rb +6 -5
  95. data/test/strtree_tests.rb +11 -18
  96. data/test/test_helper.rb +2 -0
  97. data/test/tools_tests.rb +7 -0
  98. data/test/utils_tests.rb +14 -3
  99. data/test/wkb_reader_tests.rb +1 -0
  100. data/test/wkb_writer_tests.rb +26 -5
  101. data/test/wkt_reader_tests.rb +2 -0
  102. data/test/wkt_writer_tests.rb +20 -2
  103. metadata +154 -7
  104. data/test/geometry_tests.rb +0 -2114
data/.rubocop_todo.yml CHANGED
@@ -1,24 +1,27 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 10000`
3
- # on 2022-06-13 13:21:07 UTC using RuboCop version 1.30.1.
3
+ # on 2024-04-19 02:14:33 UTC using RuboCop version 1.62.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
- Lint/BinaryOperatorWithIdenticalOperands:
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: Severity, Include.
12
+ # Include: **/*.gemspec
13
+ Gemspec/DeprecatedAttributeAssignment:
11
14
  Exclude:
12
- - 'test/geometry_tests.rb'
15
+ - 'ffi-geos.gemspec'
13
16
 
14
17
  # Offense count: 6
15
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes, Max.
18
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
16
19
  Metrics/AbcSize:
17
20
  Exclude:
18
21
  - 'lib/ffi-geos/coordinate_sequence.rb'
19
22
  - 'lib/ffi-geos/line_string.rb'
20
23
  - 'lib/ffi-geos/utils.rb'
21
- - 'test/geometry_tests.rb'
24
+ - 'test/geometry/polygonize_tests.rb'
22
25
 
23
26
  # Offense count: 2
24
27
  # Configuration parameters: CountComments, Max, CountAsOne.
@@ -28,7 +31,7 @@ Metrics/ClassLength:
28
31
  - 'lib/ffi-geos/geometry.rb'
29
32
 
30
33
  # Offense count: 3
31
- # Configuration parameters: IgnoredMethods, Max.
34
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
32
35
  Metrics/CyclomaticComplexity:
33
36
  Exclude:
34
37
  - 'lib/ffi-geos/coordinate_sequence.rb'
@@ -46,13 +49,22 @@ Metrics/ParameterLists:
46
49
  Exclude:
47
50
  - 'lib/ffi-geos/utils.rb'
48
51
 
49
- # Offense count: 4
50
- # Configuration parameters: IgnoredMethods, Max.
52
+ # Offense count: 7
53
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
51
54
  Metrics/PerceivedComplexity:
52
55
  Exclude:
53
56
  - 'lib/ffi-geos/coordinate_sequence.rb'
54
57
  - 'lib/ffi-geos/tools.rb'
55
- - 'test/geometry_tests.rb'
58
+ - 'test/geometry/sym_difference_tests.rb'
59
+ - 'test/geometry/union_tests.rb'
60
+ - 'test/geometry/voronoi_diagram_tests.rb'
61
+ - 'test/line_string_tests.rb'
62
+
63
+ # Offense count: 5
64
+ Minitest/AssertRaisesCompoundBody:
65
+ Exclude:
66
+ - 'test/geometry/polygonize_tests.rb'
67
+ - 'test/utils_tests.rb'
56
68
 
57
69
  # Offense count: 9
58
70
  Naming/AccessorMethodName:
@@ -70,7 +82,7 @@ Naming/FileName:
70
82
  Exclude:
71
83
  - 'lib/ffi-geos.rb'
72
84
 
73
- # Offense count: 2
85
+ # Offense count: 1
74
86
  # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
75
87
  # NamePrefix: is_, has_, have_
76
88
  # ForbiddenPrefixes: is_, has_, have_
@@ -78,17 +90,15 @@ Naming/FileName:
78
90
  # MethodDefinitionMacros: define_method, define_singleton_method
79
91
  Naming/PredicateName:
80
92
  Exclude:
81
- - 'lib/ffi-geos/coordinate_sequence.rb'
82
93
  - 'lib/ffi-geos/geometry.rb'
83
94
 
84
- # Offense count: 2
85
- # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
86
- # SupportedStyles: snake_case, normalcase, non_integer
87
- # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
88
- Naming/VariableNumber:
95
+ # Offense count: 1
96
+ # This cop supports unsafe autocorrection (--autocorrect-all).
97
+ # Configuration parameters: AllowedReceivers.
98
+ # AllowedReceivers: Thread.current
99
+ Style/HashEachMethods:
89
100
  Exclude:
90
- - 'lib/ffi-geos.rb'
91
- - 'lib/ffi-geos/geometry.rb'
101
+ - 'lib/ffi-geos/strtree.rb'
92
102
 
93
103
  # Offense count: 4
94
104
  # Configuration parameters: AllowedMethods.
data/ffi-geos.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Geos::VERSION
8
8
 
9
9
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10
- s.required_ruby_version = '>= 2.6'
10
+ s.required_ruby_version = '>= 2.7'
11
11
 
12
12
  s.authors = ['J Smith']
13
13
  s.description = 'An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).'
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
21
21
  s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
22
22
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
23
- s.homepage = 'http://github.com/dark-panda/ffi-geos'
23
+ s.homepage = 'https://github.com/dark-panda/ffi-geos'
24
24
  s.require_paths = ['lib']
25
25
 
26
26
  s.add_dependency('ffi', ['>= 1.0.0'])
@@ -154,9 +154,10 @@ module Geos
154
154
  end
155
155
  alias slice []
156
156
 
157
- def has_z?
157
+ def z?
158
158
  dimensions == 3
159
159
  end
160
+ alias has_z? z?
160
161
 
161
162
  # Sets the x value of a coordinate. Can also be set via #x[]=.
162
163
  def set_x(idx, val)
@@ -59,6 +59,18 @@ module Geos
59
59
  end
60
60
  alias normalize normalize!
61
61
 
62
+ if FFIGeos.respond_to?(:GEOSOrientPolygons_r)
63
+ def orient_polygons!(exterior_cw = false)
64
+ raise Geos::GEOSException, self.class if FFIGeos.GEOSOrientPolygons_r(Geos.current_handle_pointer, ptr, bool_to_int(exterior_cw)) == -1
65
+
66
+ self
67
+ end
68
+
69
+ def orient_polygons(exterior_cw = false)
70
+ dup.orient_polygons!(exterior_cw)
71
+ end
72
+ end
73
+
62
74
  def srid
63
75
  FFIGeos.GEOSGetSRID_r(Geos.current_handle_pointer, ptr)
64
76
  end
@@ -140,10 +152,43 @@ module Geos
140
152
  end
141
153
  end
142
154
 
155
+ if FFIGeos.respond_to?(:GEOSDensify_r)
156
+ def densify(tolerance = 0.0)
157
+ cast_geometry_ptr(FFIGeos.GEOSDensify_r(Geos.current_handle_pointer, ptr, tolerance), srid_copy: srid)
158
+ end
159
+ end
160
+
143
161
  def convex_hull
144
162
  cast_geometry_ptr(FFIGeos.GEOSConvexHull_r(Geos.current_handle_pointer, ptr), srid_copy: srid)
145
163
  end
146
164
 
165
+ if FFIGeos.respond_to?(:GEOSConcaveHull_r) && FFIGeos.respond_to?(:GEOSConcaveHullByLength_r)
166
+ def concave_hull(ratio: 0.0, allow_holes: false, length: nil)
167
+ cast_geometry_ptr(
168
+ case length
169
+ when Numeric
170
+ FFIGeos.GEOSConcaveHullByLength_r(Geos.current_handle_pointer, ptr, length, bool_to_int(allow_holes))
171
+ else
172
+ FFIGeos.GEOSConcaveHull_r(Geos.current_handle_pointer, ptr, ratio, bool_to_int(allow_holes))
173
+ end,
174
+ srid_copy: srid
175
+ )
176
+ end
177
+ end
178
+
179
+ if FFIGeos.respond_to?(:GEOSPolygonHullSimplify_r) && FFIGeos.respond_to?(:GEOSPolygonHullSimplifyMode_r)
180
+ def polygon_hull_simplify(parameter, outer: false, mode: :vertex_ratio)
181
+ check_enum_value(Geos::PolygonHullSimplifyModes, mode)
182
+
183
+ case mode
184
+ when :vertex_ratio
185
+ cast_geometry_ptr(FFIGeos.GEOSPolygonHullSimplify_r(Geos.current_handle_pointer, ptr, bool_to_int(outer), parameter), srid_copy: srid)
186
+ when :area_ratio
187
+ cast_geometry_ptr(FFIGeos.GEOSPolygonHullSimplifyMode_r(Geos.current_handle_pointer, ptr, bool_to_int(outer), 2, parameter), srid_copy: srid)
188
+ end
189
+ end
190
+ end
191
+
147
192
  def difference(geom, precision: nil)
148
193
  check_geometry(geom)
149
194
 
@@ -199,6 +244,13 @@ module Geos
199
244
  end
200
245
  end
201
246
 
247
+ if FFIGeos.respond_to?(:GEOSDisjointSubsetUnion_r)
248
+ # Added in GEOS 3.12+
249
+ def disjoint_subset_union
250
+ cast_geometry_ptr(FFIGeos.GEOSDisjointSubsetUnion_r(Geos.current_handle_pointer, ptr), srid_copy: srid)
251
+ end
252
+ end
253
+
202
254
  if FFIGeos.respond_to?(:GEOSUnaryUnion_r)
203
255
  # Available in GEOS 3.3+
204
256
  def unary_union(precision = nil)
@@ -235,6 +287,15 @@ module Geos
235
287
  end
236
288
  alias center centroid
237
289
 
290
+ if FFIGeos.respond_to?(:GEOSHilbertCode_r)
291
+ def hilbert_code(extent, level)
292
+ check_geometry(extent)
293
+ code_ptr = FFI::MemoryPointer.new(:uint)
294
+ FFIGeos.GEOSHilbertCode_r(Geos.current_handle_pointer, ptr, extent.ptr, level, code_ptr)
295
+ code_ptr.read_uint
296
+ end
297
+ end
298
+
238
299
  if FFIGeos.respond_to?(:GEOSMinimumBoundingCircle_r)
239
300
  # Added in GEOS 3.8+. Does not yet support the radius or center
240
301
  # arguments.
@@ -273,6 +334,19 @@ module Geos
273
334
  cast_geometry_ptr(FFIGeos.GEOSLineMerge_r(Geos.current_handle_pointer, ptr), srid_copy: srid)
274
335
  end
275
336
 
337
+ if FFIGeos.respond_to?(:GEOSLineMergeDirected_r)
338
+ def line_merge_directed
339
+ cast_geometry_ptr(FFIGeos.GEOSLineMergeDirected_r(Geos.current_handle_pointer, ptr), srid_copy: srid)
340
+ end
341
+ end
342
+
343
+ if FFIGeos.respond_to?(:GEOSLineSubstring_r)
344
+ # Added in GEOS 3.12+
345
+ def line_substring(start_fraction, end_fraction)
346
+ cast_geometry_ptr(FFIGeos.GEOSLineSubstring_r(Geos.current_handle_pointer, ptr, start_fraction, end_fraction), srid_copy: srid)
347
+ end
348
+ end
349
+
276
350
  def simplify(tolerance)
277
351
  cast_geometry_ptr(FFIGeos.GEOSSimplify_r(Geos.current_handle_pointer, ptr, tolerance), srid_copy: srid)
278
352
  end
@@ -384,6 +458,14 @@ module Geos
384
458
  alias equals_exact? eql_exact?
385
459
  alias exactly_equals? eql_exact?
386
460
 
461
+ if FFIGeos.respond_to?(:GEOSEqualsIdentical_r)
462
+ def eql_identical?(other)
463
+ check_geometry(other)
464
+ bool_result(FFIGeos.GEOSEqualsIdentical_r(Geos.current_handle_pointer, ptr, other.ptr))
465
+ end
466
+ alias equals_identical? eql_identical?
467
+ end
468
+
387
469
  def eql_almost?(other, decimal = 6)
388
470
  check_geometry(other)
389
471
  bool_result(FFIGeos.GEOSEqualsExact_r(Geos.current_handle_pointer, ptr, other.ptr, 0.5 * (10 ** -decimal)))
@@ -439,6 +521,12 @@ module Geos
439
521
  bool_result(FFIGeos.GEOSHasZ_r(Geos.current_handle_pointer, ptr))
440
522
  end
441
523
 
524
+ if FFIGeos.respond_to?(:GEOSHasM_r)
525
+ def has_m?
526
+ bool_result(FFIGeos.GEOSHasM_r(Geos.current_handle_pointer, ptr))
527
+ end
528
+ end
529
+
442
530
  # GEOS versions prior to 3.3.0 didn't handle exceptions and can crash on
443
531
  # bad input.
444
532
  if FFIGeos.respond_to?(:GEOSProject_r) && Geos::GEOS_NICE_VERSION >= '030300'
@@ -533,7 +621,7 @@ module Geos
533
621
  check_geometry(geom)
534
622
  nearest_points_ptr = FFIGeos.GEOSNearestPoints_r(Geos.current_handle_pointer, ptr, geom.ptr)
535
623
 
536
- return CoordinateSequence.new(nearest_points_ptr) unless nearest_points_ptr.null?
624
+ CoordinateSequence.new(nearest_points_ptr) unless nearest_points_ptr.null?
537
625
  end
538
626
  end
539
627
 
@@ -705,6 +793,12 @@ module Geos
705
793
  end
706
794
  end
707
795
 
796
+ if FFIGeos.respond_to?(:GEOSConcaveHullOfPolygons_r)
797
+ def concave_hull_of_polygons(length_ratio, tight: false, allow_holes: false)
798
+ cast_geometry_ptr(FFIGeos.GEOSConcaveHullOfPolygons_r(Geos.current_handle_pointer, ptr, length_ratio, bool_to_int(tight), bool_to_int(allow_holes)), srid_copy: srid)
799
+ end
800
+ end
801
+
708
802
  if FFIGeos.respond_to?(:GEOSMinimumRotatedRectangle_r)
709
803
  def minimum_rotated_rectangle
710
804
  cast_geometry_ptr(FFIGeos.GEOSMinimumRotatedRectangle_r(Geos.current_handle_pointer, ptr))
@@ -41,6 +41,15 @@ module Geos
41
41
  end
42
42
  alias z get_z
43
43
 
44
+ if FFIGeos.respond_to?(:GEOSGeomGetM_r)
45
+ def get_m
46
+ double_ptr = FFI::MemoryPointer.new(:double)
47
+ FFIGeos.GEOSGeomGetM_r(Geos.current_handle_pointer, ptr, double_ptr)
48
+ double_ptr.read_double
49
+ end
50
+ alias m get_m
51
+ end
52
+
44
53
  def area
45
54
  0
46
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Geos
4
- VERSION = '2.4.0'
4
+ VERSION = '2.5.0'
5
5
  end
data/lib/ffi-geos.rb CHANGED
@@ -54,7 +54,7 @@ module Geos
54
54
 
55
55
  module FFIGeos
56
56
  def self.search_paths
57
- @search_paths ||= \
57
+ @search_paths ||=
58
58
  if ENV['GEOS_LIBRARY_PATH']
59
59
  [ENV['GEOS_LIBRARY_PATH']]
60
60
  elsif FFI::Platform::IS_WINDOWS
@@ -81,7 +81,7 @@ module Geos
81
81
  end
82
82
 
83
83
  def self.geos_library_path
84
- @geos_library_path ||= \
84
+ @geos_library_path ||=
85
85
  # On MingW the libraries have version numbers
86
86
  find_lib('{lib,}geos_c{,-?}')
87
87
  end
@@ -153,6 +153,11 @@ module Geos
153
153
  :keep_collapsed, 1 << 1
154
154
  ])
155
155
 
156
+ Geos::PolygonHullSimplifyModes = enum(:polygon_hull_simplify_mode, [
157
+ :vertex_ratio, 1,
158
+ :area_ratio, 2
159
+ ])
160
+
156
161
  FFI_LAYOUT = {
157
162
  #### Utility functions ####
158
163
 
@@ -439,6 +444,11 @@ module Geos
439
444
  :pointer, :pointer, :pointer, :double, :int, :buffer_cap_style, :buffer_join_style, :double
440
445
  ],
441
446
 
447
+ GEOSDensify_r: [
448
+ # *geom, *handle, *geom, tolerence
449
+ :pointer, :pointer, :pointer, :double
450
+ ],
451
+
442
452
  # Deprecated in GEOS 3.3.0.
443
453
  GEOSSingleSidedBuffer_r: [
444
454
  # *geom, *handle, *geom, width, quad_segs, buffer_join_style, mitre_limit, is_left
@@ -455,6 +465,26 @@ module Geos
455
465
  :pointer, :pointer, :pointer
456
466
  ],
457
467
 
468
+ GEOSConcaveHull_r: [
469
+ # *geom, *handle, *geom, ratio, allow_holes
470
+ :pointer, :pointer, :pointer, :double, :uint
471
+ ],
472
+
473
+ GEOSConcaveHullByLength_r: [
474
+ # *geom, *handle, *geom, length, allow_holes
475
+ :pointer, :pointer, :pointer, :double, :uint
476
+ ],
477
+
478
+ GEOSPolygonHullSimplify_r: [
479
+ # *geom, *handle, *geom, is_outer, vertex_num_fraction
480
+ :pointer, :pointer, :pointer, :uint, :double
481
+ ],
482
+
483
+ GEOSPolygonHullSimplifyMode_r: [
484
+ # *geom, *handle, *geom, is_outer, parameter_mode, parameter
485
+ :pointer, :pointer, :pointer, :uint, :uint, :double
486
+ ],
487
+
458
488
  GEOSDifference_r: [
459
489
  # *geom, *handle, *geom_a, *geom_b
460
490
  :pointer, :pointer, :pointer, :pointer
@@ -495,6 +525,11 @@ module Geos
495
525
  :pointer, :pointer, :pointer
496
526
  ],
497
527
 
528
+ GEOSDisjointSubsetUnion_r: [
529
+ # *geom, *handle, *geom
530
+ :pointer, :pointer, :pointer
531
+ ],
532
+
498
533
  GEOSUnaryUnion_r: [
499
534
  # *geom, *handle, *geom
500
535
  :pointer, :pointer, :pointer
@@ -531,6 +566,11 @@ module Geos
531
566
  :pointer, :pointer, :pointer
532
567
  ],
533
568
 
569
+ GEOSHilbertCode_r: [
570
+ # int, *handler, *geom, *extent, level, *code
571
+ :int, :pointer, :pointer, :pointer, :uint, :pointer
572
+ ],
573
+
534
574
  GEOSMinimumBoundingCircle_r: [
535
575
  # *geom, *handle, *geom, *double radius, **geom center
536
576
  :pointer, :pointer, :pointer, :pointer, :pointer
@@ -546,6 +586,16 @@ module Geos
546
586
  :pointer, :pointer, :pointer
547
587
  ],
548
588
 
589
+ GEOSLineMergeDirected_r: [
590
+ # *geom, *handle, *geom
591
+ :pointer, :pointer, :pointer
592
+ ],
593
+
594
+ GEOSLineSubstring_r: [
595
+ # *geom, *handle, *geom, start_fraction, end_fraction
596
+ :pointer, :pointer, :pointer, :double, :double
597
+ ],
598
+
549
599
  GEOSGeom_getXMin_r: [
550
600
  # 0 on exception, *handle, (double *) value
551
601
  :int, :pointer, :pointer, :pointer
@@ -681,6 +731,11 @@ module Geos
681
731
  :char, :pointer, :pointer, :pointer, :double
682
732
  ],
683
733
 
734
+ GEOSEqualsIdentical_r: [
735
+ # (2 on exception, 1 on true, 2 on false), *handle, *geom_a, *geom_b
736
+ :char, :pointer, :pointer, :pointer
737
+ ],
738
+
684
739
  GEOSisEmpty_r: [
685
740
  # (2 on exception, 1 on true, 2 on false), *handle, *geom
686
741
  :char, :pointer, :pointer
@@ -716,6 +771,11 @@ module Geos
716
771
  :char, :pointer, :pointer
717
772
  ],
718
773
 
774
+ GEOSHasM_r: [
775
+ # (2 on exception, 1 on true, 2 on false), *handle, *geom
776
+ :char, :pointer, :pointer
777
+ ],
778
+
719
779
  GEOSisClosed_r: [
720
780
  # (2 on exception, 1 on true, 2 on false), *handle, *geom
721
781
  :char, :pointer, :pointer
@@ -776,6 +836,11 @@ module Geos
776
836
  :int, :pointer, :pointer
777
837
  ],
778
838
 
839
+ GEOSOrientPolygons_r: [
840
+ # -1 on exception, *handle, *geom, exterior_cw
841
+ :int, :pointer, :pointer, :int
842
+ ],
843
+
779
844
  GEOSGetInteriorRingN_r: [
780
845
  # *geom, *handle, *geom, n
781
846
  :pointer, :pointer, :pointer, :int
@@ -806,6 +871,11 @@ module Geos
806
871
  :int, :pointer, :pointer, :pointer
807
872
  ],
808
873
 
874
+ GEOSGeomGetM_r: [
875
+ # -1 on exception, *handle, *geom, *point
876
+ :int, :pointer, :pointer, :pointer
877
+ ],
878
+
809
879
  GEOSGeomGetPointN_r: [
810
880
  # *point, *handle, *geom, n
811
881
  :pointer, :pointer, :pointer, :int
@@ -831,6 +901,11 @@ module Geos
831
901
  :double, :pointer, :pointer
832
902
  ],
833
903
 
904
+ GEOSConcaveHullOfPolygons_r: [
905
+ # *geom, *handle, *geom, length_ratio, tight, allow_holes
906
+ :pointer, :pointer, :pointer, :double, :uint, :uint
907
+ ],
908
+
834
909
  GEOSMinimumRotatedRectangle_r: [
835
910
  # *geom, *handle, *geom
836
911
  :pointer, :pointer, :pointer
@@ -1330,7 +1405,7 @@ module Geos
1330
1405
  end
1331
1406
 
1332
1407
  def default_error_handler(*args)
1333
- raise Geos::GEOSException, args[0] % args[1]
1408
+ raise Geos::GEOSException, sprintf(args[0], *args[1])
1334
1409
  end
1335
1410
  end
1336
1411
 
@@ -12,16 +12,19 @@ class CoordinateSequenceTests < Minitest::Test
12
12
 
13
13
  def test_set_and_get_x
14
14
  @cs.set_x(0, 10.01)
15
+
15
16
  assert_in_delta(10.01, @cs.get_x(0), TOLERANCE)
16
17
  end
17
18
 
18
19
  def test_set_and_get_y
19
20
  @cs.set_y(0, 20.02)
21
+
20
22
  assert_in_delta(20.02, @cs.get_y(0), TOLERANCE)
21
23
  end
22
24
 
23
25
  def test_set_and_get_z
24
26
  @cs.set_z(0, 20.02)
27
+
25
28
  assert_in_delta(20.02, @cs.get_z(0), TOLERANCE)
26
29
  end
27
30
 
@@ -53,7 +56,7 @@ class CoordinateSequenceTests < Minitest::Test
53
56
  [0, 0]
54
57
  ])
55
58
 
56
- assert(cs.counter_clockwise?)
59
+ assert_predicate(cs, :counter_clockwise?)
57
60
 
58
61
  cs = Geos::CoordinateSequence.new([
59
62
  [0, 0],
@@ -62,7 +65,7 @@ class CoordinateSequenceTests < Minitest::Test
62
65
  [0, 0]
63
66
  ])
64
67
 
65
- refute(cs.counter_clockwise?)
68
+ refute_predicate(cs, :counter_clockwise?)
66
69
  end
67
70
 
68
71
  def test_check_bounds
@@ -115,6 +118,7 @@ class CoordinateSequenceTests < Minitest::Test
115
118
 
116
119
  def test_with_no_arguments
117
120
  cs = Geos::CoordinateSequence.new
121
+
118
122
  assert_equal(0, cs.size)
119
123
  assert_equal(3, cs.dimensions)
120
124
  end
@@ -153,6 +157,7 @@ class CoordinateSequenceTests < Minitest::Test
153
157
 
154
158
  def test_to_point
155
159
  cs = Geos::CoordinateSequence.new([5, 7])
160
+
156
161
  assert_equal('POINT (5 7)', write(cs.to_point, trim: true))
157
162
  end
158
163
 
@@ -170,9 +175,11 @@ class CoordinateSequenceTests < Minitest::Test
170
175
 
171
176
  def test_empty
172
177
  cs = Geos::CoordinateSequence.new
178
+
173
179
  assert_geom_empty(cs)
174
180
 
175
181
  cs = Geos::CoordinateSequence.new([4, 1])
182
+
176
183
  refute_geom_empty(cs)
177
184
  end
178
185
 
@@ -219,11 +226,13 @@ class CoordinateSequenceTests < Minitest::Test
219
226
 
220
227
  def test_to_s_2d
221
228
  cs = Geos::CoordinateSequence.new([[1, 2], [10, 11]])
229
+
222
230
  assert_equal('1.0 2.0, 10.0 11.0', cs.to_s)
223
231
  end
224
232
 
225
233
  def test_to_s_3d
226
234
  cs = Geos::CoordinateSequence.new([[1, 2, 3], [10, 11, 12]])
235
+
227
236
  assert_equal('1.0 2.0 3.0, 10.0 11.0 12.0', cs.to_s)
228
237
  end
229
238
 
@@ -358,37 +367,45 @@ class CoordinateSequenceTests < Minitest::Test
358
367
 
359
368
  def test_x_max
360
369
  cs = Geos::CoordinateSequence.new([-10, -15], [0, 5], [10, 20])
370
+
361
371
  assert_equal(10, cs.x_max)
362
372
  end
363
373
 
364
374
  def test_x_min
365
375
  cs = Geos::CoordinateSequence.new([-10, -15], [0, 5], [10, 20])
376
+
366
377
  assert_equal(-10, cs.x_min)
367
378
  end
368
379
 
369
380
  def test_y_max
370
381
  cs = Geos::CoordinateSequence.new([-10, -15], [0, 5], [10, 20])
382
+
371
383
  assert_equal(20, cs.y_max)
372
384
  end
373
385
 
374
386
  def test_y_min
375
387
  cs = Geos::CoordinateSequence.new([-10, -15], [0, 5], [10, 20])
388
+
376
389
  assert_equal(-15, cs.y_min)
377
390
  end
378
391
 
379
392
  def test_z_max
380
393
  cs = Geos::CoordinateSequence.new([-10, -15], [0, 5], [10, 20])
381
- assert(cs.z_max.nan?, ' Expected NaN')
394
+
395
+ assert_predicate(cs.z_max, :nan?, ' Expected NaN')
382
396
 
383
397
  cs = Geos::CoordinateSequence.new([-10, -15, -20], [0, 5, 10], [10, 20, 30])
398
+
384
399
  assert_equal(30, cs.z_max)
385
400
  end
386
401
 
387
402
  def test_z_min
388
403
  cs = Geos::CoordinateSequence.new([-10, -15], [0, 5], [10, 20])
389
- assert(cs.z_min.nan?, ' Expected NaN')
404
+
405
+ assert_predicate(cs.z_min, :nan?, ' Expected NaN')
390
406
 
391
407
  cs = Geos::CoordinateSequence.new([-10, -15, -20], [0, 5, 10], [10, 20, 30])
408
+
392
409
  assert_equal(-20, cs.z_min)
393
410
  end
394
411
 
@@ -422,6 +439,7 @@ class CoordinateSequenceTests < Minitest::Test
422
439
 
423
440
  cs = Geos::CoordinateSequence.new(*coordinates)
424
441
  snapped = cs.snap_to_grid(10 ** -i)
442
+
425
443
  assert_equal(coordinates, cs.to_a)
426
444
  assert_equal(expected[i].inspect, snapped.to_a.inspect)
427
445
  end
@@ -55,7 +55,11 @@ class GeoJSONReaderTests < Minitest::Test
55
55
 
56
56
  def test_multi_point
57
57
  geojson_tester(
58
- 'MULTIPOINT (10.000 40.000, 40.000 30.000, 20.000 20.000, 30.000 10.000)',
58
+ if Geos::GEOS_NICE_VERSION >= '031200'
59
+ 'MULTIPOINT ((10.000 40.000), (40.000 30.000), (20.000 20.000), (30.000 10.000))'
60
+ else
61
+ 'MULTIPOINT (10.000 40.000, 40.000 30.000, 20.000 20.000, 30.000 10.000)'
62
+ end,
59
63
  '{"type":"MultiPoint","coordinates":[[10, 40], [40, 30], [20, 20], [30, 10]]}'
60
64
  )
61
65
  end
@@ -165,6 +169,6 @@ class GeoJSONReaderTests < Minitest::Test
165
169
  srid: 3857
166
170
  )
167
171
 
168
- assert_equal(geom.srid, 3857)
172
+ assert_equal(3857, geom.srid)
169
173
  end
170
174
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class GeometryAreaTests < Minitest::Test
6
+ include TestHelper
7
+
8
+ def setup
9
+ super
10
+ writer.trim = true
11
+ end
12
+
13
+ def test_area
14
+ simple_tester(:area, 1.0, 'POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')
15
+ simple_tester(:area, 0.0, 'POINT (0 0)')
16
+ simple_tester(:area, 0.0, 'LINESTRING (0 0 , 10 0)')
17
+ end
18
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class GeometryBoundaryTests < Minitest::Test
6
+ include TestHelper
7
+
8
+ def setup
9
+ super
10
+ writer.trim = true
11
+ end
12
+
13
+ def test_boundary
14
+ simple_tester(
15
+ :boundary,
16
+ 'GEOMETRYCOLLECTION EMPTY',
17
+ 'POINT(0 0)'
18
+ )
19
+
20
+ simple_tester(
21
+ :boundary,
22
+ if Geos::GEOS_NICE_VERSION >= '031200'
23
+ 'MULTIPOINT ((0 0), (10 10))'
24
+ else
25
+ 'MULTIPOINT (0 0, 10 10)'
26
+ end,
27
+ 'LINESTRING(0 0, 10 10)'
28
+ )
29
+
30
+ simple_tester(
31
+ :boundary,
32
+ 'MULTILINESTRING ((0 0, 10 0, 10 10, 0 10, 0 0), (5 5, 5 6, 6 6, 6 5, 5 5))',
33
+ 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),( 5 5, 5 6, 6 6, 6 5, 5 5))'
34
+ )
35
+ end
36
+ end