rgeo 3.0.0.pre.rc.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/ext/geos_c_impl/factory.c +41 -5
- data/ext/geos_c_impl/factory.h +13 -2
- data/ext/geos_c_impl/geometry.c +151 -122
- data/ext/geos_c_impl/geometry_collection.c +17 -19
- data/ext/geos_c_impl/line_string.c +46 -36
- data/ext/geos_c_impl/point.c +0 -2
- data/ext/geos_c_impl/polygon.c +10 -11
- data/ext/geos_c_impl/polygon.h +1 -1
- data/ext/geos_c_impl/ruby_more.c +7 -0
- data/ext/geos_c_impl/ruby_more.h +8 -0
- data/lib/rgeo/cartesian/analysis.rb +5 -3
- data/lib/rgeo/cartesian/bounding_box.rb +74 -79
- data/lib/rgeo/cartesian/calculations.rb +20 -26
- data/lib/rgeo/cartesian/factory.rb +47 -49
- data/lib/rgeo/cartesian/planar_graph.rb +10 -16
- data/lib/rgeo/cartesian/sweepline_intersector.rb +1 -3
- data/lib/rgeo/cartesian/valid_op.rb +1 -3
- data/lib/rgeo/coord_sys/cs/entities.rb +87 -101
- data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +70 -29
- data/lib/rgeo/feature/curve.rb +0 -1
- data/lib/rgeo/feature/factory.rb +25 -27
- data/lib/rgeo/feature/factory_generator.rb +3 -4
- data/lib/rgeo/feature/geometry.rb +41 -30
- data/lib/rgeo/feature/geometry_collection.rb +3 -4
- data/lib/rgeo/feature/line_string.rb +1 -2
- data/lib/rgeo/feature/linear_ring.rb +0 -1
- data/lib/rgeo/feature/multi_curve.rb +0 -1
- data/lib/rgeo/feature/multi_surface.rb +0 -1
- data/lib/rgeo/feature/point.rb +0 -1
- data/lib/rgeo/feature/polygon.rb +1 -2
- data/lib/rgeo/feature/surface.rb +0 -1
- data/lib/rgeo/feature/types.rb +73 -83
- data/lib/rgeo/geographic/factory.rb +87 -80
- data/lib/rgeo/geographic/interface.rb +40 -23
- data/lib/rgeo/geographic/projected_feature_methods.rb +2 -6
- data/lib/rgeo/geographic/projected_window.rb +35 -21
- data/lib/rgeo/geographic/simple_mercator_projector.rb +25 -13
- data/lib/rgeo/geographic/spherical_feature_methods.rb +8 -3
- data/lib/rgeo/geographic/spherical_math.rb +17 -20
- data/lib/rgeo/geos/capi_factory.rb +50 -50
- data/lib/rgeo/geos/ffi_factory.rb +41 -42
- data/lib/rgeo/geos/ffi_feature_methods.rb +72 -97
- data/lib/rgeo/geos/interface.rb +16 -16
- data/lib/rgeo/geos/utils.rb +3 -3
- data/lib/rgeo/geos/zm_factory.rb +50 -42
- data/lib/rgeo/geos/zm_feature_methods.rb +15 -8
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +4 -4
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +18 -24
- data/lib/rgeo/impl_helper/basic_point_methods.rb +1 -3
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +15 -16
- data/lib/rgeo/impl_helper/utils.rb +3 -9
- data/lib/rgeo/impl_helper/valid_op.rb +12 -16
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +42 -47
- data/lib/rgeo/wkrep/wkb_parser.rb +17 -18
- data/lib/rgeo/wkrep/wkt_generator.rb +23 -16
- data/lib/rgeo/wkrep/wkt_parser.rb +23 -13
- metadata +5 -5
@@ -23,9 +23,11 @@ module RGeo
|
|
23
23
|
next_token
|
24
24
|
return value
|
25
25
|
end
|
26
|
+
|
26
27
|
unless @cur_token.is_a?(TypeString)
|
27
28
|
raise Error::ParseError, "Found token #{@cur_token} when we expected a value"
|
28
29
|
end
|
30
|
+
|
29
31
|
type = @cur_token
|
30
32
|
next_token
|
31
33
|
consume_tokentype(:begin)
|
@@ -47,9 +49,11 @@ module RGeo
|
|
47
49
|
obj = AxisInfo.create(args.shift(QuotedString), args.shift(TypeString))
|
48
50
|
when "TOWGS84"
|
49
51
|
bursa_wolf_params = args.find_all(Numeric)
|
52
|
+
|
50
53
|
unless bursa_wolf_params.size == 7
|
51
54
|
raise Error::ParseError, "Expected 7 Bursa Wolf parameters but found #{bursa_wolf_params.size}"
|
52
55
|
end
|
56
|
+
|
53
57
|
obj = WGS84ConversionInfo.create(*bursa_wolf_params)
|
54
58
|
when "UNIT"
|
55
59
|
klass = case containing_type
|
@@ -66,7 +70,13 @@ module RGeo
|
|
66
70
|
when "PRIMEM"
|
67
71
|
obj = PrimeMeridian.create(args.shift(QuotedString), nil, args.shift(Numeric), *args.create_optionals)
|
68
72
|
when "SPHEROID"
|
69
|
-
obj = Ellipsoid.create_flattened_sphere(
|
73
|
+
obj = Ellipsoid.create_flattened_sphere(
|
74
|
+
args.shift(QuotedString),
|
75
|
+
args.shift(Numeric),
|
76
|
+
args.shift(Numeric),
|
77
|
+
args.find_first(LinearUnit),
|
78
|
+
*args.create_optionals
|
79
|
+
)
|
70
80
|
when "PROJECTION"
|
71
81
|
name = args.shift(QuotedString)
|
72
82
|
obj = Projection.create(name, name, args.find_all(ProjectionParameter), *args.create_optionals)
|
@@ -87,15 +97,18 @@ module RGeo
|
|
87
97
|
optionals = args.create_optionals
|
88
98
|
obj = CoordinateSystem.create(defn, dim, *optionals)
|
89
99
|
when "COMPD_CS"
|
90
|
-
obj = CompoundCoordinateSystem.create(
|
100
|
+
obj = CompoundCoordinateSystem.create(
|
101
|
+
args.shift(QuotedString),
|
102
|
+
args.shift(CoordinateSystem),
|
103
|
+
args.shift(CoordinateSystem),
|
104
|
+
*args.create_optionals
|
105
|
+
)
|
91
106
|
when "LOCAL_CS"
|
92
107
|
name = args.shift(QuotedString)
|
93
108
|
local_datum = args.find_first(LocalDatum)
|
94
109
|
unit = args.find_first(Unit)
|
95
110
|
axes = args.find_all(AxisInfo)
|
96
|
-
unless axes.size > 0
|
97
|
-
raise Error::ParseError, "Expected at least one AXIS in a LOCAL_CS"
|
98
|
-
end
|
111
|
+
raise Error::ParseError, "Expected at least one AXIS in a LOCAL_CS" unless axes.size > 0
|
99
112
|
obj = LocalCoordinateSystem.create(name, local_datum, unit, axes, *args.create_optionals)
|
100
113
|
when "GEOCCS"
|
101
114
|
name = args.shift(QuotedString)
|
@@ -103,10 +116,21 @@ module RGeo
|
|
103
116
|
prime_meridian = args.find_first(PrimeMeridian)
|
104
117
|
linear_unit = args.find_first(LinearUnit)
|
105
118
|
axes = args.find_all(AxisInfo)
|
119
|
+
|
106
120
|
unless axes.size == 0 || axes.size == 3
|
107
121
|
raise Error::ParseError, "GEOCCS must contain either 0 or 3 AXIS parameters"
|
108
122
|
end
|
109
|
-
|
123
|
+
|
124
|
+
obj = GeocentricCoordinateSystem.create(
|
125
|
+
name,
|
126
|
+
horizontal_datum,
|
127
|
+
prime_meridian,
|
128
|
+
linear_unit,
|
129
|
+
axes[0],
|
130
|
+
axes[1],
|
131
|
+
axes[2],
|
132
|
+
*args.create_optionals
|
133
|
+
)
|
110
134
|
when "VERT_CS"
|
111
135
|
name = args.shift(QuotedString)
|
112
136
|
vertical_datum = args.find_first(VerticalDatum)
|
@@ -119,10 +143,20 @@ module RGeo
|
|
119
143
|
prime_meridian = args.find_first(PrimeMeridian)
|
120
144
|
angular_unit = args.find_first(AngularUnit)
|
121
145
|
axes = args.find_all(AxisInfo)
|
146
|
+
|
122
147
|
unless axes.size == 0 || axes.size == 2
|
123
148
|
raise Error::ParseError, "GEOGCS must contain either 0 or 2 AXIS parameters"
|
124
149
|
end
|
125
|
-
|
150
|
+
|
151
|
+
obj = GeographicCoordinateSystem.create(
|
152
|
+
name,
|
153
|
+
angular_unit,
|
154
|
+
horizontal_datum,
|
155
|
+
prime_meridian,
|
156
|
+
axes[0],
|
157
|
+
axes[1],
|
158
|
+
*args.create_optionals
|
159
|
+
)
|
126
160
|
when "PROJCS"
|
127
161
|
name = args.shift(QuotedString)
|
128
162
|
geographic_coordinate_system = args.find_first(GeographicCoordinateSystem)
|
@@ -131,10 +165,20 @@ module RGeo
|
|
131
165
|
projection.instance_variable_get(:@parameters).concat(parameters)
|
132
166
|
linear_unit = args.find_first(LinearUnit)
|
133
167
|
axes = args.find_all(AxisInfo)
|
168
|
+
|
134
169
|
unless axes.size == 0 || axes.size == 2
|
135
170
|
raise Error::ParseError, "PROJCS must contain either 0 or 2 AXIS parameters"
|
136
171
|
end
|
137
|
-
|
172
|
+
|
173
|
+
obj = ProjectedCoordinateSystem.create(
|
174
|
+
name,
|
175
|
+
geographic_coordinate_system,
|
176
|
+
projection,
|
177
|
+
linear_unit,
|
178
|
+
axes[0],
|
179
|
+
axes[1],
|
180
|
+
*args.create_optionals
|
181
|
+
)
|
138
182
|
else
|
139
183
|
raise Error::ParseError, "Unrecognized type: #{type}"
|
140
184
|
end
|
@@ -150,9 +194,9 @@ module RGeo
|
|
150
194
|
end
|
151
195
|
|
152
196
|
def expect_tokentype(type) # :nodoc:
|
153
|
-
|
154
|
-
|
155
|
-
|
197
|
+
return if type === @cur_token
|
198
|
+
|
199
|
+
raise Error::ParseError, "#{type.inspect} expected but #{@cur_token.inspect} found."
|
156
200
|
end
|
157
201
|
|
158
202
|
def next_token # :nodoc:
|
@@ -176,13 +220,14 @@ module RGeo
|
|
176
220
|
when "", nil
|
177
221
|
@cur_token = nil
|
178
222
|
else
|
179
|
-
@scanner.scan_until(/[^\s
|
223
|
+
@scanner.scan_until(/[^\s()\[\],"]+/)
|
180
224
|
token = @scanner.matched
|
181
|
-
|
182
|
-
|
183
|
-
else
|
225
|
+
|
226
|
+
unless token =~ /^[-+]?(\d+(\.\d*)?|\.\d+)(e[-+]?\d+)?$/
|
184
227
|
raise Error::ParseError, "Bad token: #{token.inspect}"
|
185
228
|
end
|
229
|
+
|
230
|
+
@cur_token = token.to_f
|
186
231
|
end
|
187
232
|
@cur_token
|
188
233
|
end
|
@@ -207,13 +252,12 @@ module RGeo
|
|
207
252
|
end
|
208
253
|
|
209
254
|
class ExtensionClause # :nodoc:
|
255
|
+
attr_reader :key, :value
|
256
|
+
|
210
257
|
def initialize(key, value) # :nodoc:
|
211
258
|
@key = key
|
212
259
|
@value = value
|
213
260
|
end
|
214
|
-
|
215
|
-
attr_reader :key # :nodoc:
|
216
|
-
attr_reader :value # :nodoc:
|
217
261
|
end
|
218
262
|
|
219
263
|
class ArgumentList # :nodoc:
|
@@ -226,12 +270,13 @@ module RGeo
|
|
226
270
|
end
|
227
271
|
|
228
272
|
def assert_empty # :nodoc:
|
229
|
-
if @values.
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
raise Error::ParseError, "#{@values.size} unexpected arguments: #{names.join(', ')}"
|
273
|
+
return if @values.empty?
|
274
|
+
|
275
|
+
names = @values.map do |val|
|
276
|
+
val.is_a?(Base) ? val.wkt_typename : val.inspect
|
234
277
|
end
|
278
|
+
|
279
|
+
raise Error::ParseError, "#{@values.size} unexpected arguments: #{names.join(', ')}"
|
235
280
|
end
|
236
281
|
|
237
282
|
def find_first(klass) # :nodoc:
|
@@ -266,12 +311,8 @@ module RGeo
|
|
266
311
|
|
267
312
|
def shift(klass = nil) # :nodoc:
|
268
313
|
val = @values.shift
|
269
|
-
unless val
|
270
|
-
|
271
|
-
end
|
272
|
-
if klass && !val.is_a?(klass)
|
273
|
-
raise Error::ParseError, "Expected #{klass} but got #{val.class}"
|
274
|
-
end
|
314
|
+
raise Error::ParseError, "No arguments left... expected #{klass}" unless val
|
315
|
+
raise Error::ParseError, "Expected #{klass} but got #{val.class}" if klass && !val.is_a?(klass)
|
275
316
|
val
|
276
317
|
end
|
277
318
|
end
|
data/lib/rgeo/feature/curve.rb
CHANGED
data/lib/rgeo/feature/factory.rb
CHANGED
@@ -30,12 +30,10 @@ module RGeo
|
|
30
30
|
# is provided. All factory implementation classes MUST include
|
31
31
|
# <tt>Factory::Instance</tt>, and you may use it in <tt>is_a?</tt>,
|
32
32
|
# <tt>===</tt>, and case-when constructs.
|
33
|
-
|
34
33
|
module Factory
|
35
34
|
# All factory implementations MUST include this submodule.
|
36
35
|
# This serves as a marker that may be used to test an object for
|
37
36
|
# factory-ness.
|
38
|
-
|
39
37
|
module Instance
|
40
38
|
end
|
41
39
|
|
@@ -74,22 +72,22 @@ module RGeo
|
|
74
72
|
# information is present about whether the coordinate system is
|
75
73
|
# meant to be so interpreted.
|
76
74
|
|
77
|
-
def property(
|
78
|
-
|
75
|
+
def property(_name)
|
76
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
79
77
|
end
|
80
78
|
|
81
79
|
# Parse the given string in well-known-text format and return the
|
82
80
|
# resulting feature. Returns nil if the string couldn't be parsed.
|
83
81
|
|
84
|
-
def parse_wkt(
|
85
|
-
|
82
|
+
def parse_wkt(_str)
|
83
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
86
84
|
end
|
87
85
|
|
88
86
|
# Parse the given string in well-known-binary format and return the
|
89
87
|
# resulting feature. Returns nil if the string couldn't be parsed.
|
90
88
|
|
91
|
-
def parse_wkb(
|
92
|
-
|
89
|
+
def parse_wkb(_str)
|
90
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
93
91
|
end
|
94
92
|
|
95
93
|
# Create a feature of type Point.
|
@@ -99,8 +97,8 @@ module RGeo
|
|
99
97
|
# supported. If both Z and M coordinates are supported, Z should
|
100
98
|
# be passed first.
|
101
99
|
|
102
|
-
def point(
|
103
|
-
|
100
|
+
def point(_x, _y, *_extra)
|
101
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
104
102
|
end
|
105
103
|
|
106
104
|
# Create a feature of type LineString.
|
@@ -112,8 +110,8 @@ module RGeo
|
|
112
110
|
# result of building geometries from objects of the wrong factory
|
113
111
|
# is undefined.
|
114
112
|
|
115
|
-
def line_string(
|
116
|
-
|
113
|
+
def line_string(_points)
|
114
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
117
115
|
end
|
118
116
|
|
119
117
|
# Create a feature of type Line.
|
@@ -125,8 +123,8 @@ module RGeo
|
|
125
123
|
# result of building geometries from objects of the wrong factory
|
126
124
|
# is undefined.
|
127
125
|
|
128
|
-
def line(
|
129
|
-
|
126
|
+
def line(_start, _stop)
|
127
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
130
128
|
end
|
131
129
|
|
132
130
|
# Create a feature of type LinearRing.
|
@@ -141,8 +139,8 @@ module RGeo
|
|
141
139
|
# result of building geometries from objects of the wrong factory
|
142
140
|
# is undefined.
|
143
141
|
|
144
|
-
def linear_ring(
|
145
|
-
|
142
|
+
def linear_ring(_points)
|
143
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
146
144
|
end
|
147
145
|
|
148
146
|
# Create a feature of type Polygon.
|
@@ -157,8 +155,8 @@ module RGeo
|
|
157
155
|
# result of building geometries from objects of the wrong factory
|
158
156
|
# is undefined.
|
159
157
|
|
160
|
-
def polygon(
|
161
|
-
|
158
|
+
def polygon(_outer_ring, _inner_rings = nil)
|
159
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
162
160
|
end
|
163
161
|
|
164
162
|
# Create a feature of type GeometryCollection.
|
@@ -169,8 +167,8 @@ module RGeo
|
|
169
167
|
# result of building geometries from objects of the wrong factory
|
170
168
|
# is undefined.
|
171
169
|
|
172
|
-
def collection(
|
173
|
-
|
170
|
+
def collection(_elems)
|
171
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
174
172
|
end
|
175
173
|
|
176
174
|
# Create a feature of type MultiPoint.
|
@@ -184,8 +182,8 @@ module RGeo
|
|
184
182
|
# result of building geometries from objects of the wrong factory
|
185
183
|
# is undefined.
|
186
184
|
|
187
|
-
def multi_point(
|
188
|
-
|
185
|
+
def multi_point(_elems)
|
186
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
189
187
|
end
|
190
188
|
|
191
189
|
# Create a feature of type MultiLineString.
|
@@ -199,8 +197,8 @@ module RGeo
|
|
199
197
|
# result of building geometries from objects of the wrong factory
|
200
198
|
# is undefined.
|
201
199
|
|
202
|
-
def multi_line_string(
|
203
|
-
|
200
|
+
def multi_line_string(_elems)
|
201
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
204
202
|
end
|
205
203
|
|
206
204
|
# Create a feature of type MultiPolygon.
|
@@ -216,8 +214,8 @@ module RGeo
|
|
216
214
|
# result of building geometries from objects of the wrong factory
|
217
215
|
# is undefined.
|
218
216
|
|
219
|
-
def multi_polygon(
|
220
|
-
|
217
|
+
def multi_polygon(_elems)
|
218
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
221
219
|
end
|
222
220
|
|
223
221
|
# Returns the coordinate system specification for the features
|
@@ -264,7 +262,7 @@ module RGeo
|
|
264
262
|
# algorithm to cast the object. Therefore, by default, you should
|
265
263
|
# return false.
|
266
264
|
|
267
|
-
def override_cast(
|
265
|
+
def override_cast(_original, _type, _flags)
|
268
266
|
false
|
269
267
|
end
|
270
268
|
end
|
@@ -31,7 +31,6 @@ module RGeo
|
|
31
31
|
# necessarily include this module itself. Therefore, you should not
|
32
32
|
# depend on the kind_of? method to determine if an object is a
|
33
33
|
# factory generator.
|
34
|
-
|
35
34
|
module FactoryGenerator
|
36
35
|
# Generate a factory given a configuration as a hash.
|
37
36
|
#
|
@@ -67,7 +66,7 @@ module RGeo
|
|
67
66
|
# [<tt>:has_m_coordinate</tt>]
|
68
67
|
# Support M coordinates. Default is usually false.
|
69
68
|
|
70
|
-
def call(
|
69
|
+
def call(_config = {})
|
71
70
|
nil
|
72
71
|
end
|
73
72
|
|
@@ -75,7 +74,7 @@ module RGeo
|
|
75
74
|
# factory.
|
76
75
|
|
77
76
|
def self.single(factory)
|
78
|
-
proc { |
|
77
|
+
proc { |_c| factory }
|
79
78
|
end
|
80
79
|
|
81
80
|
# Return a new FactoryGenerator that calls the given delegate, but
|
@@ -84,7 +83,7 @@ module RGeo
|
|
84
83
|
# force certain values to override the given configuration.
|
85
84
|
|
86
85
|
def self.decorate(delegate, default_config = {}, force_config = {})
|
87
|
-
proc { |c|
|
86
|
+
proc { |c| delegate.call(default_config.merge(c).merge(force_config)) }
|
88
87
|
end
|
89
88
|
end
|
90
89
|
end
|
@@ -78,7 +78,6 @@ module RGeo
|
|
78
78
|
# Therefore, if an implementation cannot provide a suitable test for
|
79
79
|
# their equivalence types, they must degrade to use a stronger form
|
80
80
|
# of equivalence.
|
81
|
-
|
82
81
|
module Geometry
|
83
82
|
extend Type
|
84
83
|
|
@@ -294,7 +293,7 @@ module RGeo
|
|
294
293
|
# this geometry, strictly speaking, the result of comparing objects
|
295
294
|
# from different factories is undefined.
|
296
295
|
|
297
|
-
def equals?(
|
296
|
+
def equals?(_another_geometry)
|
298
297
|
raise Error::UnsupportedOperation, "Method #{self.class}#equals? not defined."
|
299
298
|
end
|
300
299
|
|
@@ -313,7 +312,7 @@ module RGeo
|
|
313
312
|
# this geometry, strictly speaking, the result of comparing objects
|
314
313
|
# from different factories is undefined.
|
315
314
|
|
316
|
-
def disjoint?(
|
315
|
+
def disjoint?(_another_geometry)
|
317
316
|
raise Error::UnsupportedOperation, "Method #{self.class}#disjoint? not defined."
|
318
317
|
end
|
319
318
|
|
@@ -332,7 +331,7 @@ module RGeo
|
|
332
331
|
# this geometry, strictly speaking, the result of comparing objects
|
333
332
|
# from different factories is undefined.
|
334
333
|
|
335
|
-
def intersects?(
|
334
|
+
def intersects?(_another_geometry)
|
336
335
|
raise Error::UnsupportedOperation, "Method #{self.class}#intersects? not defined."
|
337
336
|
end
|
338
337
|
|
@@ -351,7 +350,7 @@ module RGeo
|
|
351
350
|
# this geometry, strictly speaking, the result of comparing objects
|
352
351
|
# from different factories is undefined.
|
353
352
|
|
354
|
-
def touches?(
|
353
|
+
def touches?(_another_geometry)
|
355
354
|
raise Error::UnsupportedOperation, "Method #{self.class}#touches? not defined."
|
356
355
|
end
|
357
356
|
|
@@ -370,7 +369,7 @@ module RGeo
|
|
370
369
|
# this geometry, strictly speaking, the result of comparing objects
|
371
370
|
# from different factories is undefined.
|
372
371
|
|
373
|
-
def crosses?(
|
372
|
+
def crosses?(_another_geometry)
|
374
373
|
raise Error::UnsupportedOperation, "Method #{self.class}#crosses? not defined."
|
375
374
|
end
|
376
375
|
|
@@ -389,7 +388,7 @@ module RGeo
|
|
389
388
|
# this geometry, strictly speaking, the result of comparing objects
|
390
389
|
# from different factories is undefined.
|
391
390
|
|
392
|
-
def within?(
|
391
|
+
def within?(_another_geometry)
|
393
392
|
raise Error::UnsupportedOperation, "Method #{self.class}#within? not defined."
|
394
393
|
end
|
395
394
|
|
@@ -408,7 +407,7 @@ module RGeo
|
|
408
407
|
# this geometry, strictly speaking, the result of comparing objects
|
409
408
|
# from different factories is undefined.
|
410
409
|
|
411
|
-
def contains?(
|
410
|
+
def contains?(_another_geometry)
|
412
411
|
raise Error::UnsupportedOperation, "Method #{self.class}#contains? not defined."
|
413
412
|
end
|
414
413
|
|
@@ -427,7 +426,7 @@ module RGeo
|
|
427
426
|
# this geometry, strictly speaking, the result of comparing objects
|
428
427
|
# from different factories is undefined.
|
429
428
|
|
430
|
-
def overlaps?(
|
429
|
+
def overlaps?(_another_geometry)
|
431
430
|
raise Error::UnsupportedOperation, "Method #{self.class}#overlaps? not defined."
|
432
431
|
end
|
433
432
|
|
@@ -453,7 +452,7 @@ module RGeo
|
|
453
452
|
# this geometry, strictly speaking, the result of comparing objects
|
454
453
|
# from different factories is undefined.
|
455
454
|
|
456
|
-
def relate?(
|
455
|
+
def relate?(_another_geometry, _intersection_pattern_matrix_)
|
457
456
|
raise Error::UnsupportedOperation, "Method #{self.class}#relate not defined."
|
458
457
|
end
|
459
458
|
|
@@ -499,7 +498,7 @@ module RGeo
|
|
499
498
|
# this geometry, strictly speaking, the result of measuring the
|
500
499
|
# distance between objects from different factories is undefined.
|
501
500
|
|
502
|
-
def distance(
|
501
|
+
def distance(_another_geometry)
|
503
502
|
raise Error::UnsupportedOperation, "Method #{self.class}#distance not defined."
|
504
503
|
end
|
505
504
|
|
@@ -545,7 +544,7 @@ module RGeo
|
|
545
544
|
# this geometry, strictly speaking, the result of performing
|
546
545
|
# operations on objects from different factories is undefined.
|
547
546
|
|
548
|
-
def intersection(
|
547
|
+
def intersection(_another_geometry)
|
549
548
|
raise Error::UnsupportedOperation, "Method #{self.class}#intersection not defined."
|
550
549
|
end
|
551
550
|
|
@@ -563,7 +562,7 @@ module RGeo
|
|
563
562
|
# this geometry, strictly speaking, the result of performing
|
564
563
|
# operations on objects from different factories is undefined.
|
565
564
|
|
566
|
-
def union(
|
565
|
+
def union(_another_geometry)
|
567
566
|
raise Error::UnsupportedOperation, "Method #{self.class}#union not defined."
|
568
567
|
end
|
569
568
|
|
@@ -581,7 +580,7 @@ module RGeo
|
|
581
580
|
# this geometry, strictly speaking, the result of performing
|
582
581
|
# operations on objects from different factories is undefined.
|
583
582
|
|
584
|
-
def difference(
|
583
|
+
def difference(_another_geometry)
|
585
584
|
raise Error::UnsupportedOperation, "Method #{self.class}#difference not defined."
|
586
585
|
end
|
587
586
|
|
@@ -599,7 +598,7 @@ module RGeo
|
|
599
598
|
# this geometry, strictly speaking, the result of performing
|
600
599
|
# operations on objects from different factories is undefined.
|
601
600
|
|
602
|
-
def sym_difference(
|
601
|
+
def sym_difference(_another_geometry)
|
603
602
|
raise Error::UnsupportedOperation, "Method #{self.class}#sym_difference not defined."
|
604
603
|
end
|
605
604
|
|
@@ -611,7 +610,7 @@ module RGeo
|
|
611
610
|
# this geometry, strictly speaking, the result of comparing objects
|
612
611
|
# from different factories is undefined.
|
613
612
|
|
614
|
-
def rep_equals?(
|
613
|
+
def rep_equals?(_another_geometry)
|
615
614
|
raise Error::UnsupportedOperation, "Method #{self.class}#rep_equals? not defined."
|
616
615
|
end
|
617
616
|
|
@@ -647,12 +646,12 @@ module RGeo
|
|
647
646
|
# representational equivalence test, this method must fall back on
|
648
647
|
# objective equivalence.
|
649
648
|
|
650
|
-
def eql?(
|
651
|
-
if
|
649
|
+
def eql?(other)
|
650
|
+
if other.is_a?(RGeo::Feature::Instance)
|
652
651
|
begin
|
653
|
-
rep_equals?(
|
652
|
+
rep_equals?(other)
|
654
653
|
rescue Error::UnsupportedOperation
|
655
|
-
equal?(
|
654
|
+
equal?(other)
|
656
655
|
end
|
657
656
|
else
|
658
657
|
false
|
@@ -673,12 +672,12 @@ module RGeo
|
|
673
672
|
# test, the == operator must fall back on representational or
|
674
673
|
# objective equivalence.
|
675
674
|
|
676
|
-
def ==(
|
677
|
-
if
|
675
|
+
def ==(other)
|
676
|
+
if other.is_a?(RGeo::Feature::Instance)
|
678
677
|
begin
|
679
|
-
equals?(
|
678
|
+
equals?(other)
|
680
679
|
rescue Error::UnsupportedOperation
|
681
|
-
eql?(
|
680
|
+
eql?(other)
|
682
681
|
end
|
683
682
|
else
|
684
683
|
false
|
@@ -690,8 +689,8 @@ module RGeo
|
|
690
689
|
# types is not specified; an implementation may choose to provide
|
691
690
|
# additional capabilities as appropriate.
|
692
691
|
|
693
|
-
def -(
|
694
|
-
difference(
|
692
|
+
def -(other)
|
693
|
+
difference(other)
|
695
694
|
end
|
696
695
|
|
697
696
|
# If the given rhs is a geometry object, this operator must behave
|
@@ -699,8 +698,8 @@ module RGeo
|
|
699
698
|
# is not specified; an implementation may choose to provide
|
700
699
|
# additional capabilities as appropriate.
|
701
700
|
|
702
|
-
def +(
|
703
|
-
union(
|
701
|
+
def +(other)
|
702
|
+
union(other)
|
704
703
|
end
|
705
704
|
|
706
705
|
# If the given rhs is a geometry object, this operator must behave
|
@@ -708,8 +707,20 @@ module RGeo
|
|
708
707
|
# types is not specified; an implementation may choose to provide
|
709
708
|
# additional capabilities as appropriate.
|
710
709
|
|
711
|
-
def *(
|
712
|
-
intersection(
|
710
|
+
def *(other)
|
711
|
+
intersection(other)
|
712
|
+
end
|
713
|
+
|
714
|
+
# Convenience method to transform/project a geometry
|
715
|
+
# to a different coordinate system from the geometry itself
|
716
|
+
# instead of the cast method.
|
717
|
+
#
|
718
|
+
# @note: Not an OGC SFS method
|
719
|
+
#
|
720
|
+
# @param [RGeo::Feature::Factory] other_factory
|
721
|
+
# @return [RGeo::Feature::Geometry]
|
722
|
+
def transform(other_factory)
|
723
|
+
Feature.cast(self, factory: other_factory, project: true)
|
713
724
|
end
|
714
725
|
end
|
715
726
|
end
|
@@ -28,7 +28,6 @@ module RGeo
|
|
28
28
|
# include this module itself. Therefore, you should not depend on the
|
29
29
|
# kind_of? method to check type. Instead, use the provided check_type
|
30
30
|
# class method (or === operator) defined in the Type module.
|
31
|
-
|
32
31
|
module GeometryCollection
|
33
32
|
include Geometry
|
34
33
|
extend Type
|
@@ -58,7 +57,7 @@ module RGeo
|
|
58
57
|
# Also note that this method is different from GeometryCollection#[]
|
59
58
|
# in that it does not support negative indexes.
|
60
59
|
|
61
|
-
def geometry_n(
|
60
|
+
def geometry_n(_idx)
|
62
61
|
raise Error::UnsupportedOperation, "Method #{self.class}#geometry_n not defined."
|
63
62
|
end
|
64
63
|
|
@@ -78,7 +77,7 @@ module RGeo
|
|
78
77
|
# the same way Ruby's array indexing works. Hence, geometry_n(-1)
|
79
78
|
# returns nil, where [-1] returns the last element of the collection.
|
80
79
|
|
81
|
-
def [](
|
80
|
+
def [](_idx)
|
82
81
|
raise Error::UnsupportedOperation, "Method #{self.class}#[] not defined."
|
83
82
|
end
|
84
83
|
|
@@ -95,7 +94,7 @@ module RGeo
|
|
95
94
|
# Note that all GeometryCollection implementations must also
|
96
95
|
# include the Enumerable mixin.
|
97
96
|
|
98
|
-
def each(&
|
97
|
+
def each(&_block)
|
99
98
|
raise Error::UnsupportedOperation, "Method #{self.class}#each not defined."
|
100
99
|
end
|
101
100
|
|
@@ -20,7 +20,6 @@ module RGeo
|
|
20
20
|
# include this module itself. Therefore, you should not depend on the
|
21
21
|
# kind_of? method to check type. Instead, use the provided check_type
|
22
22
|
# class method (or === operator) defined in the Type module.
|
23
|
-
|
24
23
|
module LineString
|
25
24
|
include Curve
|
26
25
|
extend Type
|
@@ -47,7 +46,7 @@ module RGeo
|
|
47
46
|
# if the given N is out of range. N is zero-based.
|
48
47
|
# Does not support negative indexes.
|
49
48
|
|
50
|
-
def point_n(
|
49
|
+
def point_n(_idx)
|
51
50
|
raise Error::UnsupportedOperation, "Method #{self.class}#point_n not defined."
|
52
51
|
end
|
53
52
|
|
@@ -19,7 +19,6 @@ module RGeo
|
|
19
19
|
# include this module itself. Therefore, you should not depend on the
|
20
20
|
# kind_of? method to check type. Instead, use the provided check_type
|
21
21
|
# class method (or === operator) defined in the Type module.
|
22
|
-
|
23
22
|
module LinearRing
|
24
23
|
include LineString
|
25
24
|
extend Type
|
@@ -37,7 +37,6 @@ module RGeo
|
|
37
37
|
# include this module itself. Therefore, you should not depend on the
|
38
38
|
# kind_of? method to check type. Instead, use the provided check_type
|
39
39
|
# class method (or === operator) defined in the Type module.
|
40
|
-
|
41
40
|
module MultiCurve
|
42
41
|
include GeometryCollection
|
43
42
|
extend Type
|