ffi-geos 2.3.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +2 -2
- data/.rbenv-vars +1 -0
- data/.rubocop-minitest.yml +40 -17
- data/.rubocop.yml +664 -120
- data/.rubocop_todo.yml +30 -19
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -0
- data/ffi-geos.gemspec +2 -2
- data/lib/ffi-geos/coordinate_sequence.rb +2 -1
- data/lib/ffi-geos/geojson_reader.rb +35 -0
- data/lib/ffi-geos/geojson_writer.rb +49 -0
- data/lib/ffi-geos/geometry.rb +101 -1
- data/lib/ffi-geos/geometry_collection.rb +1 -1
- data/lib/ffi-geos/line_string.rb +1 -1
- data/lib/ffi-geos/point.rb +9 -0
- data/lib/ffi-geos/polygon.rb +1 -1
- data/lib/ffi-geos/prepared_geometry.rb +20 -0
- data/lib/ffi-geos/version.rb +1 -1
- data/lib/ffi-geos/wkb_writer.rb +12 -0
- data/lib/ffi-geos.rb +156 -3
- data/test/coordinate_sequence_tests.rb +22 -4
- data/test/geojson_reader_tests.rb +174 -0
- data/test/geojson_writer_tests.rb +103 -0
- data/test/geometry/area_tests.rb +18 -0
- data/test/geometry/boundary_tests.rb +36 -0
- data/test/geometry/buffer_tests.rb +116 -0
- data/test/geometry/build_area_tests.rb +20 -0
- data/test/geometry/centroid_tests.rb +37 -0
- data/test/geometry/clip_by_rect_tests.rb +56 -0
- data/test/geometry/clone_tests.rb +29 -0
- data/test/geometry/concave_hull_of_polygons_tests.rb +28 -0
- data/test/geometry/concave_hull_tests.rb +38 -0
- data/test/geometry/convex_hull_tests.rb +26 -0
- data/test/geometry/coord_seq_tests.rb +27 -0
- data/test/geometry/delaunay_triangulation_tests.rb +82 -0
- data/test/geometry/densify_tests.rb +95 -0
- data/test/geometry/difference_tests.rb +108 -0
- data/test/geometry/dimensions_tests.rb +46 -0
- data/test/geometry/distance_tests.rb +29 -0
- data/test/geometry/dump_points_tests.rb +60 -0
- data/test/geometry/dup_tests.rb +29 -0
- data/test/geometry/empty_tests.rb +23 -0
- data/test/geometry/envelope_tests.rb +26 -0
- data/test/geometry/equal_identical_tests.rb +78 -0
- data/test/geometry/equal_tests.rb +62 -0
- data/test/geometry/exterior_ring_tests.rb +27 -0
- data/test/geometry/extract_unique_points_tests.rb +41 -0
- data/test/geometry/frecet_distance_tests.rb +24 -0
- data/test/geometry/get_geometry_n_tests.rb +21 -0
- data/test/geometry/hausdorff_distance_tests.rb +46 -0
- data/test/geometry/hilbert_code_tests.rb +45 -0
- data/test/geometry/interior_ring_n_tests.rb +64 -0
- data/test/geometry/interior_rings_tests.rb +36 -0
- data/test/geometry/interpolate_tests.rb +49 -0
- data/test/geometry/intersection_tests.rb +49 -0
- data/test/geometry/largest_empty_circle_tests.rb +26 -0
- data/test/geometry/length_tests.rb +18 -0
- data/test/geometry/line_merge_directed_tests.rb +28 -0
- data/test/geometry/line_merge_tests.rb +25 -0
- data/test/geometry/line_string_enumerator_tests.rb +20 -0
- data/test/geometry/line_substring_tests.rb +76 -0
- data/test/geometry/make_valid_tests.rb +27 -0
- data/test/geometry/maximum_inscribed_circle_tests.rb +21 -0
- data/test/geometry/minimum_bounding_circle_tests.rb +23 -0
- data/test/geometry/minimum_clearance_tests.rb +58 -0
- data/test/geometry/minimum_rotated_rectangle_tests.rb +28 -0
- data/test/geometry/minimum_width_tests.rb +26 -0
- data/test/geometry/misc_tests.rb +24 -0
- data/test/geometry/nearest_points_tests.rb +46 -0
- data/test/geometry/node_tests.rb +22 -0
- data/test/geometry/normalize_tests.rb +34 -0
- data/test/geometry/num_coordinates_tests.rb +39 -0
- data/test/geometry/num_goemetries_tests.rb +35 -0
- data/test/geometry/num_interior_rings_tests.rb +28 -0
- data/test/geometry/orient_polygons_tests.rb +101 -0
- data/test/geometry/point_on_surface_tests.rb +37 -0
- data/test/geometry/polygon_hull_simplify_tests.rb +55 -0
- data/test/geometry/polygonize_tests.rb +173 -0
- data/test/geometry/precision_tests.rb +42 -0
- data/test/geometry/project_tests.rb +56 -0
- data/test/geometry/relate_tests.rb +73 -0
- data/test/geometry/relationships_tests.rb +138 -0
- data/test/geometry/reverse_tests.rb +44 -0
- data/test/geometry/ring_tests.rb +18 -0
- data/test/geometry/shared_path_tests.rb +31 -0
- data/test/geometry/simple_tests.rb +18 -0
- data/test/geometry/simplify_tests.rb +21 -0
- data/test/geometry/snap_tests.rb +20 -0
- data/test/geometry/srid_copy_policy_tests.rb +94 -0
- data/test/geometry/start_and_end_point_tests.rb +24 -0
- data/test/geometry/sym_difference_tests.rb +114 -0
- data/test/geometry/topology_preserve_simplify_tests.rb +21 -0
- data/test/geometry/union_tests.rb +216 -0
- data/test/geometry/valid_tests.rb +56 -0
- data/test/geometry/voronoi_diagram_tests.rb +62 -0
- data/test/geometry_collection_tests.rb +14 -2
- data/test/interrupt_tests.rb +1 -1
- data/test/line_string_tests.rb +24 -3
- data/test/misc_tests.rb +1 -1
- data/test/point/has_m_tests.rb +43 -0
- data/test/point/x_y_z_m_tests.rb +51 -0
- data/test/point_tests.rb +25 -3
- data/test/polygon_tests.rb +14 -1
- data/test/prepared_geometry_tests.rb +31 -0
- data/test/strtree_tests.rb +11 -18
- data/test/test_helper.rb +2 -0
- data/test/tools_tests.rb +7 -0
- data/test/utils_tests.rb +14 -3
- data/test/wkb_reader_tests.rb +1 -0
- data/test/wkb_writer_tests.rb +46 -5
- data/test/wkt_reader_tests.rb +2 -0
- data/test/wkt_writer_tests.rb +20 -2
- metadata +160 -7
- data/test/geometry_tests.rb +0 -2096
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
|
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
|
-
|
10
|
+
# This cop supports safe autocorrection (--autocorrect).
|
11
|
+
# Configuration parameters: Severity, Include.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/DeprecatedAttributeAssignment:
|
11
14
|
Exclude:
|
12
|
-
- '
|
15
|
+
- 'ffi-geos.gemspec'
|
13
16
|
|
14
17
|
# Offense count: 6
|
15
|
-
# Configuration parameters:
|
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/
|
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:
|
34
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
32
35
|
Metrics/CyclomaticComplexity:
|
33
36
|
Exclude:
|
34
37
|
- 'lib/ffi-geos/coordinate_sequence.rb'
|
@@ -46,17 +49,27 @@ Metrics/ParameterLists:
|
|
46
49
|
Exclude:
|
47
50
|
- 'lib/ffi-geos/utils.rb'
|
48
51
|
|
49
|
-
# Offense count:
|
50
|
-
# Configuration parameters:
|
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/
|
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
|
-
# Offense count:
|
69
|
+
# Offense count: 9
|
58
70
|
Naming/AccessorMethodName:
|
59
71
|
Exclude:
|
72
|
+
- 'lib/ffi-geos/geojson_writer.rb'
|
60
73
|
- 'lib/ffi-geos/point.rb'
|
61
74
|
- 'lib/ffi-geos/wkb_writer.rb'
|
62
75
|
- 'lib/ffi-geos/wkt_writer.rb'
|
@@ -69,7 +82,7 @@ Naming/FileName:
|
|
69
82
|
Exclude:
|
70
83
|
- 'lib/ffi-geos.rb'
|
71
84
|
|
72
|
-
# Offense count:
|
85
|
+
# Offense count: 1
|
73
86
|
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
|
74
87
|
# NamePrefix: is_, has_, have_
|
75
88
|
# ForbiddenPrefixes: is_, has_, have_
|
@@ -77,17 +90,15 @@ Naming/FileName:
|
|
77
90
|
# MethodDefinitionMacros: define_method, define_singleton_method
|
78
91
|
Naming/PredicateName:
|
79
92
|
Exclude:
|
80
|
-
- 'lib/ffi-geos/coordinate_sequence.rb'
|
81
93
|
- 'lib/ffi-geos/geometry.rb'
|
82
94
|
|
83
|
-
# Offense count:
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
|
95
|
+
# Offense count: 1
|
96
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
97
|
+
# Configuration parameters: AllowedReceivers.
|
98
|
+
# AllowedReceivers: Thread.current
|
99
|
+
Style/HashEachMethods:
|
88
100
|
Exclude:
|
89
|
-
- 'lib/ffi-geos.rb'
|
90
|
-
- 'lib/ffi-geos/geometry.rb'
|
101
|
+
- 'lib/ffi-geos/strtree.rb'
|
91
102
|
|
92
103
|
# Offense count: 4
|
93
104
|
# Configuration parameters: AllowedMethods.
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -54,6 +54,8 @@ Ruby bindings along with the following enhancements and additions:
|
|
54
54
|
GEOS library and perform other work or cancel GEOS calls outright. The
|
55
55
|
interruption API was added in GEOS 3.4.0.
|
56
56
|
|
57
|
+
* Geos::GeoJSONReader and Geos::GeoJSONWriter support on GEOS 3.10+.
|
58
|
+
|
57
59
|
== New Methods and Additions (not exhaustive)
|
58
60
|
|
59
61
|
* SRIDs can be copied on many operations. GEOS doesn't usually copy SRIDs
|
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.
|
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 = '
|
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'])
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Geos
|
4
|
+
class GeoJSONReader
|
5
|
+
include Geos::Tools
|
6
|
+
|
7
|
+
attr_reader :ptr
|
8
|
+
|
9
|
+
class ParseError < Geos::ParseError
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
ptr = if args.first.is_a?(FFI::Pointer)
|
14
|
+
args.first
|
15
|
+
else
|
16
|
+
FFIGeos.GEOSGeoJSONReader_create_r(Geos.current_handle_pointer, *args)
|
17
|
+
end
|
18
|
+
|
19
|
+
@ptr = FFI::AutoPointer.new(
|
20
|
+
ptr,
|
21
|
+
self.class.method(:release)
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def read(json, options = {})
|
26
|
+
cast_geometry_ptr(FFIGeos.GEOSGeoJSONReader_readGeometry_r(Geos.current_handle_pointer, ptr, json), srid: options[:srid])
|
27
|
+
rescue Geos::GEOSException => e
|
28
|
+
raise ParseError, e
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.release(ptr) # :nodoc:
|
32
|
+
FFIGeos.GEOSGeoJSONReader_destroy_r(Geos.current_handle_pointer, ptr)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Geos
|
4
|
+
class GeoJSONWriter
|
5
|
+
attr_accessor :indentation
|
6
|
+
attr_reader :ptr
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
options = {
|
10
|
+
indentation: -1
|
11
|
+
}.merge(options)
|
12
|
+
|
13
|
+
ptr = FFIGeos.GEOSGeoJSONWriter_create_r(Geos.current_handle_pointer)
|
14
|
+
@ptr = FFI::AutoPointer.new(
|
15
|
+
ptr,
|
16
|
+
self.class.method(:release)
|
17
|
+
)
|
18
|
+
|
19
|
+
set_options(options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.release(ptr) # :nodoc:
|
23
|
+
FFIGeos.GEOSGeoJSONWriter_destroy_r(Geos.current_handle_pointer, ptr)
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_options(options) # :nodoc:
|
27
|
+
[:indentation].each do |k|
|
28
|
+
send("#{k}=", options[k]) if respond_to?("#{k}=") && options.key?(k)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
private :set_options
|
32
|
+
|
33
|
+
# Options can be set temporarily for individual writes using an options
|
34
|
+
# Hash. Options include :indentation.
|
35
|
+
def write(geom, options = nil)
|
36
|
+
unless options.nil?
|
37
|
+
old_options = {
|
38
|
+
indentation: indentation
|
39
|
+
}
|
40
|
+
|
41
|
+
set_options(options)
|
42
|
+
end
|
43
|
+
|
44
|
+
FFIGeos.GEOSGeoJSONWriter_writeGeometry_r(Geos.current_handle_pointer, ptr, geom.ptr, indentation)
|
45
|
+
ensure
|
46
|
+
set_options(old_options) unless options.nil?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/ffi-geos/geometry.rb
CHANGED
@@ -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
|
-
|
624
|
+
CoordinateSequence.new(nearest_points_ptr) unless nearest_points_ptr.null?
|
537
625
|
end
|
538
626
|
end
|
539
627
|
|
@@ -637,6 +725,12 @@ module Geos
|
|
637
725
|
end
|
638
726
|
end
|
639
727
|
|
728
|
+
if FFIGeos.respond_to?(:GEOSConstrainedDelaunayTriangulation_r)
|
729
|
+
def constrained_delaunay_triangulation
|
730
|
+
cast_geometry_ptr(FFIGeos.GEOSConstrainedDelaunayTriangulation_r(Geos.current_handle_pointer, ptr))
|
731
|
+
end
|
732
|
+
end
|
733
|
+
|
640
734
|
if FFIGeos.respond_to?(:GEOSVoronoiDiagram_r)
|
641
735
|
# Available in GEOS 3.5.0+
|
642
736
|
#
|
@@ -699,6 +793,12 @@ module Geos
|
|
699
793
|
end
|
700
794
|
end
|
701
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
|
+
|
702
802
|
if FFIGeos.respond_to?(:GEOSMinimumRotatedRectangle_r)
|
703
803
|
def minimum_rotated_rectangle
|
704
804
|
cast_geometry_ptr(FFIGeos.GEOSMinimumRotatedRectangle_r(Geos.current_handle_pointer, ptr))
|
@@ -46,7 +46,7 @@ module Geos
|
|
46
46
|
|
47
47
|
%w{ x y z }.each do |dimension|
|
48
48
|
%w{ max min }.each do |op|
|
49
|
-
native_method = "GEOSGeom_get#{dimension.upcase}#{op[0].upcase}#{op[1
|
49
|
+
native_method = "GEOSGeom_get#{dimension.upcase}#{op[0].upcase}#{op[1..]}_r"
|
50
50
|
|
51
51
|
if FFIGeos.respond_to?(native_method)
|
52
52
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
data/lib/ffi-geos/line_string.rb
CHANGED
@@ -146,7 +146,7 @@ module Geos
|
|
146
146
|
|
147
147
|
%w{ max min }.each do |op|
|
148
148
|
%w{ x y }.each do |dimension|
|
149
|
-
native_method = "GEOSGeom_get#{dimension.upcase}#{op[0].upcase}#{op[1
|
149
|
+
native_method = "GEOSGeom_get#{dimension.upcase}#{op[0].upcase}#{op[1..]}_r"
|
150
150
|
|
151
151
|
if FFIGeos.respond_to?(native_method)
|
152
152
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
data/lib/ffi-geos/point.rb
CHANGED
@@ -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
|
data/lib/ffi-geos/polygon.rb
CHANGED
@@ -78,7 +78,7 @@ module Geos
|
|
78
78
|
|
79
79
|
%w{ max min }.each do |op|
|
80
80
|
%w{ x y }.each do |dimension|
|
81
|
-
native_method = "GEOSGeom_get#{dimension.upcase}#{op[0].upcase}#{op[1
|
81
|
+
native_method = "GEOSGeom_get#{dimension.upcase}#{op[0].upcase}#{op[1..]}_r"
|
82
82
|
|
83
83
|
if FFIGeos.respond_to?(native_method)
|
84
84
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
@@ -77,5 +77,25 @@ module Geos
|
|
77
77
|
check_geometry(geom)
|
78
78
|
bool_result(FFIGeos.GEOSPreparedWithin_r(Geos.current_handle_pointer, ptr, geom.ptr))
|
79
79
|
end
|
80
|
+
|
81
|
+
def distance(geom)
|
82
|
+
check_geometry(geom)
|
83
|
+
double_ptr = FFI::MemoryPointer.new(:double)
|
84
|
+
FFIGeos.GEOSPreparedDistance_r(Geos.current_handle_pointer, ptr, geom.ptr, double_ptr)
|
85
|
+
double_ptr.read_double
|
86
|
+
end
|
87
|
+
|
88
|
+
def distance_within?(geom, distance)
|
89
|
+
check_geometry(geom)
|
90
|
+
bool_result(FFIGeos.GEOSPreparedDistanceWithin_r(Geos.current_handle_pointer, ptr, geom.ptr, distance))
|
91
|
+
end
|
92
|
+
|
93
|
+
def nearest_points(geom)
|
94
|
+
check_geometry(geom)
|
95
|
+
|
96
|
+
coord_seq_ptr = FFIGeos.GEOSPreparedNearestPoints_r(Geos.current_handle_pointer, ptr, geom.ptr)
|
97
|
+
|
98
|
+
Geos::CoordinateSequence.new(coord_seq_ptr)
|
99
|
+
end
|
80
100
|
end
|
81
101
|
end
|
data/lib/ffi-geos/version.rb
CHANGED
data/lib/ffi-geos/wkb_writer.rb
CHANGED
@@ -83,6 +83,18 @@ module Geos
|
|
83
83
|
FFIGeos.GEOSWKBWriter_setByteOrder_r(Geos.current_handle_pointer, ptr, val)
|
84
84
|
end
|
85
85
|
|
86
|
+
if FFIGeos.respond_to?(:GEOSWKBWriter_getFlavor_r)
|
87
|
+
def flavor
|
88
|
+
FFIGeos.GEOSWKBWriter_getFlavor_r(Geos.current_handle_pointer, ptr)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
if FFIGeos.respond_to?(:GEOSWKBWriter_setFlavor_r)
|
93
|
+
def flavor=(val)
|
94
|
+
FFIGeos.GEOSWKBWriter_setFlavor_r(Geos.current_handle_pointer, ptr, val)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
86
98
|
private
|
87
99
|
|
88
100
|
def set_options(options) # :nodoc:
|