rgeo 2.3.1 → 3.0.1
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/.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
@@ -28,7 +28,6 @@ module RGeo
|
|
28
28
|
# * FittedCoordinateSystem is not implemented.
|
29
29
|
# * The defaultEnvelope attribute of CS_CoordinateSystem is not
|
30
30
|
# implemented.
|
31
|
-
|
32
31
|
module CS
|
33
32
|
# A class implementing the CS_CoordinateSystemFactory interface.
|
34
33
|
# It provides methods for building up complex objects from simpler
|
@@ -37,7 +36,6 @@ module RGeo
|
|
37
36
|
# Note that the methods of CS_CoordinateSystemFactory do not provide
|
38
37
|
# facilities for setting the authority. If you need to set authority
|
39
38
|
# values, use the create methods for the object classes themselves.
|
40
|
-
|
41
39
|
class CoordinateSystemFactory
|
42
40
|
# Create a CompoundCoordinateSystem from a name, and two
|
43
41
|
# constituent coordinate systems.
|
@@ -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
|
-
raise Error::ParseError
|
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,26 +49,34 @@ 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
|
-
raise Error::ParseError
|
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
|
-
case containing_type
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
klass = case containing_type
|
60
|
+
when "GEOCCS", "VERT_CS", "PROJCS", "SPHEROID"
|
61
|
+
LinearUnit
|
62
|
+
when "GEOGCS"
|
63
|
+
AngularUnit
|
64
|
+
else
|
65
|
+
Unit
|
66
|
+
end
|
63
67
|
obj = klass.create(args.shift(QuotedString), args.shift(Numeric), *args.create_optionals)
|
64
68
|
when "PARAMETER"
|
65
69
|
obj = ProjectionParameter.create(args.shift(QuotedString), args.shift(Numeric))
|
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)
|
@@ -79,16 +89,26 @@ module RGeo
|
|
79
89
|
obj = VerticalDatum.create(args.shift(QuotedString), args.shift(Numeric), *args.create_optionals)
|
80
90
|
when "LOCAL_DATUM"
|
81
91
|
obj = LocalDatum.create(args.shift(QuotedString), args.shift(Numeric), *args.create_optionals)
|
92
|
+
when "CS"
|
93
|
+
# Not actually valid WKT, but necessary to load and dump factories
|
94
|
+
# with placeholder coord_sys objects
|
95
|
+
defn = args.shift(QuotedString)
|
96
|
+
dim = args.shift(Float).to_i
|
97
|
+
optionals = args.create_optionals
|
98
|
+
obj = CoordinateSystem.create(defn, dim, *optionals)
|
82
99
|
when "COMPD_CS"
|
83
|
-
obj = CompoundCoordinateSystem.create(
|
100
|
+
obj = CompoundCoordinateSystem.create(
|
101
|
+
args.shift(QuotedString),
|
102
|
+
args.shift(CoordinateSystem),
|
103
|
+
args.shift(CoordinateSystem),
|
104
|
+
*args.create_optionals
|
105
|
+
)
|
84
106
|
when "LOCAL_CS"
|
85
107
|
name = args.shift(QuotedString)
|
86
108
|
local_datum = args.find_first(LocalDatum)
|
87
109
|
unit = args.find_first(Unit)
|
88
110
|
axes = args.find_all(AxisInfo)
|
89
|
-
unless axes.size > 0
|
90
|
-
raise Error::ParseError("Expected at least one AXIS in a LOCAL_CS")
|
91
|
-
end
|
111
|
+
raise Error::ParseError, "Expected at least one AXIS in a LOCAL_CS" unless axes.size > 0
|
92
112
|
obj = LocalCoordinateSystem.create(name, local_datum, unit, axes, *args.create_optionals)
|
93
113
|
when "GEOCCS"
|
94
114
|
name = args.shift(QuotedString)
|
@@ -96,10 +116,21 @@ module RGeo
|
|
96
116
|
prime_meridian = args.find_first(PrimeMeridian)
|
97
117
|
linear_unit = args.find_first(LinearUnit)
|
98
118
|
axes = args.find_all(AxisInfo)
|
119
|
+
|
99
120
|
unless axes.size == 0 || axes.size == 3
|
100
|
-
raise Error::ParseError
|
121
|
+
raise Error::ParseError, "GEOCCS must contain either 0 or 3 AXIS parameters"
|
101
122
|
end
|
102
|
-
|
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
|
+
)
|
103
134
|
when "VERT_CS"
|
104
135
|
name = args.shift(QuotedString)
|
105
136
|
vertical_datum = args.find_first(VerticalDatum)
|
@@ -112,10 +143,20 @@ module RGeo
|
|
112
143
|
prime_meridian = args.find_first(PrimeMeridian)
|
113
144
|
angular_unit = args.find_first(AngularUnit)
|
114
145
|
axes = args.find_all(AxisInfo)
|
146
|
+
|
115
147
|
unless axes.size == 0 || axes.size == 2
|
116
|
-
raise Error::ParseError
|
148
|
+
raise Error::ParseError, "GEOGCS must contain either 0 or 2 AXIS parameters"
|
117
149
|
end
|
118
|
-
|
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
|
+
)
|
119
160
|
when "PROJCS"
|
120
161
|
name = args.shift(QuotedString)
|
121
162
|
geographic_coordinate_system = args.find_first(GeographicCoordinateSystem)
|
@@ -124,10 +165,20 @@ module RGeo
|
|
124
165
|
projection.instance_variable_get(:@parameters).concat(parameters)
|
125
166
|
linear_unit = args.find_first(LinearUnit)
|
126
167
|
axes = args.find_all(AxisInfo)
|
168
|
+
|
127
169
|
unless axes.size == 0 || axes.size == 2
|
128
|
-
raise Error::ParseError
|
170
|
+
raise Error::ParseError, "PROJCS must contain either 0 or 2 AXIS parameters"
|
129
171
|
end
|
130
|
-
|
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
|
+
)
|
131
182
|
else
|
132
183
|
raise Error::ParseError, "Unrecognized type: #{type}"
|
133
184
|
end
|
@@ -143,9 +194,9 @@ module RGeo
|
|
143
194
|
end
|
144
195
|
|
145
196
|
def expect_tokentype(type) # :nodoc:
|
146
|
-
|
147
|
-
|
148
|
-
|
197
|
+
return if type === @cur_token
|
198
|
+
|
199
|
+
raise Error::ParseError, "#{type.inspect} expected but #{@cur_token.inspect} found."
|
149
200
|
end
|
150
201
|
|
151
202
|
def next_token # :nodoc:
|
@@ -169,13 +220,14 @@ module RGeo
|
|
169
220
|
when "", nil
|
170
221
|
@cur_token = nil
|
171
222
|
else
|
172
|
-
@scanner.scan_until(/[^\s
|
223
|
+
@scanner.scan_until(/[^\s()\[\],"]+/)
|
173
224
|
token = @scanner.matched
|
174
|
-
|
175
|
-
|
176
|
-
else
|
225
|
+
|
226
|
+
unless token =~ /^[-+]?(\d+(\.\d*)?|\.\d+)(e[-+]?\d+)?$/
|
177
227
|
raise Error::ParseError, "Bad token: #{token.inspect}"
|
178
228
|
end
|
229
|
+
|
230
|
+
@cur_token = token.to_f
|
179
231
|
end
|
180
232
|
@cur_token
|
181
233
|
end
|
@@ -200,13 +252,12 @@ module RGeo
|
|
200
252
|
end
|
201
253
|
|
202
254
|
class ExtensionClause # :nodoc:
|
255
|
+
attr_reader :key, :value
|
256
|
+
|
203
257
|
def initialize(key, value) # :nodoc:
|
204
258
|
@key = key
|
205
259
|
@value = value
|
206
260
|
end
|
207
|
-
|
208
|
-
attr_reader :key # :nodoc:
|
209
|
-
attr_reader :value # :nodoc:
|
210
261
|
end
|
211
262
|
|
212
263
|
class ArgumentList # :nodoc:
|
@@ -219,12 +270,13 @@ module RGeo
|
|
219
270
|
end
|
220
271
|
|
221
272
|
def assert_empty # :nodoc:
|
222
|
-
if @values.
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
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
|
227
277
|
end
|
278
|
+
|
279
|
+
raise Error::ParseError, "#{@values.size} unexpected arguments: #{names.join(', ')}"
|
228
280
|
end
|
229
281
|
|
230
282
|
def find_first(klass) # :nodoc:
|
@@ -259,12 +311,8 @@ module RGeo
|
|
259
311
|
|
260
312
|
def shift(klass = nil) # :nodoc:
|
261
313
|
val = @values.shift
|
262
|
-
unless val
|
263
|
-
|
264
|
-
end
|
265
|
-
if klass && !val.is_a?(klass)
|
266
|
-
raise Error::ParseError, "Expected #{klass} but got #{val.class}"
|
267
|
-
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)
|
268
316
|
val
|
269
317
|
end
|
270
318
|
end
|
data/lib/rgeo/coord_sys.rb
CHANGED
@@ -9,9 +9,6 @@
|
|
9
9
|
require_relative "coord_sys/cs/factories"
|
10
10
|
require_relative "coord_sys/cs/entities"
|
11
11
|
require_relative "coord_sys/cs/wkt_parser"
|
12
|
-
require_relative "coord_sys/srs_database/entry"
|
13
|
-
require_relative "coord_sys/srs_database/url_reader"
|
14
|
-
require_relative "coord_sys/srs_database/sr_org"
|
15
12
|
|
16
13
|
module RGeo
|
17
14
|
# This module provides data structures and tools related to coordinate
|
@@ -26,23 +23,7 @@ module RGeo
|
|
26
23
|
# This includes classes for representing ellipsoids, datums, coordinate
|
27
24
|
# systems, and other related concepts, as well as a parser for the WKT
|
28
25
|
# format for specifying coordinate systems.
|
29
|
-
#
|
30
|
-
# The RGeo::CoordSys::SRSDatabase module contains tools for accessing
|
31
|
-
# spatial reference databases, from which you can look up coordinate
|
32
|
-
# system specifications. You can access the <tt>spatial_ref_sys</tt>
|
33
|
-
# table provided with OGC-compliant spatial databases such as PostGIS,
|
34
|
-
# read the databases provided with the proj4 library, or access URLs
|
35
|
-
# such as those provided by spatialreference.org.
|
36
|
-
|
37
26
|
module CoordSys
|
38
|
-
|
39
|
-
def self.supported?(key)
|
40
|
-
raise(Error::UnsupportedOperation, "Invalid key. The only valid key is :proj4.") unless key == :proj4
|
41
|
-
defined?(RGeo::CoordSys::Proj4) && RGeo::CoordSys::Proj4.supported?
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.check!(key)
|
45
|
-
supported?(key) || raise(Error::UnsupportedOperation, "Coordinate system '#{key}' is not supported.")
|
46
|
-
end
|
27
|
+
CONFIG = Struct.new(:default_coord_sys_class).new(CS::CoordinateSystem)
|
47
28
|
end
|
48
29
|
end
|
data/lib/rgeo/error.rb
CHANGED
@@ -29,5 +29,20 @@ module RGeo
|
|
29
29
|
# Parsing failed
|
30
30
|
class ParseError < RGeoError
|
31
31
|
end
|
32
|
+
|
33
|
+
# Standard error messages from
|
34
|
+
# https://github.com/locationtech/jts/blob/0afbfb1956ec24912a8b4dc4edff0f1200442857/modules/core/src/main/java/org/locationtech/jts/operation/valid/TopologyValidationError.java#L98-L110
|
35
|
+
TOPOLOGY_VALIDATION_ERR = "Topology Validation Error"
|
36
|
+
REPEATED_POINT = "Repeated Point"
|
37
|
+
HOLE_OUTSIDE_SHELL = "Hole lies outside shell"
|
38
|
+
NESTED_HOLES = "Holes are nested"
|
39
|
+
DISCONNECTED_INTERIOR = "Interior is disconnected"
|
40
|
+
SELF_INTERSECTION = "Self-intersection"
|
41
|
+
RING_SELF_INTERSECTION = "Ring Self-intersection"
|
42
|
+
NESTED_SHELLS = "Nested shells"
|
43
|
+
DUPLICATE_RINGS = "Duplicate Rings"
|
44
|
+
TOO_FEW_POINTS = "Too few distinct points in geometry component"
|
45
|
+
INVALID_COORDINATE = "Invalid Coordinate"
|
46
|
+
UNCLOSED_RING = "Ring is not closed"
|
32
47
|
end
|
33
48
|
end
|
data/lib/rgeo/feature/curve.rb
CHANGED
@@ -40,7 +40,6 @@ module RGeo
|
|
40
40
|
# class method (or === operator) defined in the Type module.
|
41
41
|
#
|
42
42
|
# Some implementations may support higher dimensional points.
|
43
|
-
|
44
43
|
module Curve
|
45
44
|
include Geometry
|
46
45
|
extend Type
|
@@ -94,11 +93,6 @@ module RGeo
|
|
94
93
|
raise Error::UnsupportedOperation, "Method Curve#closed? not defined."
|
95
94
|
end
|
96
95
|
|
97
|
-
def is_closed?
|
98
|
-
warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
99
|
-
closed?
|
100
|
-
end
|
101
|
-
|
102
96
|
# === SFS 1.1 Description
|
103
97
|
#
|
104
98
|
# Returns true if this Curve is closed [StartPoint() = EndPoint()]
|
@@ -113,11 +107,6 @@ module RGeo
|
|
113
107
|
def ring?
|
114
108
|
raise Error::UnsupportedOperation, "Method Curve#ring? not defined."
|
115
109
|
end
|
116
|
-
|
117
|
-
def is_ring?
|
118
|
-
warn "The is_ring? method is deprecated, please use the ring? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
119
|
-
ring?
|
120
|
-
end
|
121
110
|
end
|
122
111
|
end
|
123
112
|
end
|
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,16 +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
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
# Returns a RGeo::CoordSys::Proj4 representing the projection for
|
224
|
-
# the coordinate system of features created by this factory, or nil
|
225
|
-
# if there is no such proj4 projection.
|
226
|
-
|
227
|
-
def proj4
|
228
|
-
nil
|
217
|
+
def multi_polygon(_elems)
|
218
|
+
raise Error::UnsupportedOperation, "Method #{self.class}##{__method__} not defined."
|
229
219
|
end
|
230
220
|
|
231
221
|
# Returns the coordinate system specification for the features
|
@@ -262,7 +252,7 @@ module RGeo
|
|
262
252
|
# the original is already of the desired factory and type
|
263
253
|
# [<tt>:project</tt>]
|
264
254
|
# indicates whether to project the coordinates from the source to
|
265
|
-
# the destination
|
255
|
+
# the destination coordinate system, if available
|
266
256
|
#
|
267
257
|
# It should return either a casted result object, false, or nil.
|
268
258
|
# A nil return value indicates that casting should be forced to
|
@@ -272,7 +262,7 @@ module RGeo
|
|
272
262
|
# algorithm to cast the object. Therefore, by default, you should
|
273
263
|
# return false.
|
274
264
|
|
275
|
-
def override_cast(
|
265
|
+
def override_cast(_original, _type, _flags)
|
276
266
|
false
|
277
267
|
end
|
278
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
|
#
|
@@ -56,25 +55,18 @@ module RGeo
|
|
56
55
|
# [<tt>:srid</tt>]
|
57
56
|
# The SRID for the factory and objects it creates.
|
58
57
|
# Default is usually 0.
|
59
|
-
# [<tt>:proj4</tt>]
|
60
|
-
# The coordinate system in Proj4 format, either as a
|
61
|
-
# CoordSys::Proj4 object or as a string or hash representing the
|
62
|
-
# proj4 format. This is usually an optional parameter; the default
|
63
|
-
# is usually nil.
|
64
58
|
# [<tt>:coord_sys</tt>]
|
65
59
|
# The coordinate system in OGC form, either as a subclass of
|
66
60
|
# CoordSys::CS::CoordinateSystem, or as a string in WKT format.
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
# If provided, look up the Proj4 and OGC coordinate systems from
|
71
|
-
# the given database and SRID.
|
61
|
+
# Optional. If no coord_sys is given, but an SRID is the factory
|
62
|
+
# will try to create one using the CoordSys::CONFIG.default_coord_sys_class
|
63
|
+
# or the given :coord_sys_class option. The option is usually nil.
|
72
64
|
# [<tt>:has_z_coordinate</tt>]
|
73
65
|
# Support Z coordinates. Default is usually false.
|
74
66
|
# [<tt>:has_m_coordinate</tt>]
|
75
67
|
# Support M coordinates. Default is usually false.
|
76
68
|
|
77
|
-
def call(
|
69
|
+
def call(_config = {})
|
78
70
|
nil
|
79
71
|
end
|
80
72
|
|
@@ -82,7 +74,7 @@ module RGeo
|
|
82
74
|
# factory.
|
83
75
|
|
84
76
|
def self.single(factory)
|
85
|
-
proc { |
|
77
|
+
proc { |_c| factory }
|
86
78
|
end
|
87
79
|
|
88
80
|
# Return a new FactoryGenerator that calls the given delegate, but
|
@@ -91,7 +83,7 @@ module RGeo
|
|
91
83
|
# force certain values to override the given configuration.
|
92
84
|
|
93
85
|
def self.decorate(delegate, default_config = {}, force_config = {})
|
94
|
-
proc { |c|
|
86
|
+
proc { |c| delegate.call(default_config.merge(c).merge(force_config)) }
|
95
87
|
end
|
96
88
|
end
|
97
89
|
end
|