rgeo 1.1.2 → 2.0.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/ext/geos_c_impl/extconf.rb +5 -3
- data/ext/geos_c_impl/factory.c +4 -4
- data/ext/geos_c_impl/geometry.c +1 -1
- data/lib/rgeo.rb +2 -4
- data/lib/rgeo/cartesian.rb +6 -16
- data/lib/rgeo/cartesian/analysis.rb +22 -20
- data/lib/rgeo/cartesian/bounding_box.rb +83 -79
- data/lib/rgeo/cartesian/calculations.rb +40 -38
- data/lib/rgeo/cartesian/factory.rb +134 -169
- data/lib/rgeo/cartesian/feature_classes.rb +2 -18
- data/lib/rgeo/cartesian/feature_methods.rb +37 -39
- data/lib/rgeo/cartesian/interface.rb +11 -9
- data/lib/rgeo/coord_sys.rb +9 -8
- data/lib/rgeo/coord_sys/cs/entities.rb +345 -303
- data/lib/rgeo/coord_sys/cs/factories.rb +30 -28
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +128 -126
- data/lib/rgeo/coord_sys/srs_database/{interface.rb → entry.rb} +26 -32
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +19 -17
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +21 -19
- data/lib/rgeo/error.rb +3 -1
- data/lib/rgeo/feature.rb +23 -34
- data/lib/rgeo/feature/curve.rb +2 -0
- data/lib/rgeo/feature/factory.rb +15 -13
- data/lib/rgeo/feature/factory_generator.rb +7 -5
- data/lib/rgeo/feature/geometry.rb +31 -29
- data/lib/rgeo/feature/geometry_collection.rb +6 -4
- data/lib/rgeo/feature/line.rb +2 -0
- data/lib/rgeo/feature/line_string.rb +3 -1
- data/lib/rgeo/feature/linear_ring.rb +2 -0
- data/lib/rgeo/feature/multi_curve.rb +2 -0
- data/lib/rgeo/feature/multi_line_string.rb +2 -0
- data/lib/rgeo/feature/multi_point.rb +2 -0
- data/lib/rgeo/feature/multi_polygon.rb +2 -0
- data/lib/rgeo/feature/multi_surface.rb +2 -0
- data/lib/rgeo/feature/point.rb +2 -0
- data/lib/rgeo/feature/polygon.rb +3 -1
- data/lib/rgeo/feature/surface.rb +2 -0
- data/lib/rgeo/feature/types.rb +107 -103
- data/lib/rgeo/geographic.rb +17 -27
- data/lib/rgeo/geographic/factory.rb +154 -199
- data/lib/rgeo/geographic/interface.rb +141 -137
- data/lib/rgeo/geographic/proj4_projector.rb +28 -23
- data/lib/rgeo/geographic/projected_feature_classes.rb +2 -18
- data/lib/rgeo/geographic/projected_feature_methods.rb +59 -49
- data/lib/rgeo/geographic/projected_window.rb +4 -2
- data/lib/rgeo/geographic/simple_mercator_projector.rb +41 -39
- data/lib/rgeo/geographic/spherical_feature_classes.rb +2 -18
- data/lib/rgeo/geographic/spherical_feature_methods.rb +67 -67
- data/lib/rgeo/geographic/spherical_math.rb +81 -87
- data/lib/rgeo/geos.rb +23 -34
- data/lib/rgeo/geos/capi_factory.rb +106 -135
- data/lib/rgeo/geos/capi_feature_classes.rb +19 -37
- data/lib/rgeo/geos/ffi_factory.rb +276 -297
- data/lib/rgeo/geos/ffi_feature_classes.rb +2 -20
- data/lib/rgeo/geos/ffi_feature_methods.rb +170 -166
- data/lib/rgeo/geos/interface.rb +25 -23
- data/lib/rgeo/geos/utils.rb +47 -39
- data/lib/rgeo/geos/zm_factory.rb +171 -185
- data/lib/rgeo/geos/zm_feature_classes.rb +2 -20
- data/lib/rgeo/geos/zm_feature_methods.rb +76 -72
- data/lib/rgeo/impl_helper.rb +1 -11
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +72 -75
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +21 -23
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +57 -49
- data/lib/rgeo/impl_helper/basic_point_methods.rb +29 -25
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +31 -27
- data/lib/rgeo/impl_helper/math.rb +2 -0
- data/lib/rgeo/impl_helper/utils.rb +9 -15
- data/lib/rgeo/version.rb +3 -1
- data/lib/rgeo/wkrep.rb +20 -30
- data/lib/rgeo/wkrep/wkb_generator.rb +87 -84
- data/lib/rgeo/wkrep/wkb_parser.rb +93 -93
- data/lib/rgeo/wkrep/wkt_generator.rb +67 -63
- data/lib/rgeo/wkrep/wkt_parser.rb +172 -168
- metadata +17 -32
- data/lib/rgeo/feature/mixins.rb +0 -143
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -----------------------------------------------------------------------------
|
2
4
|
#
|
3
5
|
# FFI-GEOS geometry implementation
|
@@ -8,76 +10,56 @@ module RGeo
|
|
8
10
|
module Geos
|
9
11
|
class FFIGeometryImpl # :nodoc:
|
10
12
|
include FFIGeometryMethods
|
11
|
-
|
12
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::Geometry).include_in_class(self, true)
|
13
13
|
end
|
14
14
|
|
15
15
|
class FFIPointImpl # :nodoc:
|
16
16
|
include FFIGeometryMethods
|
17
17
|
include FFIPointMethods
|
18
|
-
|
19
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::Point).include_in_class(self, true)
|
20
18
|
end
|
21
19
|
|
22
20
|
class FFILineStringImpl # :nodoc:
|
23
21
|
include FFIGeometryMethods
|
24
22
|
include FFILineStringMethods
|
25
|
-
|
26
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::LineString).include_in_class(self, true)
|
27
23
|
end
|
28
24
|
|
29
25
|
class FFILinearRingImpl # :nodoc:
|
30
26
|
include FFIGeometryMethods
|
31
27
|
include FFILineStringMethods
|
32
28
|
include FFILinearRingMethods
|
33
|
-
|
34
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::LinearRing).include_in_class(self, true)
|
35
29
|
end
|
36
30
|
|
37
31
|
class FFILineImpl # :nodoc:
|
38
32
|
include FFIGeometryMethods
|
39
33
|
include FFILineStringMethods
|
40
34
|
include FFILineMethods
|
41
|
-
|
42
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::Line).include_in_class(self, true)
|
43
35
|
end
|
44
36
|
|
45
37
|
class FFIPolygonImpl # :nodoc:
|
46
38
|
include FFIGeometryMethods
|
47
39
|
include FFIPolygonMethods
|
48
|
-
|
49
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::Polygon).include_in_class(self, true)
|
50
40
|
end
|
51
41
|
|
52
42
|
class FFIGeometryCollectionImpl # :nodoc:
|
53
43
|
include FFIGeometryMethods
|
54
44
|
include FFIGeometryCollectionMethods
|
55
|
-
|
56
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::GeometryCollection).include_in_class(self, true)
|
57
45
|
end
|
58
46
|
|
59
47
|
class FFIMultiPointImpl # :nodoc:
|
60
48
|
include FFIGeometryMethods
|
61
49
|
include FFIGeometryCollectionMethods
|
62
50
|
include FFIMultiPointMethods
|
63
|
-
|
64
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPoint).include_in_class(self, true)
|
65
51
|
end
|
66
52
|
|
67
53
|
class FFIMultiLineStringImpl # :nodoc:
|
68
54
|
include FFIGeometryMethods
|
69
55
|
include FFIGeometryCollectionMethods
|
70
56
|
include FFIMultiLineStringMethods
|
71
|
-
|
72
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiLineString).include_in_class(self, true)
|
73
57
|
end
|
74
58
|
|
75
59
|
class FFIMultiPolygonImpl # :nodoc:
|
76
60
|
include FFIGeometryMethods
|
77
61
|
include FFIGeometryCollectionMethods
|
78
62
|
include FFIMultiPolygonMethods
|
79
|
-
|
80
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPolygon).include_in_class(self, true)
|
81
63
|
end
|
82
64
|
end
|
83
65
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -----------------------------------------------------------------------------
|
2
4
|
#
|
3
5
|
# FFI-GEOS geometry implementation
|
@@ -9,12 +11,12 @@ module RGeo
|
|
9
11
|
module FFIGeometryMethods # :nodoc:
|
10
12
|
include Feature::Instance
|
11
13
|
|
12
|
-
def initialize(
|
13
|
-
@factory =
|
14
|
-
@fg_geom =
|
15
|
-
@_fg_prep =
|
16
|
-
@_klasses =
|
17
|
-
|
14
|
+
def initialize(factory, fg_geom, klasses)
|
15
|
+
@factory = factory
|
16
|
+
@fg_geom = fg_geom
|
17
|
+
@_fg_prep = factory._auto_prepare ? 1 : 0
|
18
|
+
@_klasses = klasses
|
19
|
+
fg_geom.srid = factory.srid
|
18
20
|
end
|
19
21
|
|
20
22
|
def inspect
|
@@ -24,12 +26,12 @@ module RGeo
|
|
24
26
|
# Marshal support
|
25
27
|
|
26
28
|
def marshal_dump # :nodoc:
|
27
|
-
[@factory, @factory.
|
29
|
+
[@factory, @factory.write_for_marshal(self)]
|
28
30
|
end
|
29
31
|
|
30
|
-
def marshal_load(
|
31
|
-
@factory =
|
32
|
-
@fg_geom = @factory.
|
32
|
+
def marshal_load(data) # :nodoc:
|
33
|
+
@factory = data[0]
|
34
|
+
@fg_geom = @factory.read_for_marshal(data[1])
|
33
35
|
@fg_geom.srid = @factory.srid
|
34
36
|
@_fg_prep = @factory._auto_prepare ? 1 : 0
|
35
37
|
@_klasses = nil
|
@@ -37,16 +39,16 @@ module RGeo
|
|
37
39
|
|
38
40
|
# Psych support
|
39
41
|
|
40
|
-
def encode_with(
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
def encode_with(coder) # :nodoc:
|
43
|
+
coder["factory"] = @factory
|
44
|
+
str = @factory.write_for_psych(self)
|
45
|
+
str = str.encode("US-ASCII") if str.respond_to?(:encode)
|
46
|
+
coder["wkt"] = str
|
45
47
|
end
|
46
48
|
|
47
|
-
def init_with(
|
48
|
-
@factory =
|
49
|
-
@fg_geom = @factory.
|
49
|
+
def init_with(coder) # :nodoc:
|
50
|
+
@factory = coder["factory"]
|
51
|
+
@fg_geom = @factory.read_for_psych(coder["wkt"])
|
50
52
|
@fg_geom.srid = @factory.srid
|
51
53
|
@_fg_prep = @factory._auto_prepare ? 1 : 0
|
52
54
|
@_klasses = nil
|
@@ -55,14 +57,14 @@ module RGeo
|
|
55
57
|
attr_reader :factory
|
56
58
|
attr_reader :fg_geom
|
57
59
|
|
58
|
-
attr_reader :_klasses
|
60
|
+
attr_reader :_klasses # :nodoc:
|
59
61
|
|
60
|
-
def initialize_copy(
|
61
|
-
@factory =
|
62
|
-
@fg_geom =
|
63
|
-
@fg_geom.srid =
|
62
|
+
def initialize_copy(orig)
|
63
|
+
@factory = orig.factory
|
64
|
+
@fg_geom = orig.fg_geom.clone
|
65
|
+
@fg_geom.srid = orig.fg_geom.srid
|
64
66
|
@_fg_prep = @factory._auto_prepare ? 1 : 0
|
65
|
-
@_klasses =
|
67
|
+
@_klasses = orig._klasses
|
66
68
|
end
|
67
69
|
|
68
70
|
def srid
|
@@ -78,37 +80,37 @@ module RGeo
|
|
78
80
|
end
|
79
81
|
|
80
82
|
def prepared?
|
81
|
-
!@_fg_prep.is_a?(
|
83
|
+
!@_fg_prep.is_a?(Integer)
|
82
84
|
end
|
83
85
|
|
84
86
|
def prepare!
|
85
|
-
if @_fg_prep.is_a?(
|
87
|
+
if @_fg_prep.is_a?(Integer)
|
86
88
|
@_fg_prep = ::Geos::PreparedGeometry.new(@fg_geom)
|
87
89
|
end
|
88
90
|
self
|
89
91
|
end
|
90
92
|
|
91
93
|
def envelope
|
92
|
-
@factory.
|
94
|
+
@factory.wrap_fg_geom(@fg_geom.envelope, nil)
|
93
95
|
end
|
94
96
|
|
95
97
|
def boundary
|
96
98
|
if self.class == FFIGeometryCollectionImpl
|
97
99
|
nil
|
98
100
|
else
|
99
|
-
@factory.
|
101
|
+
@factory.wrap_fg_geom(@fg_geom.boundary, nil)
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
103
105
|
def as_text
|
104
|
-
|
105
|
-
|
106
|
-
|
106
|
+
str = @factory.generate_wkt(self)
|
107
|
+
str.force_encoding("US-ASCII") if str.respond_to?(:force_encoding)
|
108
|
+
str
|
107
109
|
end
|
108
110
|
alias to_s as_text
|
109
111
|
|
110
112
|
def as_binary
|
111
|
-
@factory.
|
113
|
+
@factory.generate_wkb(self)
|
112
114
|
end
|
113
115
|
|
114
116
|
def is_empty?
|
@@ -119,120 +121,120 @@ module RGeo
|
|
119
121
|
@fg_geom.simple?
|
120
122
|
end
|
121
123
|
|
122
|
-
def equals?(
|
123
|
-
return false unless
|
124
|
-
|
125
|
-
if !
|
124
|
+
def equals?(rhs)
|
125
|
+
return false unless rhs.is_a?(RGeo::Feature::Instance)
|
126
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
127
|
+
if !fg
|
126
128
|
false
|
127
129
|
# GEOS has a bug where empty geometries are not spatially equal
|
128
130
|
# to each other. Work around this case first.
|
129
|
-
elsif
|
131
|
+
elsif fg.empty? && @fg_geom.empty?
|
130
132
|
true
|
131
133
|
else
|
132
|
-
@fg_geom.eql?(
|
134
|
+
@fg_geom.eql?(fg)
|
133
135
|
end
|
134
136
|
end
|
135
137
|
alias == equals?
|
136
138
|
|
137
|
-
def disjoint?(
|
138
|
-
|
139
|
-
if
|
140
|
-
|
141
|
-
|
139
|
+
def disjoint?(rhs)
|
140
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
141
|
+
if fg
|
142
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
143
|
+
prep ? prep.disjoint?(fg) : @fg_geom.disjoint?(fg)
|
142
144
|
else
|
143
145
|
false
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
147
|
-
def intersects?(
|
148
|
-
|
149
|
-
if
|
150
|
-
|
151
|
-
|
149
|
+
def intersects?(rhs)
|
150
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
151
|
+
if fg
|
152
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_1
|
153
|
+
prep ? prep.intersects?(fg) : @fg_geom.intersects?(fg)
|
152
154
|
else
|
153
155
|
false
|
154
156
|
end
|
155
157
|
end
|
156
158
|
|
157
|
-
def touches?(
|
158
|
-
|
159
|
-
if
|
160
|
-
|
161
|
-
|
159
|
+
def touches?(rhs)
|
160
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
161
|
+
if fg
|
162
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
163
|
+
prep ? prep.touches?(fg) : @fg_geom.touches?(fg)
|
162
164
|
else
|
163
165
|
false
|
164
166
|
end
|
165
167
|
end
|
166
168
|
|
167
|
-
def crosses?(
|
168
|
-
|
169
|
-
if
|
170
|
-
|
171
|
-
|
169
|
+
def crosses?(rhs)
|
170
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
171
|
+
if fg
|
172
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
173
|
+
prep ? prep.crosses?(fg) : @fg_geom.crosses?(fg)
|
172
174
|
else
|
173
175
|
false
|
174
176
|
end
|
175
177
|
end
|
176
178
|
|
177
|
-
def within?(
|
178
|
-
|
179
|
-
if
|
180
|
-
|
181
|
-
|
179
|
+
def within?(rhs)
|
180
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
181
|
+
if fg
|
182
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
183
|
+
prep ? prep.within?(fg) : @fg_geom.within?(fg)
|
182
184
|
else
|
183
185
|
false
|
184
186
|
end
|
185
187
|
end
|
186
188
|
|
187
|
-
def contains?(
|
188
|
-
|
189
|
-
if
|
190
|
-
|
191
|
-
|
189
|
+
def contains?(rhs)
|
190
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
191
|
+
if fg
|
192
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_1
|
193
|
+
prep ? prep.contains?(fg) : @fg_geom.contains?(fg)
|
192
194
|
else
|
193
195
|
false
|
194
196
|
end
|
195
197
|
end
|
196
198
|
|
197
|
-
def overlaps?(
|
198
|
-
|
199
|
-
if
|
200
|
-
|
201
|
-
|
199
|
+
def overlaps?(rhs)
|
200
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
201
|
+
if fg
|
202
|
+
prep = request_prepared if Utils.ffi_supports_prepared_level_2
|
203
|
+
prep ? prep.overlaps?(fg) : @fg_geom.overlaps?(fg)
|
202
204
|
else
|
203
205
|
false
|
204
206
|
end
|
205
207
|
end
|
206
208
|
|
207
|
-
def relate?(
|
208
|
-
|
209
|
-
|
209
|
+
def relate?(rhs, pattern)
|
210
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
211
|
+
fg ? @fg_geom.relate_pattern(fg, pattern) : nil
|
210
212
|
end
|
211
213
|
alias relate relate? # DEPRECATED
|
212
214
|
|
213
|
-
def distance(
|
214
|
-
|
215
|
-
|
215
|
+
def distance(rhs)
|
216
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
217
|
+
fg ? @fg_geom.distance(fg) : nil
|
216
218
|
end
|
217
219
|
|
218
|
-
def buffer(
|
219
|
-
@factory.
|
220
|
+
def buffer(distance)
|
221
|
+
@factory.wrap_fg_geom(@fg_geom.buffer(distance, @factory.buffer_resolution), nil)
|
220
222
|
end
|
221
223
|
|
222
224
|
def convex_hull
|
223
|
-
@factory.
|
225
|
+
@factory.wrap_fg_geom(@fg_geom.convex_hull, nil)
|
224
226
|
end
|
225
227
|
|
226
|
-
def intersection(
|
227
|
-
|
228
|
-
|
228
|
+
def intersection(rhs)
|
229
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
230
|
+
fg ? @factory.wrap_fg_geom(@fg_geom.intersection(fg), nil) : nil
|
229
231
|
end
|
230
232
|
|
231
233
|
alias * intersection
|
232
234
|
|
233
|
-
def union(
|
234
|
-
|
235
|
-
|
235
|
+
def union(rhs)
|
236
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
237
|
+
fg ? @factory.wrap_fg_geom(@fg_geom.union(fg), nil) : nil
|
236
238
|
end
|
237
239
|
|
238
240
|
alias + union
|
@@ -242,29 +244,31 @@ module RGeo
|
|
242
244
|
@factory.wrap_fg_geom(@fg_geom.unary_union)
|
243
245
|
end
|
244
246
|
|
245
|
-
def difference(
|
246
|
-
|
247
|
-
|
247
|
+
def difference(rhs)
|
248
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
249
|
+
fg ? @factory.wrap_fg_geom(@fg_geom.difference(fg), nil) : nil
|
248
250
|
end
|
249
251
|
|
250
252
|
alias - difference
|
251
253
|
|
252
|
-
def sym_difference(
|
253
|
-
|
254
|
-
|
254
|
+
def sym_difference(rhs)
|
255
|
+
fg = factory.convert_to_fg_geometry(rhs)
|
256
|
+
fg ? @factory.wrap_fg_geom(@fg_geom.sym_difference(fg), nil) : nil
|
255
257
|
end
|
256
258
|
|
257
|
-
def eql?(
|
258
|
-
rep_equals?(
|
259
|
+
def eql?(rhs)
|
260
|
+
rep_equals?(rhs)
|
259
261
|
end
|
260
262
|
|
261
|
-
def
|
262
|
-
|
263
|
+
def detach_fg_geom
|
264
|
+
fg = @fg_geom
|
263
265
|
@fg_geom = nil
|
264
|
-
|
266
|
+
fg
|
265
267
|
end
|
266
268
|
|
267
|
-
|
269
|
+
private
|
270
|
+
|
271
|
+
def request_prepared
|
268
272
|
case @_fg_prep
|
269
273
|
when 0
|
270
274
|
nil
|
@@ -300,9 +304,9 @@ module RGeo
|
|
300
304
|
Feature::Point
|
301
305
|
end
|
302
306
|
|
303
|
-
def rep_equals?(
|
304
|
-
|
305
|
-
Utils.ffi_coord_seqs_equal?(
|
307
|
+
def rep_equals?(rhs)
|
308
|
+
rhs.class == self.class && rhs.factory.eql?(@factory) &&
|
309
|
+
Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
|
306
310
|
end
|
307
311
|
|
308
312
|
def hash
|
@@ -330,13 +334,13 @@ module RGeo
|
|
330
334
|
@fg_geom.num_points
|
331
335
|
end
|
332
336
|
|
333
|
-
def point_n(
|
334
|
-
if
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
@factory.point(
|
337
|
+
def point_n(n)
|
338
|
+
if n >= 0 && n < @fg_geom.num_points
|
339
|
+
coord_seq = @fg_geom.coord_seq
|
340
|
+
x = coord_seq.get_x(n)
|
341
|
+
y = coord_seq.get_y(n)
|
342
|
+
extra = @factory._has_3d ? [coord_seq.get_z(n)] : []
|
343
|
+
@factory.point(x, y, *extra)
|
340
344
|
end
|
341
345
|
end
|
342
346
|
|
@@ -349,13 +353,13 @@ module RGeo
|
|
349
353
|
end
|
350
354
|
|
351
355
|
def points
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
@factory.point(
|
356
|
+
coord_seq = @fg_geom.coord_seq
|
357
|
+
has_3d = @factory._has_3d
|
358
|
+
Array.new(@fg_geom.num_points) do |n|
|
359
|
+
x = coord_seq.get_x(n)
|
360
|
+
y = coord_seq.get_y(n)
|
361
|
+
extra = has_3d ? [coord_seq.get_z(n)] : []
|
362
|
+
@factory.point(x, y, *extra)
|
359
363
|
end
|
360
364
|
end
|
361
365
|
|
@@ -367,9 +371,9 @@ module RGeo
|
|
367
371
|
@fg_geom.ring?
|
368
372
|
end
|
369
373
|
|
370
|
-
def rep_equals?(
|
371
|
-
|
372
|
-
Utils.ffi_coord_seqs_equal?(
|
374
|
+
def rep_equals?(rhs)
|
375
|
+
rhs.class == self.class && rhs.factory.eql?(@factory) &&
|
376
|
+
Utils.ffi_coord_seqs_equal?(rhs.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
|
373
377
|
end
|
374
378
|
|
375
379
|
def hash
|
@@ -403,41 +407,41 @@ module RGeo
|
|
403
407
|
end
|
404
408
|
|
405
409
|
def centroid
|
406
|
-
@factory.
|
410
|
+
@factory.wrap_fg_geom(@fg_geom.centroid, FFIPointImpl)
|
407
411
|
end
|
408
412
|
|
409
413
|
def point_on_surface
|
410
|
-
@factory.
|
414
|
+
@factory.wrap_fg_geom(@fg_geom.point_on_surface, FFIPointImpl)
|
411
415
|
end
|
412
416
|
|
413
417
|
def exterior_ring
|
414
|
-
@factory.
|
418
|
+
@factory.wrap_fg_geom(@fg_geom.exterior_ring, FFILinearRingImpl)
|
415
419
|
end
|
416
420
|
|
417
421
|
def num_interior_rings
|
418
422
|
@fg_geom.num_interior_rings
|
419
423
|
end
|
420
424
|
|
421
|
-
def interior_ring_n(
|
422
|
-
if
|
423
|
-
@factory.
|
425
|
+
def interior_ring_n(n)
|
426
|
+
if n >= 0 && n < @fg_geom.num_interior_rings
|
427
|
+
@factory.wrap_fg_geom(@fg_geom.interior_ring_n(n), FFILinearRingImpl)
|
424
428
|
end
|
425
429
|
end
|
426
430
|
|
427
431
|
def interior_rings
|
428
|
-
|
429
|
-
@factory.
|
432
|
+
Array.new(@fg_geom.num_interior_rings) do |n|
|
433
|
+
@factory.wrap_fg_geom(@fg_geom.interior_ring_n(n), FFILinearRingImpl)
|
430
434
|
end
|
431
435
|
end
|
432
436
|
|
433
|
-
def rep_equals?(
|
434
|
-
if
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
if
|
439
|
-
|
440
|
-
return false unless interior_ring_n(
|
437
|
+
def rep_equals?(rhs)
|
438
|
+
if rhs.class == self.class && rhs.factory.eql?(@factory) &&
|
439
|
+
rhs.exterior_ring.rep_equals?(exterior_ring)
|
440
|
+
sn = @fg_geom.num_interior_rings
|
441
|
+
rn = rhs.num_interior_rings
|
442
|
+
if sn == rn
|
443
|
+
sn.times do |i|
|
444
|
+
return false unless interior_ring_n(i).rep_equals?(rhs.interior_ring_n(i))
|
441
445
|
end
|
442
446
|
return true
|
443
447
|
end
|
@@ -447,10 +451,10 @@ module RGeo
|
|
447
451
|
|
448
452
|
def hash
|
449
453
|
@hash ||= begin
|
450
|
-
|
454
|
+
hash = Utils.ffi_coord_seq_hash(@fg_geom.exterior_ring.coord_seq,
|
451
455
|
[@factory, geometry_type].hash)
|
452
|
-
@fg_geom.interior_rings.inject(
|
453
|
-
Utils.ffi_coord_seq_hash(
|
456
|
+
@fg_geom.interior_rings.inject(hash) do |h, r|
|
457
|
+
Utils.ffi_coord_seq_hash(r.coord_seq, h)
|
454
458
|
end
|
455
459
|
end
|
456
460
|
end
|
@@ -465,12 +469,12 @@ module RGeo
|
|
465
469
|
Feature::GeometryCollection
|
466
470
|
end
|
467
471
|
|
468
|
-
def rep_equals?(
|
469
|
-
if
|
470
|
-
|
471
|
-
if
|
472
|
-
|
473
|
-
return false unless geometry_n(
|
472
|
+
def rep_equals?(rhs)
|
473
|
+
if rhs.class == self.class && rhs.factory.eql?(@factory)
|
474
|
+
size = @fg_geom.num_geometries
|
475
|
+
if size == rhs.num_geometries
|
476
|
+
size.times do |n|
|
477
|
+
return false unless geometry_n(n).rep_equals?(rhs.geometry_n(n))
|
474
478
|
end
|
475
479
|
return true
|
476
480
|
end
|
@@ -483,35 +487,35 @@ module RGeo
|
|
483
487
|
end
|
484
488
|
alias size num_geometries
|
485
489
|
|
486
|
-
def geometry_n(
|
487
|
-
if
|
488
|
-
@factory.
|
489
|
-
@_klasses ? @_klasses[
|
490
|
+
def geometry_n(n)
|
491
|
+
if n >= 0 && n < @fg_geom.num_geometries
|
492
|
+
@factory.wrap_fg_geom(@fg_geom.get_geometry_n(n),
|
493
|
+
@_klasses ? @_klasses[n] : nil)
|
490
494
|
end
|
491
495
|
end
|
492
496
|
|
493
|
-
def [](
|
494
|
-
|
495
|
-
if
|
496
|
-
@factory.
|
497
|
-
@_klasses ? @_klasses[
|
497
|
+
def [](n)
|
498
|
+
n += @fg_geom.num_geometries if n < 0
|
499
|
+
if n >= 0 && n < @fg_geom.num_geometries
|
500
|
+
@factory.wrap_fg_geom(@fg_geom.get_geometry_n(n),
|
501
|
+
@_klasses ? @_klasses[n] : nil)
|
498
502
|
end
|
499
503
|
end
|
500
504
|
|
501
505
|
def hash
|
502
506
|
@hash ||= begin
|
503
|
-
|
504
|
-
(0...num_geometries).inject(
|
505
|
-
(1_664_525 *
|
507
|
+
hash = [@factory, geometry_type].hash
|
508
|
+
(0...num_geometries).inject(hash) do |h, i|
|
509
|
+
(1_664_525 * h + geometry_n(i).hash).hash
|
506
510
|
end
|
507
511
|
end
|
508
512
|
end
|
509
513
|
|
510
514
|
def each
|
511
515
|
if block_given?
|
512
|
-
@fg_geom.num_geometries.times do |
|
513
|
-
yield @factory.
|
514
|
-
@_klasses ? @_klasses[
|
516
|
+
@fg_geom.num_geometries.times do |n|
|
517
|
+
yield @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n),
|
518
|
+
@_klasses ? @_klasses[n] : nil)
|
515
519
|
end
|
516
520
|
self
|
517
521
|
else
|
@@ -519,7 +523,7 @@ module RGeo
|
|
519
523
|
end
|
520
524
|
end
|
521
525
|
|
522
|
-
include
|
526
|
+
include Enumerable
|
523
527
|
end
|
524
528
|
|
525
529
|
module FFIMultiPointMethods # :nodoc:
|
@@ -542,9 +546,9 @@ module RGeo
|
|
542
546
|
end
|
543
547
|
|
544
548
|
def is_closed?
|
545
|
-
|
546
|
-
|
547
|
-
return false unless @fg_geom.get_geometry_n(
|
549
|
+
size = num_geometries
|
550
|
+
size.times do |n|
|
551
|
+
return false unless @fg_geom.get_geometry_n(n).closed?
|
548
552
|
end
|
549
553
|
true
|
550
554
|
end
|
@@ -564,11 +568,11 @@ module RGeo
|
|
564
568
|
end
|
565
569
|
|
566
570
|
def centroid
|
567
|
-
@factory.
|
571
|
+
@factory.wrap_fg_geom(@fg_geom.centroid, FFIPointImpl)
|
568
572
|
end
|
569
573
|
|
570
574
|
def point_on_surface
|
571
|
-
@factory.
|
575
|
+
@factory.wrap_fg_geom(@fg_geom.point_on_surface, FFIPointImpl)
|
572
576
|
end
|
573
577
|
|
574
578
|
def coordinates
|