ffi-geos 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -5
- data/MIT-LICENSE +1 -1
- data/lib/ffi-geos.rb +90 -8
- data/lib/ffi-geos/buffer_params.rb +8 -7
- data/lib/ffi-geos/coordinate_sequence.rb +14 -13
- data/lib/ffi-geos/geometry.rb +120 -71
- data/lib/ffi-geos/geometry_collection.rb +2 -1
- data/lib/ffi-geos/interrupt.rb +2 -0
- data/lib/ffi-geos/line_string.rb +5 -4
- data/lib/ffi-geos/linear_ring.rb +1 -0
- data/lib/ffi-geos/multi_line_string.rb +2 -1
- data/lib/ffi-geos/multi_point.rb +1 -0
- data/lib/ffi-geos/multi_polygon.rb +1 -0
- data/lib/ffi-geos/point.rb +4 -3
- data/lib/ffi-geos/polygon.rb +4 -3
- data/lib/ffi-geos/prepared_geometry.rb +13 -12
- data/lib/ffi-geos/strtree.rb +61 -13
- data/lib/ffi-geos/tools.rb +2 -1
- data/lib/ffi-geos/utils.rb +12 -11
- data/lib/ffi-geos/version.rb +2 -1
- data/lib/ffi-geos/wkb_reader.rb +5 -4
- data/lib/ffi-geos/wkb_writer.rb +11 -10
- data/lib/ffi-geos/wkt_reader.rb +4 -3
- data/lib/ffi-geos/wkt_writer.rb +9 -8
- data/test/coordinate_sequence_tests.rb +1 -0
- data/test/geometry_collection_tests.rb +1 -0
- data/test/geometry_tests.rb +88 -0
- data/test/interrupt_tests.rb +1 -0
- data/test/line_string_tests.rb +1 -0
- data/test/linear_ring_tests.rb +1 -0
- data/test/misc_tests.rb +99 -0
- data/test/multi_line_string_tests.rb +1 -0
- data/test/point_tests.rb +1 -0
- data/test/polygon_tests.rb +1 -0
- data/test/prepared_geometry_tests.rb +1 -0
- data/test/strtree_tests.rb +143 -2
- data/test/test_helper.rb +8 -2
- data/test/tools_tests.rb +1 -0
- data/test/utils_tests.rb +1 -0
- data/test/wkb_reader_tests.rb +1 -0
- data/test/wkb_writer_tests.rb +3 -4
- data/test/wkt_reader_tests.rb +1 -0
- data/test/wkt_writer_tests.rb +1 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccb3a99801ff6039bf36d14f2d0be9cd7a084aa7
|
4
|
+
data.tar.gz: 183a295b0c845bbc1fb856d98ddf9771c6f1a4ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 951a4938f5844873b3cd3d0d0fe6ae6cbee3e336380a18b9fe9af4777cc4c4526c932685472750d118671ea3f139c10c983909fb3bab8b18e44c8761072891ff
|
7
|
+
data.tar.gz: 054b81d1f27bb26f5c2220fa2618cdd1a1eef4ef74668c658133728a34a9e4a69ca7335968cde10cfda47d7133b6d584a9fe4d1805158c57c1c401a10b7250f7
|
data/.travis.yml
CHANGED
@@ -2,12 +2,15 @@ cache: bundler
|
|
2
2
|
sudo: false
|
3
3
|
language: ruby
|
4
4
|
rvm:
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
-
|
9
|
-
- rbx-2
|
5
|
+
- 2.4.0
|
6
|
+
- 2.3.3
|
7
|
+
- 2.2.6
|
8
|
+
- rbx-3
|
10
9
|
- jruby-19mode
|
10
|
+
matrix:
|
11
|
+
allow_failures:
|
12
|
+
- rvm: rbx-3
|
13
|
+
- rvm: jruby-19mode
|
11
14
|
addons:
|
12
15
|
apt:
|
13
16
|
packages:
|
data/MIT-LICENSE
CHANGED
data/lib/ffi-geos.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'ffi'
|
4
5
|
require 'rbconfig'
|
@@ -135,6 +136,11 @@ module Geos
|
|
135
136
|
:geometry_collection, 7
|
136
137
|
])
|
137
138
|
|
139
|
+
Geos::PrecisionOptions = enum(:precision_option, [
|
140
|
+
:no_topology, 1 << 0,
|
141
|
+
:keep_collapsed, 1 << 1
|
142
|
+
])
|
143
|
+
|
138
144
|
FFI_LAYOUT = {
|
139
145
|
#### Utility functions ####
|
140
146
|
|
@@ -712,6 +718,36 @@ module Geos
|
|
712
718
|
# *point, *handle, *geom
|
713
719
|
:pointer, :pointer, :pointer
|
714
720
|
],
|
721
|
+
|
722
|
+
:GEOSGeom_setPrecision_r => [
|
723
|
+
# *geom, *hande, *geom, grid_size, int flags
|
724
|
+
:pointer, :pointer, :pointer, :double, :int
|
725
|
+
],
|
726
|
+
|
727
|
+
:GEOSGeom_getPrecision_r => [
|
728
|
+
# precision, *hande, *geom
|
729
|
+
:double, :pointer, :pointer
|
730
|
+
],
|
731
|
+
|
732
|
+
:GEOSMinimumRotatedRectangle_r => [
|
733
|
+
# *geom, *handle, *geom
|
734
|
+
:pointer, :pointer, :pointer
|
735
|
+
],
|
736
|
+
|
737
|
+
:GEOSMinimumClearance_r => [
|
738
|
+
# 0 on success, *handle, *geom, *clearance
|
739
|
+
:int, :pointer, :pointer, :pointer
|
740
|
+
],
|
741
|
+
|
742
|
+
:GEOSMinimumClearanceLine_r => [
|
743
|
+
# *geom, *handle, *geom
|
744
|
+
:pointer, :pointer, :pointer
|
745
|
+
],
|
746
|
+
|
747
|
+
:GEOSMinimumWidth_r => [
|
748
|
+
# *geom, *handle, *geom
|
749
|
+
:pointer, :pointer, :pointer
|
750
|
+
],
|
715
751
|
#### /Geometry functions ####
|
716
752
|
|
717
753
|
#### STRtree functions ####
|
@@ -744,6 +780,11 @@ module Geos
|
|
744
780
|
# void, *handle, *tree
|
745
781
|
:void, :pointer, :pointer
|
746
782
|
],
|
783
|
+
|
784
|
+
:GEOSSTRtree_nearest_generic_r => [
|
785
|
+
# *void, *handle, *tree, *item, *item_envelope, int distance_callback(*item_1, *item_2, *double, void *user_data), *user_data
|
786
|
+
:pointer, :pointer, :pointer, :pointer, :pointer, callback([ :pointer, :pointer, :pointer, :pointer ], :int), :pointer
|
787
|
+
],
|
747
788
|
#### /STRtree functions ####
|
748
789
|
|
749
790
|
#### PreparedGeometry functions ####
|
@@ -1041,21 +1082,51 @@ module Geos
|
|
1041
1082
|
def initialize
|
1042
1083
|
@ptr = FFI::AutoPointer.new(FFIGeos.GEOS_init_r, self.class.method(:release))
|
1043
1084
|
|
1044
|
-
|
1045
|
-
|
1085
|
+
reset_notice_handler
|
1086
|
+
reset_error_handler
|
1046
1087
|
end
|
1047
1088
|
|
1048
1089
|
def self.release(ptr)
|
1049
1090
|
FFIGeos.GEOS_finish_r(ptr)
|
1050
1091
|
end
|
1051
1092
|
|
1093
|
+
def notice_handler=(method_or_block)
|
1094
|
+
@notice_handler = method_or_block
|
1095
|
+
FFIGeos.GEOSContext_setNoticeMessageHandler_r(@ptr, @notice_handler, nil)
|
1096
|
+
@notice_handler
|
1097
|
+
end
|
1098
|
+
|
1099
|
+
def error_handler=(method_or_block)
|
1100
|
+
@error_handler = method_or_block
|
1101
|
+
FFIGeos.GEOSContext_setErrorMessageHandler_r(@ptr, @error_handler, nil)
|
1102
|
+
@error_handler
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
def notice_handler(&block)
|
1106
|
+
self.notice_handler = block if block_given?
|
1107
|
+
@notice_handler
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
def error_handler(&block)
|
1111
|
+
self.error_handler = block if block_given?
|
1112
|
+
@error_handler
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
def reset_notice_handler
|
1116
|
+
self.notice_handler = self.method(:default_notice_handler)
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
def reset_error_handler
|
1120
|
+
self.error_handler = self.method(:default_error_handler)
|
1121
|
+
end
|
1122
|
+
|
1052
1123
|
# Deprecated initialization and teardown...
|
1053
1124
|
else
|
1054
1125
|
def initialize
|
1055
1126
|
@ptr = FFI::AutoPointer.new(
|
1056
1127
|
FFIGeos.initGEOS_r(
|
1057
|
-
@notice_handler = self.method(:
|
1058
|
-
@error_handler = self.method(:
|
1128
|
+
@notice_handler = self.method(:default_notice_handler),
|
1129
|
+
@error_handler = self.method(:default_error_handler)
|
1059
1130
|
),
|
1060
1131
|
self.class.method(:release)
|
1061
1132
|
)
|
@@ -1064,14 +1135,22 @@ module Geos
|
|
1064
1135
|
def self.release(ptr)
|
1065
1136
|
FFIGeos.finishGEOS_r(ptr)
|
1066
1137
|
end
|
1138
|
+
|
1139
|
+
def notice_handler
|
1140
|
+
@notice_handler
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
def error_handler
|
1144
|
+
@error_handler
|
1145
|
+
end
|
1067
1146
|
end
|
1068
1147
|
|
1069
1148
|
private
|
1070
|
-
def
|
1071
|
-
# no-op
|
1149
|
+
def default_notice_handler(*args)
|
1150
|
+
# no-op
|
1072
1151
|
end
|
1073
1152
|
|
1074
|
-
def
|
1153
|
+
def default_error_handler(*args)
|
1075
1154
|
raise Geos::GEOSException.new(args[0] % args[1])
|
1076
1155
|
end
|
1077
1156
|
end
|
@@ -1087,7 +1166,10 @@ module Geos
|
|
1087
1166
|
|
1088
1167
|
def current_handle
|
1089
1168
|
Thread.current[:ffi_geos_handle] ||= Geos::Handle.new
|
1090
|
-
|
1169
|
+
end
|
1170
|
+
|
1171
|
+
def current_handle_pointer
|
1172
|
+
current_handle.ptr
|
1091
1173
|
end
|
1092
1174
|
|
1093
1175
|
def srid_copy_policy
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Geos
|
4
5
|
class BufferParams
|
@@ -24,7 +25,7 @@ module Geos
|
|
24
25
|
def initialize(params = {})
|
25
26
|
params = Geos::Constants::BUFFER_PARAM_DEFAULTS.merge(params)
|
26
27
|
|
27
|
-
ptr = FFIGeos.GEOSBufferParams_create_r(Geos.
|
28
|
+
ptr = FFIGeos.GEOSBufferParams_create_r(Geos.current_handle_pointer)
|
28
29
|
@ptr = FFI::AutoPointer.new(
|
29
30
|
ptr,
|
30
31
|
self.class.method(:release)
|
@@ -37,13 +38,13 @@ module Geos
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def self.release(ptr) #:nodoc:
|
40
|
-
FFIGeos.GEOSBufferParams_destroy_r(Geos.
|
41
|
+
FFIGeos.GEOSBufferParams_destroy_r(Geos.current_handle_pointer, ptr)
|
41
42
|
end
|
42
43
|
|
43
44
|
def endcap=(value)
|
44
45
|
check_enum_value(Geos::BufferCapStyles, value)
|
45
46
|
|
46
|
-
if bool_result(FFIGeos.GEOSBufferParams_setEndCapStyle_r(Geos.
|
47
|
+
if bool_result(FFIGeos.GEOSBufferParams_setEndCapStyle_r(Geos.current_handle_pointer, ptr, value))
|
47
48
|
@params[:endcap] = symbol_for_enum(Geos::BufferCapStyles, value)
|
48
49
|
end
|
49
50
|
end
|
@@ -51,25 +52,25 @@ module Geos
|
|
51
52
|
def join=(value)
|
52
53
|
check_enum_value(Geos::BufferJoinStyles, value)
|
53
54
|
|
54
|
-
if bool_result(FFIGeos.GEOSBufferParams_setJoinStyle_r(Geos.
|
55
|
+
if bool_result(FFIGeos.GEOSBufferParams_setJoinStyle_r(Geos.current_handle_pointer, ptr, value))
|
55
56
|
@params[:join] = symbol_for_enum(Geos::BufferJoinStyles, value)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
60
|
def mitre_limit=(value)
|
60
|
-
if bool_result(FFIGeos.GEOSBufferParams_setMitreLimit_r(Geos.
|
61
|
+
if bool_result(FFIGeos.GEOSBufferParams_setMitreLimit_r(Geos.current_handle_pointer, ptr, value))
|
61
62
|
@params[:mitre_limit] = value
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
66
|
def quad_segs=(value)
|
66
|
-
if bool_result(FFIGeos.GEOSBufferParams_setQuadrantSegments_r(Geos.
|
67
|
+
if bool_result(FFIGeos.GEOSBufferParams_setQuadrantSegments_r(Geos.current_handle_pointer, ptr, value))
|
67
68
|
@params[:quad_segs] = value
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
71
72
|
def single_sided=(value)
|
72
|
-
if bool_result(FFIGeos.GEOSBufferParams_setSingleSided_r(Geos.
|
73
|
+
if bool_result(FFIGeos.GEOSBufferParams_setSingleSided_r(Geos.current_handle_pointer, ptr, Geos::Tools.bool_to_int(value)))
|
73
74
|
@params[:single_sided] = value
|
74
75
|
end
|
75
76
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Geos
|
4
5
|
|
@@ -91,7 +92,7 @@ module Geos
|
|
91
92
|
size ||= 0
|
92
93
|
dimensions ||= 0
|
93
94
|
|
94
|
-
[ FFIGeos.GEOSCoordSeq_create_r(Geos.
|
95
|
+
[ FFIGeos.GEOSCoordSeq_create_r(Geos.current_handle_pointer, size, dimensions), true ]
|
95
96
|
end
|
96
97
|
|
97
98
|
@ptr = FFI::AutoPointer.new(
|
@@ -117,7 +118,7 @@ module Geos
|
|
117
118
|
|
118
119
|
def initialize_copy(source)
|
119
120
|
@ptr = FFI::AutoPointer.new(
|
120
|
-
FFIGeos.GEOSCoordSeq_clone_r(Geos.
|
121
|
+
FFIGeos.GEOSCoordSeq_clone_r(Geos.current_handle_pointer, source.ptr),
|
121
122
|
self.class.method(:release)
|
122
123
|
)
|
123
124
|
|
@@ -127,7 +128,7 @@ module Geos
|
|
127
128
|
end
|
128
129
|
|
129
130
|
def self.release(ptr) #:nodoc:
|
130
|
-
FFIGeos.GEOSCoordSeq_destroy_r(Geos.
|
131
|
+
FFIGeos.GEOSCoordSeq_destroy_r(Geos.current_handle_pointer, ptr)
|
131
132
|
end
|
132
133
|
|
133
134
|
# Yields coordinates as [ x, y, z ]. The z coordinate may be omitted for
|
@@ -164,31 +165,31 @@ module Geos
|
|
164
165
|
# Sets the x value of a coordinate. Can also be set via #x[]=.
|
165
166
|
def set_x(idx, val)
|
166
167
|
self.check_bounds(idx)
|
167
|
-
FFIGeos.GEOSCoordSeq_setX_r(Geos.
|
168
|
+
FFIGeos.GEOSCoordSeq_setX_r(Geos.current_handle_pointer, self.ptr, idx, val.to_f)
|
168
169
|
end
|
169
170
|
|
170
171
|
# Sets the y value of a coordinate. Can also be set via #y[]=.
|
171
172
|
def set_y(idx, val)
|
172
173
|
self.check_bounds(idx)
|
173
|
-
FFIGeos.GEOSCoordSeq_setY_r(Geos.
|
174
|
+
FFIGeos.GEOSCoordSeq_setY_r(Geos.current_handle_pointer, self.ptr, idx, val.to_f)
|
174
175
|
end
|
175
176
|
|
176
177
|
# Sets the z value of a coordinate. Can also be set via #z[]=.
|
177
178
|
def set_z(idx, val)
|
178
179
|
self.check_bounds(idx)
|
179
|
-
FFIGeos.GEOSCoordSeq_setZ_r(Geos.
|
180
|
+
FFIGeos.GEOSCoordSeq_setZ_r(Geos.current_handle_pointer, self.ptr, idx, val.to_f)
|
180
181
|
end
|
181
182
|
|
182
183
|
def set_ordinate(idx, dim, val)
|
183
184
|
self.check_bounds(idx)
|
184
|
-
FFIGeos.GEOSCoordSeq_setOrdinate_r(Geos.
|
185
|
+
FFIGeos.GEOSCoordSeq_setOrdinate_r(Geos.current_handle_pointer, self.ptr, idx, dim, val.to_f)
|
185
186
|
end
|
186
187
|
|
187
188
|
# Gets the x value of a coordinate. Can also be retrieved via #x[].
|
188
189
|
def get_x(idx)
|
189
190
|
self.check_bounds(idx)
|
190
191
|
double_ptr = FFI::MemoryPointer.new(:double)
|
191
|
-
FFIGeos.GEOSCoordSeq_getX_r(Geos.
|
192
|
+
FFIGeos.GEOSCoordSeq_getX_r(Geos.current_handle_pointer, self.ptr, idx, double_ptr)
|
192
193
|
double_ptr.read_double
|
193
194
|
end
|
194
195
|
|
@@ -196,7 +197,7 @@ module Geos
|
|
196
197
|
def get_y(idx)
|
197
198
|
self.check_bounds(idx)
|
198
199
|
double_ptr = FFI::MemoryPointer.new(:double)
|
199
|
-
FFIGeos.GEOSCoordSeq_getY_r(Geos.
|
200
|
+
FFIGeos.GEOSCoordSeq_getY_r(Geos.current_handle_pointer, self.ptr, idx, double_ptr)
|
200
201
|
double_ptr.read_double
|
201
202
|
end
|
202
203
|
|
@@ -204,20 +205,20 @@ module Geos
|
|
204
205
|
def get_z(idx)
|
205
206
|
self.check_bounds(idx)
|
206
207
|
double_ptr = FFI::MemoryPointer.new(:double)
|
207
|
-
FFIGeos.GEOSCoordSeq_getZ_r(Geos.
|
208
|
+
FFIGeos.GEOSCoordSeq_getZ_r(Geos.current_handle_pointer, self.ptr, idx, double_ptr)
|
208
209
|
double_ptr.read_double
|
209
210
|
end
|
210
211
|
|
211
212
|
def get_ordinate(idx, dim)
|
212
213
|
self.check_bounds(idx)
|
213
214
|
double_ptr = FFI::MemoryPointer.new(:double)
|
214
|
-
FFIGeos.GEOSCoordSeq_getOrdinate_r(Geos.
|
215
|
+
FFIGeos.GEOSCoordSeq_getOrdinate_r(Geos.current_handle_pointer, self.ptr, idx, dim, double_ptr)
|
215
216
|
double_ptr.read_double
|
216
217
|
end
|
217
218
|
|
218
219
|
def length
|
219
220
|
int_ptr = FFI::MemoryPointer.new(:int)
|
220
|
-
FFIGeos.GEOSCoordSeq_getSize_r(Geos.
|
221
|
+
FFIGeos.GEOSCoordSeq_getSize_r(Geos.current_handle_pointer, self.ptr, int_ptr)
|
221
222
|
int_ptr.read_int
|
222
223
|
end
|
223
224
|
alias_method :size, :length
|
@@ -231,7 +232,7 @@ module Geos
|
|
231
232
|
@dimensions
|
232
233
|
else
|
233
234
|
int_ptr = FFI::MemoryPointer.new(:int)
|
234
|
-
FFIGeos.GEOSCoordSeq_getDimensions_r(Geos.
|
235
|
+
FFIGeos.GEOSCoordSeq_getDimensions_r(Geos.current_handle_pointer, self.ptr, int_ptr)
|
235
236
|
@dimensions = int_ptr.read_int
|
236
237
|
end
|
237
238
|
end
|
data/lib/ffi-geos/geometry.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Geos
|
4
5
|
class Geometry
|
@@ -30,7 +31,7 @@ module Geos
|
|
30
31
|
|
31
32
|
def initialize_copy(source)
|
32
33
|
@ptr = FFI::AutoPointer.new(
|
33
|
-
FFIGeos.GEOSGeom_clone_r(Geos.
|
34
|
+
FFIGeos.GEOSGeom_clone_r(Geos.current_handle_pointer, source.ptr),
|
34
35
|
self.class.method(:release)
|
35
36
|
)
|
36
37
|
|
@@ -39,21 +40,21 @@ module Geos
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def self.release(ptr) #:nodoc:
|
42
|
-
FFIGeos.GEOSGeom_destroy_r(Geos.
|
43
|
+
FFIGeos.GEOSGeom_destroy_r(Geos.current_handle_pointer, ptr)
|
43
44
|
end
|
44
45
|
|
45
46
|
# Returns the name of the Geometry type, i.e. "Point", "Polygon", etc.
|
46
47
|
def geom_type
|
47
|
-
FFIGeos.GEOSGeomType_r(Geos.
|
48
|
+
FFIGeos.GEOSGeomType_r(Geos.current_handle_pointer, self.ptr)
|
48
49
|
end
|
49
50
|
|
50
51
|
# Returns one of the values from Geos::GeomTypes.
|
51
52
|
def type_id
|
52
|
-
FFIGeos.GEOSGeomTypeId_r(Geos.
|
53
|
+
FFIGeos.GEOSGeomTypeId_r(Geos.current_handle_pointer, self.ptr)
|
53
54
|
end
|
54
55
|
|
55
56
|
def normalize!
|
56
|
-
if FFIGeos.GEOSNormalize_r(Geos.
|
57
|
+
if FFIGeos.GEOSNormalize_r(Geos.current_handle_pointer, self.ptr) == -1
|
57
58
|
raise Geos::Geometry::CouldntNormalizeError.new(self.class)
|
58
59
|
end
|
59
60
|
|
@@ -62,32 +63,32 @@ module Geos
|
|
62
63
|
alias_method :normalize, :normalize!
|
63
64
|
|
64
65
|
def srid
|
65
|
-
FFIGeos.GEOSGetSRID_r(Geos.
|
66
|
+
FFIGeos.GEOSGetSRID_r(Geos.current_handle_pointer, self.ptr)
|
66
67
|
end
|
67
68
|
|
68
69
|
def srid=(s)
|
69
|
-
FFIGeos.GEOSSetSRID_r(Geos.
|
70
|
+
FFIGeos.GEOSSetSRID_r(Geos.current_handle_pointer, self.ptr, s)
|
70
71
|
end
|
71
72
|
|
72
73
|
def dimensions
|
73
|
-
FFIGeos.GEOSGeom_getDimensions_r(Geos.
|
74
|
+
FFIGeos.GEOSGeom_getDimensions_r(Geos.current_handle_pointer, self.ptr)
|
74
75
|
end
|
75
76
|
|
76
77
|
def num_geometries
|
77
|
-
FFIGeos.GEOSGetNumGeometries_r(Geos.
|
78
|
+
FFIGeos.GEOSGetNumGeometries_r(Geos.current_handle_pointer, self.ptr)
|
78
79
|
end
|
79
80
|
|
80
81
|
def num_coordinates
|
81
|
-
FFIGeos.GEOSGetNumCoordinates_r(Geos.
|
82
|
+
FFIGeos.GEOSGetNumCoordinates_r(Geos.current_handle_pointer, self.ptr)
|
82
83
|
end
|
83
84
|
|
84
85
|
def coord_seq
|
85
|
-
CoordinateSequence.new(FFIGeos.GEOSGeom_getCoordSeq_r(Geos.
|
86
|
+
CoordinateSequence.new(FFIGeos.GEOSGeom_getCoordSeq_r(Geos.current_handle_pointer, self.ptr), false, self)
|
86
87
|
end
|
87
88
|
|
88
89
|
def intersection(geom)
|
89
90
|
check_geometry(geom)
|
90
|
-
cast_geometry_ptr(FFIGeos.GEOSIntersection_r(Geos.
|
91
|
+
cast_geometry_ptr(FFIGeos.GEOSIntersection_r(Geos.current_handle_pointer, self.ptr, geom.ptr), {
|
91
92
|
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
|
92
93
|
})
|
93
94
|
end
|
@@ -119,7 +120,7 @@ module Geos
|
|
119
120
|
raise ArgumentError.new("Expected Geos::BufferParams, a Hash or a Numeric")
|
120
121
|
end
|
121
122
|
|
122
|
-
cast_geometry_ptr(FFIGeos.GEOSBufferWithParams_r(Geos.
|
123
|
+
cast_geometry_ptr(FFIGeos.GEOSBufferWithParams_r(Geos.current_handle_pointer, self.ptr, params.ptr, width), :srid_copy => self.srid)
|
123
124
|
end
|
124
125
|
else
|
125
126
|
def buffer(width, options = nil)
|
@@ -135,31 +136,31 @@ module Geos
|
|
135
136
|
raise ArgumentError.new("Expected Geos::BufferParams, a Hash or a Numeric")
|
136
137
|
end
|
137
138
|
|
138
|
-
cast_geometry_ptr(FFIGeos.GEOSBuffer_r(Geos.
|
139
|
+
cast_geometry_ptr(FFIGeos.GEOSBuffer_r(Geos.current_handle_pointer, self.ptr, width, quad_segs), :srid_copy => self.srid)
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
142
143
|
def convex_hull
|
143
|
-
cast_geometry_ptr(FFIGeos.GEOSConvexHull_r(Geos.
|
144
|
+
cast_geometry_ptr(FFIGeos.GEOSConvexHull_r(Geos.current_handle_pointer, self.ptr), :srid_copy => self.srid)
|
144
145
|
end
|
145
146
|
|
146
147
|
def difference(geom)
|
147
148
|
check_geometry(geom)
|
148
|
-
cast_geometry_ptr(FFIGeos.GEOSDifference_r(Geos.
|
149
|
+
cast_geometry_ptr(FFIGeos.GEOSDifference_r(Geos.current_handle_pointer, self.ptr, geom.ptr), {
|
149
150
|
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
|
150
151
|
})
|
151
152
|
end
|
152
153
|
|
153
154
|
def sym_difference(geom)
|
154
155
|
check_geometry(geom)
|
155
|
-
cast_geometry_ptr(FFIGeos.GEOSSymDifference_r(Geos.
|
156
|
+
cast_geometry_ptr(FFIGeos.GEOSSymDifference_r(Geos.current_handle_pointer, self.ptr, geom.ptr), {
|
156
157
|
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
|
157
158
|
})
|
158
159
|
end
|
159
160
|
alias_method :symmetric_difference, :sym_difference
|
160
161
|
|
161
162
|
def boundary
|
162
|
-
cast_geometry_ptr(FFIGeos.GEOSBoundary_r(Geos.
|
163
|
+
cast_geometry_ptr(FFIGeos.GEOSBoundary_r(Geos.current_handle_pointer, self.ptr), :srid_copy => self.srid)
|
163
164
|
end
|
164
165
|
|
165
166
|
# Calling without a geom argument is equivalent to calling unary_union when
|
@@ -168,7 +169,7 @@ module Geos
|
|
168
169
|
def union(geom = nil)
|
169
170
|
if geom
|
170
171
|
check_geometry(geom)
|
171
|
-
cast_geometry_ptr(FFIGeos.GEOSUnion_r(Geos.
|
172
|
+
cast_geometry_ptr(FFIGeos.GEOSUnion_r(Geos.current_handle_pointer, self.ptr, geom.ptr), {
|
172
173
|
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
|
173
174
|
})
|
174
175
|
else
|
@@ -181,7 +182,7 @@ module Geos
|
|
181
182
|
end
|
182
183
|
|
183
184
|
def union_cascaded
|
184
|
-
cast_geometry_ptr(FFIGeos.GEOSUnionCascaded_r(Geos.
|
185
|
+
cast_geometry_ptr(FFIGeos.GEOSUnionCascaded_r(Geos.current_handle_pointer, self.ptr), {
|
185
186
|
:srid_copy => self.srid
|
186
187
|
})
|
187
188
|
end
|
@@ -189,7 +190,7 @@ module Geos
|
|
189
190
|
if FFIGeos.respond_to?(:GEOSUnaryUnion_r)
|
190
191
|
# Available in GEOS 3.3+
|
191
192
|
def unary_union
|
192
|
-
cast_geometry_ptr(FFIGeos.GEOSUnaryUnion_r(Geos.
|
193
|
+
cast_geometry_ptr(FFIGeos.GEOSUnaryUnion_r(Geos.current_handle_pointer, self.ptr), {
|
193
194
|
:srid_copy => self.srid
|
194
195
|
})
|
195
196
|
end
|
@@ -198,43 +199,43 @@ module Geos
|
|
198
199
|
if FFIGeos.respond_to?(:GEOSNode_r)
|
199
200
|
# Available in GEOS 3.3.4+
|
200
201
|
def node
|
201
|
-
cast_geometry_ptr(FFIGeos.GEOSNode_r(Geos.
|
202
|
+
cast_geometry_ptr(FFIGeos.GEOSNode_r(Geos.current_handle_pointer, self.ptr))
|
202
203
|
end
|
203
204
|
end
|
204
205
|
|
205
206
|
def point_on_surface
|
206
|
-
cast_geometry_ptr(FFIGeos.GEOSPointOnSurface_r(Geos.
|
207
|
+
cast_geometry_ptr(FFIGeos.GEOSPointOnSurface_r(Geos.current_handle_pointer, self.ptr), :srid_copy => self.srid)
|
207
208
|
end
|
208
209
|
alias_method :representative_point, :point_on_surface
|
209
210
|
|
210
211
|
if FFIGeos.respond_to?(:GEOSClipByRect_r)
|
211
212
|
# Available in GEOS 3.5.0+.
|
212
213
|
def clip_by_rect(xmin, ymin, xmax, ymax)
|
213
|
-
cast_geometry_ptr(FFIGeos.GEOSClipByRect_r(Geos.
|
214
|
+
cast_geometry_ptr(FFIGeos.GEOSClipByRect_r(Geos.current_handle_pointer, self.ptr, xmin, ymin, xmax, ymax))
|
214
215
|
end
|
215
216
|
alias_method :clip_by_rectangle, :clip_by_rect
|
216
217
|
end
|
217
218
|
|
218
219
|
def centroid
|
219
|
-
cast_geometry_ptr(FFIGeos.GEOSGetCentroid_r(Geos.
|
220
|
+
cast_geometry_ptr(FFIGeos.GEOSGetCentroid_r(Geos.current_handle_pointer, self.ptr), :srid_copy => self.srid)
|
220
221
|
end
|
221
222
|
alias_method :center, :centroid
|
222
223
|
|
223
224
|
def envelope
|
224
|
-
cast_geometry_ptr(FFIGeos.GEOSEnvelope_r(Geos.
|
225
|
+
cast_geometry_ptr(FFIGeos.GEOSEnvelope_r(Geos.current_handle_pointer, self.ptr), :srid_copy => self.srid)
|
225
226
|
end
|
226
227
|
|
227
228
|
# Returns the Dimensionally Extended Nine-Intersection Model (DE-9IM)
|
228
229
|
# matrix of the geometries as a String.
|
229
230
|
def relate(geom)
|
230
231
|
check_geometry(geom)
|
231
|
-
FFIGeos.GEOSRelate_r(Geos.
|
232
|
+
FFIGeos.GEOSRelate_r(Geos.current_handle_pointer, self.ptr, geom.ptr)
|
232
233
|
end
|
233
234
|
|
234
235
|
# Checks the DE-9IM pattern against the geoms.
|
235
236
|
def relate_pattern(geom, pattern)
|
236
237
|
check_geometry(geom)
|
237
|
-
bool_result(FFIGeos.GEOSRelatePattern_r(Geos.
|
238
|
+
bool_result(FFIGeos.GEOSRelatePattern_r(Geos.current_handle_pointer, self.ptr, geom.ptr, pattern))
|
238
239
|
end
|
239
240
|
|
240
241
|
if FFIGeos.respond_to?(:GEOSRelateBoundaryNodeRule_r)
|
@@ -242,60 +243,60 @@ module Geos
|
|
242
243
|
def relate_boundary_node_rule(geom, bnr = :mod2)
|
243
244
|
check_geometry(geom)
|
244
245
|
check_enum_value(Geos::RelateBoundaryNodeRules, bnr)
|
245
|
-
FFIGeos.GEOSRelateBoundaryNodeRule_r(Geos.
|
246
|
+
FFIGeos.GEOSRelateBoundaryNodeRule_r(Geos.current_handle_pointer, self.ptr, geom.ptr, bnr)
|
246
247
|
end
|
247
248
|
end
|
248
249
|
|
249
250
|
def line_merge
|
250
|
-
cast_geometry_ptr(FFIGeos.GEOSLineMerge_r(Geos.
|
251
|
+
cast_geometry_ptr(FFIGeos.GEOSLineMerge_r(Geos.current_handle_pointer, self.ptr), :srid_copy => self.srid)
|
251
252
|
end
|
252
253
|
|
253
254
|
def simplify(tolerance)
|
254
|
-
cast_geometry_ptr(FFIGeos.GEOSSimplify_r(Geos.
|
255
|
+
cast_geometry_ptr(FFIGeos.GEOSSimplify_r(Geos.current_handle_pointer, self.ptr, tolerance), :srid_copy => self.srid)
|
255
256
|
end
|
256
257
|
|
257
258
|
def topology_preserve_simplify(tolerance)
|
258
|
-
cast_geometry_ptr(FFIGeos.GEOSTopologyPreserveSimplify_r(Geos.
|
259
|
+
cast_geometry_ptr(FFIGeos.GEOSTopologyPreserveSimplify_r(Geos.current_handle_pointer, self.ptr, tolerance), :srid_copy => self.srid)
|
259
260
|
end
|
260
261
|
|
261
262
|
def extract_unique_points
|
262
|
-
cast_geometry_ptr(FFIGeos.GEOSGeom_extractUniquePoints_r(Geos.
|
263
|
+
cast_geometry_ptr(FFIGeos.GEOSGeom_extractUniquePoints_r(Geos.current_handle_pointer, self.ptr), :srid_copy => self.srid)
|
263
264
|
end
|
264
265
|
alias_method :unique_points, :extract_unique_points
|
265
266
|
|
266
267
|
def disjoint?(geom)
|
267
268
|
check_geometry(geom)
|
268
|
-
bool_result(FFIGeos.GEOSDisjoint_r(Geos.
|
269
|
+
bool_result(FFIGeos.GEOSDisjoint_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
269
270
|
end
|
270
271
|
|
271
272
|
def touches?(geom)
|
272
273
|
check_geometry(geom)
|
273
|
-
bool_result(FFIGeos.GEOSTouches_r(Geos.
|
274
|
+
bool_result(FFIGeos.GEOSTouches_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
274
275
|
end
|
275
276
|
|
276
277
|
def intersects?(geom)
|
277
278
|
check_geometry(geom)
|
278
|
-
bool_result(FFIGeos.GEOSIntersects_r(Geos.
|
279
|
+
bool_result(FFIGeos.GEOSIntersects_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
279
280
|
end
|
280
281
|
|
281
282
|
def crosses?(geom)
|
282
283
|
check_geometry(geom)
|
283
|
-
bool_result(FFIGeos.GEOSCrosses_r(Geos.
|
284
|
+
bool_result(FFIGeos.GEOSCrosses_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
284
285
|
end
|
285
286
|
|
286
287
|
def within?(geom)
|
287
288
|
check_geometry(geom)
|
288
|
-
bool_result(FFIGeos.GEOSWithin_r(Geos.
|
289
|
+
bool_result(FFIGeos.GEOSWithin_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
289
290
|
end
|
290
291
|
|
291
292
|
def contains?(geom)
|
292
293
|
check_geometry(geom)
|
293
|
-
bool_result(FFIGeos.GEOSContains_r(Geos.
|
294
|
+
bool_result(FFIGeos.GEOSContains_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
294
295
|
end
|
295
296
|
|
296
297
|
def overlaps?(geom)
|
297
298
|
check_geometry(geom)
|
298
|
-
bool_result(FFIGeos.GEOSOverlaps_r(Geos.
|
299
|
+
bool_result(FFIGeos.GEOSOverlaps_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
299
300
|
end
|
300
301
|
|
301
302
|
if FFIGeos.respond_to?(:GEOSCovers_r)
|
@@ -304,7 +305,7 @@ module Geos
|
|
304
305
|
# implementation.
|
305
306
|
def covers?(geom)
|
306
307
|
check_geometry(geom)
|
307
|
-
bool_result(FFIGeos.GEOSCovers_r(Geos.
|
308
|
+
bool_result(FFIGeos.GEOSCovers_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
308
309
|
end
|
309
310
|
else
|
310
311
|
def covers?(geom) #:nodoc:
|
@@ -326,7 +327,7 @@ module Geos
|
|
326
327
|
# implementation.
|
327
328
|
def covered_by?(geom)
|
328
329
|
check_geometry(geom)
|
329
|
-
bool_result(FFIGeos.GEOSCoveredBy_r(Geos.
|
330
|
+
bool_result(FFIGeos.GEOSCoveredBy_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
330
331
|
end
|
331
332
|
else
|
332
333
|
def covered_by?(geom) #:nodoc:
|
@@ -344,7 +345,7 @@ module Geos
|
|
344
345
|
|
345
346
|
def eql?(geom)
|
346
347
|
check_geometry(geom)
|
347
|
-
bool_result(FFIGeos.GEOSEquals_r(Geos.
|
348
|
+
bool_result(FFIGeos.GEOSEquals_r(Geos.current_handle_pointer, self.ptr, geom.ptr))
|
348
349
|
end
|
349
350
|
alias_method :equals?, :eql?
|
350
351
|
|
@@ -358,29 +359,29 @@ module Geos
|
|
358
359
|
|
359
360
|
def eql_exact?(geom, tolerance)
|
360
361
|
check_geometry(geom)
|
361
|
-
bool_result(FFIGeos.GEOSEqualsExact_r(Geos.
|
362
|
+
bool_result(FFIGeos.GEOSEqualsExact_r(Geos.current_handle_pointer, self.ptr, geom.ptr, tolerance))
|
362
363
|
end
|
363
364
|
alias_method :equals_exact?, :eql_exact?
|
364
365
|
alias_method :exactly_equals?, :eql_exact?
|
365
366
|
|
366
367
|
def eql_almost?(geom, decimal = 6)
|
367
368
|
check_geometry(geom)
|
368
|
-
bool_result(FFIGeos.GEOSEqualsExact_r(Geos.
|
369
|
+
bool_result(FFIGeos.GEOSEqualsExact_r(Geos.current_handle_pointer, self.ptr, geom.ptr, 0.5 * 10 ** (-decimal)))
|
369
370
|
end
|
370
371
|
alias_method :equals_almost?, :eql_almost?
|
371
372
|
alias_method :almost_equals?, :eql_almost?
|
372
373
|
|
373
374
|
def empty?
|
374
|
-
bool_result(FFIGeos.GEOSisEmpty_r(Geos.
|
375
|
+
bool_result(FFIGeos.GEOSisEmpty_r(Geos.current_handle_pointer, self.ptr))
|
375
376
|
end
|
376
377
|
|
377
378
|
def valid?
|
378
|
-
bool_result(FFIGeos.GEOSisValid_r(Geos.
|
379
|
+
bool_result(FFIGeos.GEOSisValid_r(Geos.current_handle_pointer, self.ptr))
|
379
380
|
end
|
380
381
|
|
381
382
|
# Returns a String describing whether or not the Geometry is valid.
|
382
383
|
def valid_reason
|
383
|
-
FFIGeos.GEOSisValidReason_r(Geos.
|
384
|
+
FFIGeos.GEOSisValidReason_r(Geos.current_handle_pointer, self.ptr)
|
384
385
|
end
|
385
386
|
|
386
387
|
# Returns a Hash containing the following structure on invalid geometries:
|
@@ -395,7 +396,7 @@ module Geos
|
|
395
396
|
detail = FFI::MemoryPointer.new(:pointer)
|
396
397
|
location = FFI::MemoryPointer.new(:pointer)
|
397
398
|
valid = bool_result(
|
398
|
-
FFIGeos.GEOSisValidDetail_r(Geos.
|
399
|
+
FFIGeos.GEOSisValidDetail_r(Geos.current_handle_pointer, self.ptr, flags, detail, location)
|
399
400
|
)
|
400
401
|
|
401
402
|
if !valid
|
@@ -409,15 +410,15 @@ module Geos
|
|
409
410
|
end
|
410
411
|
|
411
412
|
def simple?
|
412
|
-
bool_result(FFIGeos.GEOSisSimple_r(Geos.
|
413
|
+
bool_result(FFIGeos.GEOSisSimple_r(Geos.current_handle_pointer, self.ptr))
|
413
414
|
end
|
414
415
|
|
415
416
|
def ring?
|
416
|
-
bool_result(FFIGeos.GEOSisRing_r(Geos.
|
417
|
+
bool_result(FFIGeos.GEOSisRing_r(Geos.current_handle_pointer, self.ptr))
|
417
418
|
end
|
418
419
|
|
419
420
|
def has_z?
|
420
|
-
bool_result(FFIGeos.GEOSHasZ_r(Geos.
|
421
|
+
bool_result(FFIGeos.GEOSHasZ_r(Geos.current_handle_pointer, self.ptr))
|
421
422
|
end
|
422
423
|
|
423
424
|
# GEOS versions prior to 3.3.0 didn't handle exceptions and can crash on
|
@@ -427,9 +428,9 @@ module Geos
|
|
427
428
|
raise TypeError.new("Expected Geos::Point type") if !geom.is_a?(Geos::Point)
|
428
429
|
|
429
430
|
if normalized
|
430
|
-
FFIGeos.GEOSProjectNormalized_r(Geos.
|
431
|
+
FFIGeos.GEOSProjectNormalized_r(Geos.current_handle_pointer, self.ptr, geom.ptr)
|
431
432
|
else
|
432
|
-
FFIGeos.GEOSProject_r(Geos.
|
433
|
+
FFIGeos.GEOSProject_r(Geos.current_handle_pointer, self.ptr, geom.ptr)
|
433
434
|
end
|
434
435
|
end
|
435
436
|
|
@@ -440,9 +441,9 @@ module Geos
|
|
440
441
|
|
441
442
|
def interpolate(d, normalized = false)
|
442
443
|
ret = if normalized
|
443
|
-
FFIGeos.GEOSInterpolateNormalized_r(Geos.
|
444
|
+
FFIGeos.GEOSInterpolateNormalized_r(Geos.current_handle_pointer, self.ptr, d)
|
444
445
|
else
|
445
|
-
FFIGeos.GEOSInterpolate_r(Geos.
|
446
|
+
FFIGeos.GEOSInterpolate_r(Geos.current_handle_pointer, self.ptr, d)
|
446
447
|
end
|
447
448
|
|
448
449
|
cast_geometry_ptr(ret, :srid_copy => self.srid)
|
@@ -453,11 +454,11 @@ module Geos
|
|
453
454
|
end
|
454
455
|
|
455
456
|
def start_point
|
456
|
-
cast_geometry_ptr(FFIGeos.GEOSGeomGetStartPoint_r(Geos.
|
457
|
+
cast_geometry_ptr(FFIGeos.GEOSGeomGetStartPoint_r(Geos.current_handle_pointer, self.ptr), :srid_copy => self.srid)
|
457
458
|
end
|
458
459
|
|
459
460
|
def end_point
|
460
|
-
cast_geometry_ptr(FFIGeos.GEOSGeomGetEndPoint_r(Geos.
|
461
|
+
cast_geometry_ptr(FFIGeos.GEOSGeomGetEndPoint_r(Geos.current_handle_pointer, self.ptr), :srid_copy => self.srid)
|
461
462
|
end
|
462
463
|
|
463
464
|
def area
|
@@ -465,7 +466,7 @@ module Geos
|
|
465
466
|
0
|
466
467
|
else
|
467
468
|
double_ptr = FFI::MemoryPointer.new(:double)
|
468
|
-
FFIGeos.GEOSArea_r(Geos.
|
469
|
+
FFIGeos.GEOSArea_r(Geos.current_handle_pointer, self.ptr, double_ptr)
|
469
470
|
double_ptr.read_double
|
470
471
|
end
|
471
472
|
end
|
@@ -475,7 +476,7 @@ module Geos
|
|
475
476
|
0
|
476
477
|
else
|
477
478
|
double_ptr = FFI::MemoryPointer.new(:double)
|
478
|
-
FFIGeos.GEOSLength_r(Geos.
|
479
|
+
FFIGeos.GEOSLength_r(Geos.current_handle_pointer, self.ptr, double_ptr)
|
479
480
|
double_ptr.read_double
|
480
481
|
end
|
481
482
|
end
|
@@ -483,7 +484,7 @@ module Geos
|
|
483
484
|
def distance(geom)
|
484
485
|
check_geometry(geom)
|
485
486
|
double_ptr = FFI::MemoryPointer.new(:double)
|
486
|
-
FFIGeos.GEOSDistance_r(Geos.
|
487
|
+
FFIGeos.GEOSDistance_r(Geos.current_handle_pointer, self.ptr, geom.ptr, double_ptr)
|
487
488
|
double_ptr.read_double
|
488
489
|
end
|
489
490
|
|
@@ -493,9 +494,9 @@ module Geos
|
|
493
494
|
double_ptr = FFI::MemoryPointer.new(:double)
|
494
495
|
|
495
496
|
if densify_frac
|
496
|
-
FFIGeos.GEOSHausdorffDistanceDensify_r(Geos.
|
497
|
+
FFIGeos.GEOSHausdorffDistanceDensify_r(Geos.current_handle_pointer, self.ptr, geom.ptr, densify_frac, double_ptr)
|
497
498
|
else
|
498
|
-
FFIGeos.GEOSHausdorffDistance_r(Geos.
|
499
|
+
FFIGeos.GEOSHausdorffDistance_r(Geos.current_handle_pointer, self.ptr, geom.ptr, double_ptr)
|
499
500
|
end
|
500
501
|
|
501
502
|
double_ptr.read_double
|
@@ -505,7 +506,7 @@ module Geos
|
|
505
506
|
# Available in GEOS 3.4+.
|
506
507
|
def nearest_points(geom)
|
507
508
|
check_geometry(geom)
|
508
|
-
ptr = FFIGeos.GEOSNearestPoints_r(Geos.
|
509
|
+
ptr = FFIGeos.GEOSNearestPoints_r(Geos.current_handle_pointer, self.ptr, geom.ptr)
|
509
510
|
|
510
511
|
if !ptr.null?
|
511
512
|
CoordinateSequence.new(ptr)
|
@@ -515,7 +516,7 @@ module Geos
|
|
515
516
|
|
516
517
|
def snap(geom, tolerance)
|
517
518
|
check_geometry(geom)
|
518
|
-
cast_geometry_ptr(FFIGeos.GEOSSnap_r(Geos.
|
519
|
+
cast_geometry_ptr(FFIGeos.GEOSSnap_r(Geos.current_handle_pointer, self.ptr, geom.ptr, tolerance), {
|
519
520
|
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
|
520
521
|
})
|
521
522
|
end
|
@@ -523,7 +524,7 @@ module Geos
|
|
523
524
|
|
524
525
|
def shared_paths(geom)
|
525
526
|
check_geometry(geom)
|
526
|
-
cast_geometry_ptr(FFIGeos.GEOSSharedPaths_r(Geos.
|
527
|
+
cast_geometry_ptr(FFIGeos.GEOSSharedPaths_r(Geos.current_handle_pointer, self.ptr, geom.ptr), {
|
527
528
|
:srid_copy => pick_srid_from_geoms(self.srid, geom.srid)
|
528
529
|
}).to_a
|
529
530
|
end
|
@@ -542,7 +543,7 @@ module Geos
|
|
542
543
|
invalid_rings = FFI::MemoryPointer.new(:pointer)
|
543
544
|
|
544
545
|
rings = cast_geometry_ptr(
|
545
|
-
FFIGeos.GEOSPolygonize_full_r(Geos.
|
546
|
+
FFIGeos.GEOSPolygonize_full_r(Geos.current_handle_pointer, self.ptr, cuts, dangles, invalid_rings), {
|
546
547
|
:srid_copy => self.srid
|
547
548
|
}
|
548
549
|
)
|
@@ -563,14 +564,14 @@ module Geos
|
|
563
564
|
ary = FFI::MemoryPointer.new(:pointer)
|
564
565
|
ary.write_array_of_pointer([ self.ptr ])
|
565
566
|
|
566
|
-
cast_geometry_ptr(FFIGeos.GEOSPolygonize_r(Geos.
|
567
|
+
cast_geometry_ptr(FFIGeos.GEOSPolygonize_r(Geos.current_handle_pointer, ary, 1), :srid_copy => self.srid).to_a
|
567
568
|
end
|
568
569
|
|
569
570
|
def polygonize_cut_edges
|
570
571
|
ary = FFI::MemoryPointer.new(:pointer)
|
571
572
|
ary.write_array_of_pointer([ self.ptr ])
|
572
573
|
|
573
|
-
cast_geometry_ptr(FFIGeos.GEOSPolygonizer_getCutEdges_r(Geos.
|
574
|
+
cast_geometry_ptr(FFIGeos.GEOSPolygonizer_getCutEdges_r(Geos.current_handle_pointer, ary, 1), :srid_copy => self.srid).to_a
|
574
575
|
end
|
575
576
|
|
576
577
|
if FFIGeos.respond_to?(:GEOSDelaunayTriangulation_r)
|
@@ -588,7 +589,7 @@ module Geos
|
|
588
589
|
tolerance = args.first || options[:tolerance] || 0.0
|
589
590
|
only_edges = bool_to_int(options[:only_edges])
|
590
591
|
|
591
|
-
cast_geometry_ptr(FFIGeos.GEOSDelaunayTriangulation_r(Geos.
|
592
|
+
cast_geometry_ptr(FFIGeos.GEOSDelaunayTriangulation_r(Geos.current_handle_pointer, self.ptr, tolerance, only_edges))
|
592
593
|
end
|
593
594
|
end
|
594
595
|
|
@@ -616,7 +617,7 @@ module Geos
|
|
616
617
|
|
617
618
|
only_edges = bool_to_int(options[:only_edges])
|
618
619
|
|
619
|
-
cast_geometry_ptr(FFIGeos.GEOSVoronoiDiagram_r(Geos.
|
620
|
+
cast_geometry_ptr(FFIGeos.GEOSVoronoiDiagram_r(Geos.current_handle_pointer, self.ptr, envelope_ptr, tolerance, only_edges))
|
620
621
|
end
|
621
622
|
end
|
622
623
|
|
@@ -633,5 +634,53 @@ module Geos
|
|
633
634
|
|
634
635
|
"#<Geos::#{self.geom_type}: #{wkt}>"
|
635
636
|
end
|
637
|
+
|
638
|
+
if FFIGeos.respond_to?(:GEOSGeom_getPrecision_r)
|
639
|
+
def precision
|
640
|
+
FFIGeos.GEOSGeom_getPrecision_r(Geos.current_handle_pointer, self.ptr)
|
641
|
+
end
|
642
|
+
end
|
643
|
+
|
644
|
+
if FFIGeos.respond_to?(:GEOSGeom_setPrecision_r)
|
645
|
+
def with_precision(grid_size, options = {})
|
646
|
+
options = {
|
647
|
+
:no_topology => false,
|
648
|
+
:keep_collapsed => false
|
649
|
+
}.merge(options)
|
650
|
+
|
651
|
+
flags = options.reduce(0) do |memo, (key, value)|
|
652
|
+
memo |= Geos::PrecisionOptions[key] if value
|
653
|
+
memo
|
654
|
+
end
|
655
|
+
|
656
|
+
cast_geometry_ptr(FFIGeos.GEOSGeom_setPrecision_r(Geos.current_handle_pointer, self.ptr, grid_size, flags))
|
657
|
+
end
|
658
|
+
end
|
659
|
+
|
660
|
+
if FFIGeos.respond_to?(:GEOSMinimumRotatedRectangle_r)
|
661
|
+
def minimum_rotated_rectangle
|
662
|
+
cast_geometry_ptr(FFIGeos.GEOSMinimumRotatedRectangle_r(Geos.current_handle_pointer, self.ptr))
|
663
|
+
end
|
664
|
+
end
|
665
|
+
|
666
|
+
if FFIGeos.respond_to?(:GEOSMinimumClearance_r)
|
667
|
+
def minimum_clearance
|
668
|
+
double_ptr = FFI::MemoryPointer.new(:double)
|
669
|
+
ret = FFIGeos.GEOSMinimumClearance_r(Geos.current_handle_pointer, self.ptr, double_ptr)
|
670
|
+
double_ptr.read_double
|
671
|
+
end
|
672
|
+
end
|
673
|
+
|
674
|
+
if FFIGeos.respond_to?(:GEOSMinimumClearanceLine_r)
|
675
|
+
def minimum_clearance_line
|
676
|
+
cast_geometry_ptr(FFIGeos.GEOSMinimumClearanceLine_r(Geos.current_handle_pointer, self.ptr))
|
677
|
+
end
|
678
|
+
end
|
679
|
+
|
680
|
+
if FFIGeos.respond_to?(:GEOSMinimumWidth_r)
|
681
|
+
def minimum_width
|
682
|
+
cast_geometry_ptr(FFIGeos.GEOSMinimumWidth_r(Geos.current_handle_pointer, self.ptr))
|
683
|
+
end
|
684
|
+
end
|
636
685
|
end
|
637
686
|
end
|