rgeo 2.3.1 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +6 -0
- data/README.md +23 -14
- data/ext/geos_c_impl/analysis.c +30 -25
- data/ext/geos_c_impl/analysis.h +8 -7
- data/ext/geos_c_impl/coordinates.c +27 -21
- data/ext/geos_c_impl/coordinates.h +5 -2
- data/ext/geos_c_impl/errors.c +19 -10
- data/ext/geos_c_impl/errors.h +11 -4
- data/ext/geos_c_impl/extconf.rb +42 -28
- data/ext/geos_c_impl/factory.c +540 -451
- data/ext/geos_c_impl/factory.h +105 -95
- data/ext/geos_c_impl/geometry.c +593 -387
- data/ext/geos_c_impl/geometry.h +10 -5
- data/ext/geos_c_impl/geometry_collection.c +306 -339
- data/ext/geos_c_impl/geometry_collection.h +6 -20
- data/ext/geos_c_impl/globals.c +169 -0
- data/ext/geos_c_impl/globals.h +46 -0
- data/ext/geos_c_impl/line_string.c +271 -231
- data/ext/geos_c_impl/line_string.h +5 -8
- data/ext/geos_c_impl/main.c +16 -16
- data/ext/geos_c_impl/point.c +65 -67
- data/ext/geos_c_impl/point.h +4 -7
- data/ext/geos_c_impl/polygon.c +137 -135
- data/ext/geos_c_impl/polygon.h +11 -11
- data/ext/geos_c_impl/preface.h +16 -10
- data/ext/geos_c_impl/ruby_more.c +67 -0
- data/ext/geos_c_impl/ruby_more.h +25 -0
- data/lib/rgeo/cartesian/analysis.rb +5 -3
- data/lib/rgeo/cartesian/bounding_box.rb +74 -79
- data/lib/rgeo/cartesian/calculations.rb +64 -33
- data/lib/rgeo/cartesian/factory.rb +57 -102
- data/lib/rgeo/cartesian/feature_classes.rb +68 -46
- data/lib/rgeo/cartesian/feature_methods.rb +67 -25
- data/lib/rgeo/cartesian/interface.rb +6 -41
- data/lib/rgeo/cartesian/planar_graph.rb +373 -0
- data/lib/rgeo/cartesian/sweepline_intersector.rb +147 -0
- data/lib/rgeo/cartesian/valid_op.rb +69 -0
- data/lib/rgeo/cartesian.rb +3 -0
- data/lib/rgeo/coord_sys/cs/entities.rb +303 -99
- data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +90 -42
- data/lib/rgeo/coord_sys.rb +1 -20
- data/lib/rgeo/error.rb +15 -0
- data/lib/rgeo/feature/curve.rb +0 -11
- data/lib/rgeo/feature/factory.rb +26 -36
- data/lib/rgeo/feature/factory_generator.rb +6 -14
- data/lib/rgeo/feature/geometry.rb +146 -66
- data/lib/rgeo/feature/geometry_collection.rb +16 -9
- data/lib/rgeo/feature/line_string.rb +4 -5
- data/lib/rgeo/feature/linear_ring.rb +0 -1
- data/lib/rgeo/feature/multi_curve.rb +0 -6
- data/lib/rgeo/feature/multi_surface.rb +3 -4
- data/lib/rgeo/feature/point.rb +4 -5
- data/lib/rgeo/feature/polygon.rb +1 -2
- data/lib/rgeo/feature/surface.rb +3 -4
- data/lib/rgeo/feature/types.rb +69 -85
- data/lib/rgeo/geographic/factory.rb +98 -125
- data/lib/rgeo/geographic/interface.rb +69 -166
- data/lib/rgeo/geographic/projected_feature_classes.rb +21 -9
- data/lib/rgeo/geographic/projected_feature_methods.rb +67 -42
- data/lib/rgeo/geographic/projected_window.rb +36 -22
- data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -5
- data/lib/rgeo/geographic/simple_mercator_projector.rb +26 -25
- data/lib/rgeo/geographic/spherical_feature_classes.rb +29 -9
- data/lib/rgeo/geographic/spherical_feature_methods.rb +86 -9
- data/lib/rgeo/geographic/spherical_math.rb +17 -20
- data/lib/rgeo/geographic.rb +1 -1
- data/lib/rgeo/geos/capi_factory.rb +87 -158
- data/lib/rgeo/geos/capi_feature_classes.rb +50 -36
- data/lib/rgeo/geos/ffi_factory.rb +105 -173
- data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
- data/lib/rgeo/geos/ffi_feature_methods.rb +105 -127
- data/lib/rgeo/geos/interface.rb +20 -59
- data/lib/rgeo/geos/utils.rb +5 -5
- data/lib/rgeo/geos/zm_factory.rb +53 -95
- data/lib/rgeo/geos/zm_feature_methods.rb +30 -33
- data/lib/rgeo/geos.rb +8 -8
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +9 -22
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +28 -56
- data/lib/rgeo/impl_helper/basic_point_methods.rb +2 -14
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +17 -26
- data/lib/rgeo/impl_helper/utils.rb +21 -0
- data/lib/rgeo/impl_helper/valid_op.rb +350 -0
- data/lib/rgeo/impl_helper/validity_check.rb +139 -0
- data/lib/rgeo/impl_helper.rb +1 -0
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +73 -63
- data/lib/rgeo/wkrep/wkb_parser.rb +33 -31
- data/lib/rgeo/wkrep/wkt_generator.rb +52 -45
- data/lib/rgeo/wkrep/wkt_parser.rb +48 -35
- data/lib/rgeo.rb +1 -3
- metadata +50 -13
- data/lib/rgeo/coord_sys/srs_database/entry.rb +0 -107
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +0 -64
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +0 -65
data/lib/rgeo/geos/zm_factory.rb
CHANGED
@@ -9,7 +9,6 @@
|
|
9
9
|
module RGeo
|
10
10
|
module Geos
|
11
11
|
# A factory for Geos that handles both Z and M.
|
12
|
-
|
13
12
|
class ZMFactory
|
14
13
|
include Feature::Factory::Instance
|
15
14
|
include ImplHelper::Utils
|
@@ -41,24 +40,14 @@ module RGeo
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def initialize(opts = {}) # :nodoc:
|
44
|
-
proj4 = opts[:proj4]
|
45
43
|
coord_sys = opts[:coord_sys]
|
46
44
|
srid = opts[:srid]
|
47
|
-
if (!proj4 || !coord_sys) && srid && (db = opts[:srs_database])
|
48
|
-
entry = db.get(srid.to_i)
|
49
|
-
if entry
|
50
|
-
proj4 ||= entry.proj4
|
51
|
-
coord_sys ||= entry.coord_sys
|
52
|
-
end
|
53
|
-
end
|
54
45
|
srid ||= coord_sys.authority_code if coord_sys
|
55
46
|
config = {
|
56
|
-
uses_lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions] ||
|
57
|
-
opts[:uses_lenient_multi_polygon_assertions],
|
58
47
|
buffer_resolution: opts[:buffer_resolution], auto_prepare: opts[:auto_prepare],
|
59
48
|
wkt_generator: opts[:wkt_generator], wkt_parser: opts[:wkt_parser],
|
60
49
|
wkb_generator: opts[:wkb_generator], wkb_parser: opts[:wkb_parser],
|
61
|
-
srid: srid.to_i,
|
50
|
+
srid: srid.to_i, coord_sys: coord_sys
|
62
51
|
}
|
63
52
|
native_interface = opts[:native_interface] || Geos.preferred_native_interface
|
64
53
|
if native_interface == :ffi
|
@@ -70,33 +59,37 @@ module RGeo
|
|
70
59
|
end
|
71
60
|
|
72
61
|
wkt_generator = opts[:wkt_generator]
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
62
|
+
@wkt_generator =
|
63
|
+
case wkt_generator
|
64
|
+
when Hash
|
65
|
+
WKRep::WKTGenerator.new(wkt_generator)
|
66
|
+
else
|
67
|
+
WKRep::WKTGenerator.new(convert_case: :upper)
|
68
|
+
end
|
79
69
|
wkb_generator = opts[:wkb_generator]
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
70
|
+
@wkb_generator =
|
71
|
+
case wkb_generator
|
72
|
+
when Hash
|
73
|
+
WKRep::WKBGenerator.new(wkb_generator)
|
74
|
+
else
|
75
|
+
WKRep::WKBGenerator.new
|
76
|
+
end
|
86
77
|
wkt_parser = opts[:wkt_parser]
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
78
|
+
@wkt_parser =
|
79
|
+
case wkt_parser
|
80
|
+
when Hash
|
81
|
+
WKRep::WKTParser.new(self, wkt_parser)
|
82
|
+
else
|
83
|
+
WKRep::WKTParser.new(self)
|
84
|
+
end
|
93
85
|
wkb_parser = opts[:wkb_parser]
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
86
|
+
@wkb_parser =
|
87
|
+
case wkb_parser
|
88
|
+
when Hash
|
89
|
+
WKRep::WKBParser.new(self, wkb_parser)
|
90
|
+
else
|
91
|
+
WKRep::WKBParser.new(self)
|
92
|
+
end
|
100
93
|
end
|
101
94
|
|
102
95
|
# Marshal support
|
@@ -109,29 +102,18 @@ module RGeo
|
|
109
102
|
"wkbg" => @wkb_generator.properties,
|
110
103
|
"wktp" => @wkt_parser.properties,
|
111
104
|
"wkbp" => @wkb_parser.properties,
|
112
|
-
"lmpa" => @zfactory.lenient_multi_polygon_assertions?,
|
113
105
|
"apre" => @zfactory.property(:auto_prepare) == :simple,
|
114
106
|
"nffi" => @zfactory.is_a?(FFIFactory)
|
115
107
|
}
|
116
|
-
proj4 = @zfactory.proj4
|
117
108
|
coord_sys = @zfactory.coord_sys
|
118
|
-
hash["proj4"] = proj4.marshal_dump if proj4
|
119
109
|
hash["cs"] = coord_sys.to_wkt if coord_sys
|
120
110
|
hash
|
121
111
|
end
|
122
112
|
|
123
113
|
def marshal_load(data) # :nodoc:
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
else
|
128
|
-
proj4 = nil
|
129
|
-
end
|
130
|
-
if (coord_sys_data = data["cs"])
|
131
|
-
coord_sys = CoordSys::CS.create_from_wkt(coord_sys_data)
|
132
|
-
else
|
133
|
-
coord_sys = nil
|
134
|
-
end
|
114
|
+
cs_class = CoordSys::CONFIG.default_coord_sys_class
|
115
|
+
coord_sys = data["cs"]&.then { |cs| cs_class.create_from_wkt(cs) }
|
116
|
+
|
135
117
|
initialize(
|
136
118
|
native_interface: (data["nffi"] ? :ffi : :capi),
|
137
119
|
has_z_coordinate: data["hasz"],
|
@@ -142,9 +124,7 @@ module RGeo
|
|
142
124
|
wkb_generator: symbolize_hash(data["wkbg"]),
|
143
125
|
wkt_parser: symbolize_hash(data["wktp"]),
|
144
126
|
wkb_parser: symbolize_hash(data["wkbp"]),
|
145
|
-
uses_lenient_multi_polygon_assertions: data["lmpa"],
|
146
127
|
auto_prepare: (data["apre"] ? :simple : :disabled),
|
147
|
-
proj4: proj4,
|
148
128
|
coord_sys: coord_sys
|
149
129
|
)
|
150
130
|
end
|
@@ -154,38 +134,22 @@ module RGeo
|
|
154
134
|
def encode_with(coder) # :nodoc:
|
155
135
|
coder["srid"] = @zfactory.srid
|
156
136
|
coder["buffer_resolution"] = @zfactory.buffer_resolution
|
157
|
-
coder["lenient_multi_polygon_assertions"] = @zfactory.lenient_multi_polygon_assertions?
|
158
137
|
coder["wkt_generator"] = @wkt_generator.properties
|
159
138
|
coder["wkb_generator"] = @wkb_generator.properties
|
160
139
|
coder["wkt_parser"] = @wkt_parser.properties
|
161
140
|
coder["wkb_parser"] = @wkb_parser.properties
|
162
141
|
coder["auto_prepare"] = @zfactory.property(:auto_prepare).to_s
|
163
142
|
coder["native_interface"] = @zfactory.is_a?(FFIFactory) ? "ffi" : "capi"
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
if (coord_sys = @zfactory.coord_sys)
|
169
|
-
coder["coord_sys"] = coord_sys.to_wkt
|
170
|
-
end
|
143
|
+
|
144
|
+
return unless (coord_sys = @zfactory.coord_sys)
|
145
|
+
|
146
|
+
coder["coord_sys"] = coord_sys.to_wkt
|
171
147
|
end
|
172
148
|
|
173
149
|
def init_with(coder) # :nodoc:
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
proj4 = CoordSys::Proj4.create(proj4_data["proj4"], radians: proj4_data["radians"])
|
178
|
-
else
|
179
|
-
proj4 = CoordSys::Proj4.create(proj4_data.to_s)
|
180
|
-
end
|
181
|
-
else
|
182
|
-
proj4 = nil
|
183
|
-
end
|
184
|
-
if (coord_sys_data = coder["cs"])
|
185
|
-
coord_sys = CoordSys::CS.create_from_wkt(coord_sys_data.to_s)
|
186
|
-
else
|
187
|
-
coord_sys = nil
|
188
|
-
end
|
150
|
+
cs_class = CoordSys::CONFIG.default_coord_sys_class
|
151
|
+
coord_sys = coder["cs"]&.then { |cs| cs_class.create_from_wkt(cs) }
|
152
|
+
|
189
153
|
initialize(
|
190
154
|
native_interface: coder["native_interface"] == "ffi" ? :ffi : :capi,
|
191
155
|
has_z_coordinate: coder["has_z_coordinate"],
|
@@ -197,8 +161,6 @@ module RGeo
|
|
197
161
|
wkt_parser: symbolize_hash(coder["wkt_parser"]),
|
198
162
|
wkb_parser: symbolize_hash(coder["wkb_parser"]),
|
199
163
|
auto_prepare: coder["auto_prepare"] == "disabled" ? :disabled : :simple,
|
200
|
-
uses_lenient_multi_polygon_assertions: coder["lenient_multi_polygon_assertions"],
|
201
|
-
proj4: proj4,
|
202
164
|
coord_sys: coord_sys
|
203
165
|
)
|
204
166
|
end
|
@@ -216,12 +178,6 @@ module RGeo
|
|
216
178
|
@zfactory.buffer_resolution
|
217
179
|
end
|
218
180
|
|
219
|
-
# Returns true if this factory is lenient with MultiPolygon assertions
|
220
|
-
|
221
|
-
def lenient_multi_polygon_assertions?
|
222
|
-
@zfactory.lenient_multi_polygon_assertions?
|
223
|
-
end
|
224
|
-
|
225
181
|
# Returns the z-only factory corresponding to this factory.
|
226
182
|
|
227
183
|
def z_factory
|
@@ -236,8 +192,8 @@ module RGeo
|
|
236
192
|
|
237
193
|
# Factory equivalence test.
|
238
194
|
|
239
|
-
def eql?(
|
240
|
-
|
195
|
+
def eql?(other)
|
196
|
+
other.is_a?(ZMFactory) && other.z_factory == @zfactory
|
241
197
|
end
|
242
198
|
alias == eql?
|
243
199
|
|
@@ -271,7 +227,11 @@ module RGeo
|
|
271
227
|
# See RGeo::Feature::Factory#point
|
272
228
|
|
273
229
|
def point(x, y, z = 0, m = 0)
|
274
|
-
create_feature(
|
230
|
+
create_feature(
|
231
|
+
ZMPointImpl,
|
232
|
+
@zfactory.point(x, y, z),
|
233
|
+
@mfactory.point(x, y, m)
|
234
|
+
)
|
275
235
|
end
|
276
236
|
|
277
237
|
# See RGeo::Feature::Factory#line_string
|
@@ -295,7 +255,11 @@ module RGeo
|
|
295
255
|
# See RGeo::Feature::Factory#polygon
|
296
256
|
|
297
257
|
def polygon(outer_ring, inner_rings = nil)
|
298
|
-
create_feature(
|
258
|
+
create_feature(
|
259
|
+
ZMPolygonImpl,
|
260
|
+
@zfactory.polygon(outer_ring, inner_rings),
|
261
|
+
@mfactory.polygon(outer_ring, inner_rings)
|
262
|
+
)
|
299
263
|
end
|
300
264
|
|
301
265
|
# See RGeo::Feature::Factory#collection
|
@@ -322,12 +286,6 @@ module RGeo
|
|
322
286
|
create_feature(ZMMultiPolygonImpl, @zfactory.multi_polygon(elems), @mfactory.multi_polygon(elems))
|
323
287
|
end
|
324
288
|
|
325
|
-
# See RGeo::Feature::Factory#proj4
|
326
|
-
|
327
|
-
def proj4
|
328
|
-
@zfactory.proj4
|
329
|
-
end
|
330
|
-
|
331
289
|
# See RGeo::Feature::Factory#coord_sys
|
332
290
|
|
333
291
|
def coord_sys
|
@@ -347,7 +305,7 @@ module RGeo
|
|
347
305
|
# Optimization if we're just changing factories, but to
|
348
306
|
# another ZM factory.
|
349
307
|
if original.factory != self && ntype == type &&
|
350
|
-
(!project || original.factory.
|
308
|
+
(!project || original.factory.coord_sys == @coord_sys)
|
351
309
|
zresult = original.z_geometry.dup
|
352
310
|
zresult.factory = @zfactory
|
353
311
|
mresult = original.m_geometry.dup
|
@@ -356,7 +314,7 @@ module RGeo
|
|
356
314
|
end
|
357
315
|
# LineString conversion optimization.
|
358
316
|
if (original.factory != self || ntype != type) &&
|
359
|
-
(!project || original.factory.
|
317
|
+
(!project || original.factory.coord_sys == @coord_sys) &&
|
360
318
|
type.subtypeof?(Feature::LineString) && ntype.subtypeof?(Feature::LineString)
|
361
319
|
klass = Factory::IMPL_CLASSES[ntype]
|
362
320
|
zresult = klass._copy_from(@zfactory, original.z_geometry)
|
@@ -26,7 +26,7 @@ module RGeo
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def hash
|
29
|
-
@factory
|
29
|
+
[@factory, @zgeometry, @mgeometry].hash
|
30
30
|
end
|
31
31
|
|
32
32
|
def factory
|
@@ -45,6 +45,14 @@ module RGeo
|
|
45
45
|
@zgeometry.dimension
|
46
46
|
end
|
47
47
|
|
48
|
+
def coordinate_dimension
|
49
|
+
4
|
50
|
+
end
|
51
|
+
|
52
|
+
def spatial_dimension
|
53
|
+
3
|
54
|
+
end
|
55
|
+
|
48
56
|
def geometry_type
|
49
57
|
@zgeometry.geometry_type
|
50
58
|
end
|
@@ -69,18 +77,16 @@ module RGeo
|
|
69
77
|
@zgeometry.empty?
|
70
78
|
end
|
71
79
|
|
72
|
-
def is_empty?
|
73
|
-
warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
74
|
-
empty?
|
75
|
-
end
|
76
|
-
|
77
80
|
def simple?
|
78
81
|
@zgeometry.simple?
|
79
82
|
end
|
80
83
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
84
|
+
def is_3d?
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
88
|
+
def measured?
|
89
|
+
true
|
84
90
|
end
|
85
91
|
|
86
92
|
def boundary
|
@@ -122,7 +128,6 @@ module RGeo
|
|
122
128
|
def relate?(rhs, pattern)
|
123
129
|
@zgeometry.relate?(RGeo::Feature.cast(rhs, self).z_geometry, pattern)
|
124
130
|
end
|
125
|
-
alias relate relate? # DEPRECATED
|
126
131
|
|
127
132
|
def distance(rhs)
|
128
133
|
@zgeometry.distance(RGeo::Feature.cast(rhs, self).z_geometry)
|
@@ -153,12 +158,19 @@ module RGeo
|
|
153
158
|
|
154
159
|
def sym_difference(rhs)
|
155
160
|
rhs = RGeo::Feature.cast(rhs, self)
|
156
|
-
@factory.create_feature(
|
161
|
+
@factory.create_feature(
|
162
|
+
nil,
|
163
|
+
@zgeometry.sym_difference(rhs.z_geometry),
|
164
|
+
@mgeometry.sym_difference(rhs.m_geometry)
|
165
|
+
)
|
157
166
|
end
|
158
167
|
|
159
168
|
def rep_equals?(rhs)
|
160
169
|
rhs = RGeo::Feature.cast(rhs, self)
|
161
|
-
rhs.is_a?(self.class) &&
|
170
|
+
rhs.is_a?(self.class) &&
|
171
|
+
@factory.eql?(rhs.factory) &&
|
172
|
+
@zgeometry.rep_equals?(rhs.z_geometry) &&
|
173
|
+
@mgeometry.rep_equals?(rhs.m_geometry)
|
162
174
|
end
|
163
175
|
|
164
176
|
alias eql? rep_equals?
|
@@ -236,26 +248,16 @@ module RGeo
|
|
236
248
|
@zgeometry.closed?
|
237
249
|
end
|
238
250
|
|
239
|
-
def is_closed?
|
240
|
-
warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
241
|
-
closed?
|
242
|
-
end
|
243
|
-
|
244
251
|
def ring?
|
245
252
|
@zgeometry.ring?
|
246
253
|
end
|
247
254
|
|
248
|
-
def is_ring?
|
249
|
-
warn "The is_ring? method is deprecated, please use the ring? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
250
|
-
ring?
|
251
|
-
end
|
252
|
-
|
253
255
|
def num_points
|
254
256
|
@zgeometry.num_points
|
255
257
|
end
|
256
258
|
|
257
|
-
def point_n(
|
258
|
-
@factory.create_feature(ZMPointImpl, @zgeometry.point_n(
|
259
|
+
def point_n(idx)
|
260
|
+
@factory.create_feature(ZMPointImpl, @zgeometry.point_n(idx), @mgeometry.point_n(idx))
|
259
261
|
end
|
260
262
|
|
261
263
|
def points
|
@@ -294,8 +296,8 @@ module RGeo
|
|
294
296
|
@zgeometry.num_interior_rings
|
295
297
|
end
|
296
298
|
|
297
|
-
def interior_ring_n(
|
298
|
-
@factory.create_feature(ZMLineStringImpl, @zgeometry.interior_ring_n(
|
299
|
+
def interior_ring_n(idx)
|
300
|
+
@factory.create_feature(ZMLineStringImpl, @zgeometry.interior_ring_n(idx), @mgeometry.interior_ring_n(idx))
|
299
301
|
end
|
300
302
|
|
301
303
|
def interior_rings
|
@@ -319,8 +321,8 @@ module RGeo
|
|
319
321
|
end
|
320
322
|
alias size num_geometries
|
321
323
|
|
322
|
-
def geometry_n(
|
323
|
-
@factory.create_feature(nil, @zgeometry.geometry_n(
|
324
|
+
def geometry_n(idx)
|
325
|
+
@factory.create_feature(nil, @zgeometry.geometry_n(idx), @mgeometry.geometry_n(idx))
|
324
326
|
end
|
325
327
|
alias [] geometry_n
|
326
328
|
|
@@ -347,11 +349,6 @@ module RGeo
|
|
347
349
|
@zgeometry.closed?
|
348
350
|
end
|
349
351
|
|
350
|
-
def is_closed?
|
351
|
-
warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
352
|
-
closed?
|
353
|
-
end
|
354
|
-
|
355
352
|
def coordinates
|
356
353
|
each.map(&:coordinates)
|
357
354
|
end
|
data/lib/rgeo/geos.rb
CHANGED
@@ -33,9 +33,6 @@ module RGeo
|
|
33
33
|
require_relative "geos/capi_feature_classes"
|
34
34
|
require_relative "geos/capi_factory"
|
35
35
|
end
|
36
|
-
require_relative "geos/ffi_feature_methods"
|
37
|
-
require_relative "geos/ffi_feature_classes"
|
38
|
-
require_relative "geos/ffi_factory"
|
39
36
|
require_relative "geos/zm_feature_methods"
|
40
37
|
require_relative "geos/zm_feature_classes"
|
41
38
|
require_relative "geos/zm_factory"
|
@@ -48,12 +45,15 @@ module RGeo
|
|
48
45
|
raise "Problem loading FFI" unless ::FFI::AutoPointer
|
49
46
|
FFI_SUPPORTED = true
|
50
47
|
FFI_SUPPORT_EXCEPTION = nil
|
51
|
-
rescue LoadError =>
|
48
|
+
rescue LoadError, StandardError => e
|
52
49
|
FFI_SUPPORTED = false
|
53
|
-
FFI_SUPPORT_EXCEPTION =
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
FFI_SUPPORT_EXCEPTION = e
|
51
|
+
end
|
52
|
+
|
53
|
+
if FFI_SUPPORTED
|
54
|
+
require_relative "geos/ffi_feature_methods"
|
55
|
+
require_relative "geos/ffi_feature_classes"
|
56
|
+
require_relative "geos/ffi_factory"
|
57
57
|
end
|
58
58
|
|
59
59
|
# Default preferred native interface
|
@@ -20,19 +20,19 @@ module RGeo
|
|
20
20
|
raise Error::InvalidGeometry, "Could not cast #{elem}" unless elem
|
21
21
|
elem
|
22
22
|
end
|
23
|
-
|
23
|
+
init_geometry
|
24
24
|
end
|
25
25
|
|
26
26
|
def num_geometries
|
27
27
|
@elements.size
|
28
28
|
end
|
29
29
|
|
30
|
-
def geometry_n(
|
31
|
-
|
30
|
+
def geometry_n(idx)
|
31
|
+
idx < 0 ? nil : @elements[idx]
|
32
32
|
end
|
33
33
|
|
34
|
-
def [](
|
35
|
-
@elements[
|
34
|
+
def [](idx)
|
35
|
+
@elements[idx]
|
36
36
|
end
|
37
37
|
|
38
38
|
def each(&block)
|
@@ -55,11 +55,6 @@ module RGeo
|
|
55
55
|
@elements.size == 0
|
56
56
|
end
|
57
57
|
|
58
|
-
def is_empty?
|
59
|
-
warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
60
|
-
empty?
|
61
|
-
end
|
62
|
-
|
63
58
|
def rep_equals?(rhs)
|
64
59
|
if rhs.is_a?(self.class) && rhs.factory.eql?(@factory) && @elements.size == rhs.num_geometries
|
65
60
|
rhs.each_with_index { |p, i| return false unless @elements[i].rep_equals?(p) }
|
@@ -69,10 +64,7 @@ module RGeo
|
|
69
64
|
end
|
70
65
|
|
71
66
|
def hash
|
72
|
-
@hash ||=
|
73
|
-
hash = [factory, geometry_type].hash
|
74
|
-
@elements.inject(hash) { |h, g| (1_664_525 * h + g.hash).hash }
|
75
|
-
end
|
67
|
+
@hash ||= [factory, geometry_type, *@elements].hash
|
76
68
|
end
|
77
69
|
|
78
70
|
private
|
@@ -91,7 +83,7 @@ module RGeo
|
|
91
83
|
raise Error::InvalidGeometry, "Could not cast #{elem}" unless elem
|
92
84
|
elem
|
93
85
|
end
|
94
|
-
|
86
|
+
init_geometry
|
95
87
|
end
|
96
88
|
|
97
89
|
def geometry_type
|
@@ -102,11 +94,6 @@ module RGeo
|
|
102
94
|
all?(&:closed?)
|
103
95
|
end
|
104
96
|
|
105
|
-
def is_closed?
|
106
|
-
warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
107
|
-
closed?
|
108
|
-
end
|
109
|
-
|
110
97
|
def length
|
111
98
|
@elements.inject(0.0) { |sum, obj| sum + obj.length }
|
112
99
|
end
|
@@ -152,7 +139,7 @@ module RGeo
|
|
152
139
|
raise Error::InvalidGeometry, "Could not cast #{elem}" unless elem
|
153
140
|
elem
|
154
141
|
end
|
155
|
-
|
142
|
+
init_geometry
|
156
143
|
end
|
157
144
|
|
158
145
|
def geometry_type
|
@@ -176,7 +163,7 @@ module RGeo
|
|
176
163
|
raise Error::InvalidGeometry, "Could not cast #{elem}" unless elem
|
177
164
|
elem
|
178
165
|
end
|
179
|
-
|
166
|
+
init_geometry
|
180
167
|
end
|
181
168
|
|
182
169
|
def geometry_type
|