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
@@ -54,12 +54,6 @@ module RGeo
|
|
54
54
|
# Support a Z coordinate. Default is false.
|
55
55
|
# [<tt>:has_m_coordinate</tt>]
|
56
56
|
# Support an M coordinate. Default is false.
|
57
|
-
# [<tt>:uses_lenient_assertions</tt>]
|
58
|
-
# If set to true, assertion checking is disabled. This includes
|
59
|
-
# simplicity checking on LinearRing, and validity checks on
|
60
|
-
# Polygon and MultiPolygon. This may speed up creation of certain
|
61
|
-
# objects, at the expense of not doing the proper checking for
|
62
|
-
# OGC compliance. Default is false.
|
63
57
|
# [<tt>:buffer_resolution</tt>]
|
64
58
|
# The resolution of buffers around geometries created by this
|
65
59
|
# factory. This controls the number of line segments used to
|
@@ -70,30 +64,20 @@ module RGeo
|
|
70
64
|
# for different kinds of buffers is not specified precisely,
|
71
65
|
# but in general the value is taken as the number of segments
|
72
66
|
# per 90-degree curve.
|
73
|
-
# [<tt>:proj4</tt>]
|
74
|
-
# Provide the coordinate system in Proj4 format. You may pass
|
75
|
-
# either an RGeo::CoordSys::Proj4 object, or a string or hash
|
76
|
-
# containing the Proj4 parameters. This coordinate system must be
|
77
|
-
# a geographic (lat/long) coordinate system. The default is the
|
78
|
-
# "popular visualization CRS" (EPSG 4055), represented by
|
79
|
-
# "<tt>+proj=longlat +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +no_defs</tt>".
|
80
|
-
# Has no effect if Proj4 is not available.
|
81
67
|
# [<tt>:coord_sys</tt>]
|
82
68
|
# Provide a coordinate system in OGC format, either as an object
|
83
69
|
# (one of the CoordSys::CS classes) or as a string in WKT format.
|
84
70
|
# This coordinate system must be a GeographicCoordinateSystem.
|
85
71
|
# The default is the "popular visualization CRS" (EPSG 4055).
|
72
|
+
# [<tt>:coord_sys_class</tt>]
|
73
|
+
# CoordSys::CS::CoordinateSystem implementation used to instansiate
|
74
|
+
# a coord_sys based on the :srid given.
|
86
75
|
# [<tt>:srid</tt>]
|
87
76
|
# The SRID that should be returned by features from this factory.
|
88
77
|
# Default is 4055, indicating EPSG 4055, the "popular
|
89
78
|
# visualization crs". You may alternatively wish to set the srid
|
90
79
|
# to 4326, indicating the WGS84 crs, but note that that value
|
91
80
|
# implies an ellipsoidal datum, not a spherical datum.
|
92
|
-
# [<tt>:srs_database</tt>]
|
93
|
-
# Optional. If provided, the object should respond to #get and
|
94
|
-
# #clear_cache. If both this and an SRID are
|
95
|
-
# provided, they are used to look up the proj4 and coord_sys
|
96
|
-
# objects from a spatial reference system database.
|
97
81
|
# [<tt>:wkt_parser</tt>]
|
98
82
|
# Configure the parser for WKT. The value is a hash of
|
99
83
|
# configuration parameters for WKRep::WKTParser.new. Default is
|
@@ -115,29 +99,21 @@ module RGeo
|
|
115
99
|
# for WKRep::WKBGenerator.
|
116
100
|
|
117
101
|
def spherical_factory(opts = {})
|
118
|
-
proj4 = opts[:proj4]
|
119
102
|
coord_sys = opts[:coord_sys]
|
120
103
|
srid = opts[:srid]
|
121
|
-
if (!proj4 || !coord_sys) && srid && (db_ = opts[:srs_database])
|
122
|
-
entry_ = db_.get(srid.to_i)
|
123
|
-
if entry_
|
124
|
-
proj4 ||= entry_.proj4
|
125
|
-
coord_sys ||= entry_.coord_sys
|
126
|
-
end
|
127
|
-
end
|
128
104
|
srid ||= coord_sys.authority_code if coord_sys
|
129
|
-
Geographic::Factory.new(
|
105
|
+
Geographic::Factory.new(
|
106
|
+
"Spherical",
|
130
107
|
has_z_coordinate: opts[:has_z_coordinate],
|
131
108
|
has_m_coordinate: opts[:has_m_coordinate],
|
132
|
-
|
133
|
-
coord_sys: coord_sys || coord_sys_4055,
|
134
|
-
uses_lenient_assertions: opts[:uses_lenient_assertions],
|
109
|
+
coord_sys: coord_sys || coord_sys4055,
|
135
110
|
buffer_resolution: opts[:buffer_resolution],
|
136
111
|
wkt_parser: opts[:wkt_parser],
|
137
112
|
wkb_parser: opts[:wkb_parser],
|
138
113
|
wkt_generator: opts[:wkt_generator],
|
139
114
|
wkb_generator: opts[:wkb_generator],
|
140
|
-
srid: (srid || 4055).to_i
|
115
|
+
srid: (srid || 4055).to_i
|
116
|
+
)
|
141
117
|
end
|
142
118
|
|
143
119
|
# Creates and returns a geographic factory that is designed for
|
@@ -207,35 +183,33 @@ module RGeo
|
|
207
183
|
#
|
208
184
|
# You may also provide options understood by the underlying
|
209
185
|
# projected Cartesian factory. For example, if GEOS is used for the
|
210
|
-
# projected factory, you may also set the
|
211
|
-
#
|
212
|
-
# <tt>:buffer_resolution</tt> options. See RGeo::Geos.factory for
|
213
|
-
# more details.
|
186
|
+
# projected factory, you may also set the <tt>:buffer_resolution</tt>
|
187
|
+
# options. See RGeo::Geos.factory for more details.
|
214
188
|
|
215
189
|
def simple_mercator_factory(opts = {})
|
216
|
-
factory = Geographic::Factory.new(
|
217
|
-
|
218
|
-
coord_sys:
|
190
|
+
factory = Geographic::Factory.new(
|
191
|
+
"Projected",
|
192
|
+
coord_sys: coord_sys4326,
|
219
193
|
srid: 4326,
|
220
194
|
wkt_parser: opts[:wkt_parser],
|
221
195
|
wkb_parser: opts[:wkb_parser],
|
222
196
|
wkt_generator: opts[:wkt_generator],
|
223
197
|
wkb_generator: opts[:wkb_generator],
|
224
198
|
has_z_coordinate: opts[:has_z_coordinate],
|
225
|
-
has_m_coordinate: opts[:has_m_coordinate]
|
226
|
-
|
227
|
-
projector = Geographic::SimpleMercatorProjector.new(
|
199
|
+
has_m_coordinate: opts[:has_m_coordinate]
|
200
|
+
)
|
201
|
+
projector = Geographic::SimpleMercatorProjector.new(
|
202
|
+
factory,
|
228
203
|
buffer_resolution: opts[:buffer_resolution],
|
229
|
-
lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions],
|
230
|
-
uses_lenient_assertions: opts[:uses_lenient_assertions],
|
231
204
|
has_z_coordinate: opts[:has_z_coordinate],
|
232
|
-
has_m_coordinate: opts[:has_m_coordinate]
|
205
|
+
has_m_coordinate: opts[:has_m_coordinate]
|
206
|
+
)
|
233
207
|
factory.projector = projector
|
234
208
|
factory
|
235
209
|
end
|
236
210
|
|
237
211
|
# Creates and returns a geographic factory that includes a
|
238
|
-
# projection specified by a
|
212
|
+
# projection specified by a coordinate system. Like all
|
239
213
|
# geographic factories, this one creates features using latitude-
|
240
214
|
# longitude values. However, calculations such as intersections are
|
241
215
|
# done in the projected coordinate system, and size and distance
|
@@ -251,30 +225,24 @@ module RGeo
|
|
251
225
|
# === Options
|
252
226
|
#
|
253
227
|
# When creating a projected implementation, you must provide enough
|
254
|
-
# information to construct a
|
228
|
+
# information to construct a CoordinateSystem specification for the projection.
|
255
229
|
# Generally, this means you will provide either the projection's
|
256
230
|
# factory itself (via the <tt>:projection_factory</tt> option), in
|
257
|
-
# which case the factory must include a
|
258
|
-
# or, alternatively, you should provide the
|
231
|
+
# which case the factory must include a coord_sys;
|
232
|
+
# or, alternatively, you should provide the coordinate system
|
259
233
|
# and let this method construct a projection factory for you (which
|
260
234
|
# it will do using the preferred Cartesian factory generator).
|
261
|
-
# If you choose this second method, you may provide the
|
262
|
-
#
|
263
|
-
# by providing both an <tt>:srid</tt> and a <tt>:srs_database</tt>
|
264
|
-
# to use to look up the coordinate system.
|
235
|
+
# If you choose this second method, you may provide the coord_sys
|
236
|
+
# via the <tt>:projection_coord_sys</tt> or <option or <tt>:projection_srid</tt>.
|
265
237
|
#
|
266
238
|
# Following are detailed descriptions of the various options you can
|
267
239
|
# pass to this method.
|
268
240
|
#
|
269
241
|
# [<tt>:projection_factory</tt>]
|
270
242
|
# Specify an existing Cartesian factory to use for the projection.
|
271
|
-
# This factory must have a non-nil
|
272
|
-
# <tt>:
|
243
|
+
# This factory must have a non-nil coord_sys. If this is provided, any
|
244
|
+
# <tt>:projection_coord_sys</tt> and
|
273
245
|
# <tt>:projection_srid</tt> are ignored.
|
274
|
-
# [<tt>:projection_proj4</tt>]
|
275
|
-
# Specify a Proj4 projection to use to construct the projection
|
276
|
-
# factory. This may be specified as a CoordSys::Proj4 object, or
|
277
|
-
# as a Proj4 string or hash representation.
|
278
246
|
# [<tt>:projection_coord_sys</tt>]
|
279
247
|
# Specify a OGC coordinate system for the projection. This may be
|
280
248
|
# specified as an RGeo::CoordSys::CS::GeographicCoordinateSystem
|
@@ -282,16 +250,12 @@ module RGeo
|
|
282
250
|
# [<tt>:projection_srid</tt>]
|
283
251
|
# The SRID value to use for the projection factory. Defaults to
|
284
252
|
# the given projection coordinate system's authority code, or to
|
285
|
-
# 0 if no projection coordinate system is known.
|
286
|
-
#
|
287
|
-
#
|
288
|
-
#
|
289
|
-
#
|
290
|
-
#
|
291
|
-
# geographic part of the projection factory's coordinate system.
|
292
|
-
# Generally, you should leave it at the default unless you want
|
293
|
-
# the geographic coordinate system to be based on a different
|
294
|
-
# horizontal datum than the projection.
|
253
|
+
# 0 if no projection coordinate system is known. If this is provided
|
254
|
+
# without a projection_coord_sys, one will be instansiated from
|
255
|
+
# the default_coord_sys_class or projection_coord_sys_class if given.
|
256
|
+
# [<tt>:projection_coord_sys_class</tt>]
|
257
|
+
# Class to create the projection_coord_sys from if only a projection_srid
|
258
|
+
# is provided.
|
295
259
|
# [<tt>:coord_sys</tt>]
|
296
260
|
# An OGC coordinate system for the geographic (lat-lon) factory,
|
297
261
|
# which may be an RGeo::CoordSys::CS::GeographicCoordinateSystem
|
@@ -304,11 +268,6 @@ module RGeo
|
|
304
268
|
# The SRID value to use for the main geographic factory. Defaults
|
305
269
|
# to the given geographic coordinate system's authority code, or
|
306
270
|
# to 0 if no geographic coordinate system is known.
|
307
|
-
# [<tt>:srs_database</tt>]
|
308
|
-
# Optional. If provided, the object should respond to #get and
|
309
|
-
# #clear_cache. If both this and an SRID are
|
310
|
-
# provided, they are used to look up the proj4 and coord_sys
|
311
|
-
# objects from a spatial reference system database.
|
312
271
|
# [<tt>:has_z_coordinate</tt>]
|
313
272
|
# Support a Z coordinate. Default is false.
|
314
273
|
# Note: this is ignored if a <tt>:projection_factory</tt> is
|
@@ -342,117 +301,77 @@ module RGeo
|
|
342
301
|
# If a <tt>:projection_factory</tt> is _not_ provided, you may also
|
343
302
|
# provide options for configuring the projected Cartesian factory.
|
344
303
|
# For example, if GEOS is used for the projected factory, you may
|
345
|
-
# also set the <tt>:
|
346
|
-
#
|
347
|
-
# more details.
|
304
|
+
# also set the <tt>:buffer_resolution</tt> option. See RGeo::Geos.factory
|
305
|
+
# for more details.
|
348
306
|
|
349
307
|
def projected_factory(opts = {})
|
350
|
-
CoordSys.check!(:proj4)
|
351
|
-
db_ = opts[:srs_database]
|
352
308
|
if (projection_factory = opts[:projection_factory])
|
353
309
|
# Get the projection coordinate systems from the given factory
|
354
|
-
projection_proj4 = projection_factory.proj4
|
355
|
-
unless projection_proj4
|
356
|
-
raise ArgumentError, "The :projection_factory does not have a proj4."
|
357
|
-
end
|
358
310
|
projection_coord_sys = projection_factory.coord_sys
|
359
|
-
|
311
|
+
|
312
|
+
if projection_coord_sys && !projection_coord_sys.projected?
|
360
313
|
raise ArgumentError, "The :projection_factory's coord_sys is not a ProjectedCoordinateSystem."
|
361
314
|
end
|
315
|
+
|
362
316
|
# Determine geographic coordinate system. First check parameters.
|
363
|
-
proj4 = opts[:proj4]
|
364
317
|
coord_sys = opts[:coord_sys]
|
365
318
|
srid = opts[:srid]
|
366
|
-
# Lookup srid from srs database if needed
|
367
|
-
if (!proj4 || !coord_sys) && srid && db_
|
368
|
-
entry_ = db_.get(srid.to_i)
|
369
|
-
if entry_
|
370
|
-
proj4 ||= entry_.proj4
|
371
|
-
coord_sys ||= entry_.coord_sys
|
372
|
-
end
|
373
|
-
end
|
374
319
|
# Fall back to getting the values from the projection.
|
375
|
-
proj4 ||= projection_proj4.get_geographic || _proj_4326
|
376
320
|
coord_sys ||= projection_coord_sys.geographic_coordinate_system if projection_coord_sys
|
377
321
|
srid ||= coord_sys.authority_code if coord_sys
|
378
322
|
srid ||= 4326
|
379
323
|
# Now we should have all the coordinate system info.
|
380
|
-
factory = Geographic::Factory.new(
|
381
|
-
|
324
|
+
factory = Geographic::Factory.new(
|
325
|
+
"Projected",
|
382
326
|
coord_sys: coord_sys,
|
383
327
|
srid: srid.to_i,
|
384
328
|
has_z_coordinate: projection_factory.property(:has_z_coordinate),
|
385
329
|
has_m_coordinate: projection_factory.property(:has_m_coordinate),
|
386
330
|
wkt_parser: opts[:wkt_parser], wkt_generator: opts[:wkt_generator],
|
387
|
-
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator]
|
388
|
-
|
389
|
-
|
331
|
+
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator]
|
332
|
+
)
|
333
|
+
projector = Geographic::Projector.create_from_existing_factory(
|
334
|
+
factory,
|
335
|
+
projection_factory
|
336
|
+
)
|
390
337
|
else
|
391
338
|
# Determine projection coordinate system. First check the parameters.
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
projection_coord_sys ||= entry_.coord_sys
|
401
|
-
end
|
402
|
-
end
|
403
|
-
# A projection proj4 is absolutely required.
|
404
|
-
unless projection_proj4
|
405
|
-
raise ArgumentError, "Unable to determine the Proj4 for the projected coordinate system."
|
406
|
-
end
|
407
|
-
# Check the projection coordinate systems, and parse if needed.
|
408
|
-
if projection_proj4.is_a?(String) || projection_proj4.is_a?(Hash)
|
409
|
-
actual_projection_proj4 = CoordSys::Proj4.create(projection_proj4)
|
410
|
-
unless actual_projection_proj4
|
411
|
-
raise ArgumentError, "Bad proj4 syntax: #{projection_proj4.inspect}"
|
412
|
-
end
|
413
|
-
projection_proj4 = actual_projection_proj4
|
414
|
-
end
|
415
|
-
if projection_coord_sys && !projection_coord_sys.is_a?(CoordSys::CS::ProjectedCoordinateSystem)
|
416
|
-
raise ArgumentError, "The :projection_coord_sys is not a ProjectedCoordinateSystem."
|
417
|
-
end
|
418
|
-
projection_srid ||= projection_coord_sys.authority_code if projection_coord_sys
|
339
|
+
projection_coord_sys_info = ImplHelper::Utils.setup_coord_sys(
|
340
|
+
opts[:projection_srid],
|
341
|
+
opts[:projection_coord_sys],
|
342
|
+
opts[:projection_coord_sys_class]
|
343
|
+
)
|
344
|
+
projection_coord_sys = projection_coord_sys_info[:coord_sys]
|
345
|
+
projection_srid = projection_coord_sys_info[:srid]
|
346
|
+
|
419
347
|
# Determine geographic coordinate system. First check parameters.
|
420
|
-
proj4 = opts[:proj4]
|
421
348
|
coord_sys = opts[:coord_sys]
|
422
349
|
srid = opts[:srid]
|
423
|
-
|
424
|
-
if (!proj4 || !coord_sys) && srid && db_
|
425
|
-
entry_ = db_.get(srid.to_i)
|
426
|
-
if entry_
|
427
|
-
proj4 ||= entry_.proj4
|
428
|
-
coord_sys ||= entry_.coord_sys
|
429
|
-
end
|
430
|
-
end
|
350
|
+
|
431
351
|
# Fall back to getting the values from the projection.
|
432
|
-
proj4 ||= projection_proj4.get_geographic || _proj_4326
|
433
352
|
coord_sys ||= projection_coord_sys.geographic_coordinate_system if projection_coord_sys
|
434
353
|
srid ||= coord_sys.authority_code if coord_sys
|
435
354
|
srid ||= 4326
|
436
355
|
# Now we should have all the coordinate system info.
|
437
|
-
factory = Geographic::Factory.new(
|
438
|
-
|
356
|
+
factory = Geographic::Factory.new(
|
357
|
+
"Projected",
|
439
358
|
coord_sys: coord_sys,
|
440
359
|
srid: srid.to_i,
|
441
360
|
has_z_coordinate: opts[:has_z_coordinate],
|
442
361
|
has_m_coordinate: opts[:has_m_coordinate],
|
443
362
|
wkt_parser: opts[:wkt_parser], wkt_generator: opts[:wkt_generator],
|
444
|
-
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator]
|
445
|
-
|
446
|
-
|
363
|
+
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator]
|
364
|
+
)
|
365
|
+
projector = Geographic::Projector.create_from_opts(
|
366
|
+
factory,
|
447
367
|
srid: projection_srid,
|
448
368
|
coord_sys: projection_coord_sys,
|
449
369
|
buffer_resolution: opts[:buffer_resolution],
|
450
|
-
lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions],
|
451
|
-
uses_lenient_assertions: opts[:uses_lenient_assertions],
|
452
370
|
has_z_coordinate: opts[:has_z_coordinate],
|
453
371
|
has_m_coordinate: opts[:has_m_coordinate],
|
454
372
|
wkt_parser: opts[:wkt_parser], wkt_generator: opts[:wkt_generator],
|
455
|
-
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator]
|
373
|
+
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator]
|
374
|
+
)
|
456
375
|
end
|
457
376
|
factory.projector = projector
|
458
377
|
factory
|
@@ -460,32 +379,16 @@ module RGeo
|
|
460
379
|
|
461
380
|
private
|
462
381
|
|
463
|
-
def
|
464
|
-
|
465
|
-
@proj44055 = CoordSys.supported?(:proj4) && CoordSys::Proj4.create("+proj=longlat +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +no_defs")
|
466
|
-
end
|
467
|
-
@proj44055
|
468
|
-
end
|
382
|
+
def coord_sys4055
|
383
|
+
return @coord_sys4055 if defined?(@coord_sys4055)
|
469
384
|
|
470
|
-
|
471
|
-
unless defined?(@coord_sys_4055)
|
472
|
-
@coord_sys_4055 = CoordSys::CS.create_from_wkt('GEOGCS["Popular Visualisation CRS",DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation Sphere",6378137,0,AUTHORITY["EPSG","7059"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6055"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4055"]]')
|
473
|
-
end
|
474
|
-
@coord_sys_4055
|
385
|
+
@coord_sys4055 = CoordSys::CONFIG.default_coord_sys_class.create(4055)
|
475
386
|
end
|
476
387
|
|
477
|
-
def
|
478
|
-
|
479
|
-
@proj_4326 = CoordSys.supported?(:proj4) && CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
480
|
-
end
|
481
|
-
@proj_4326
|
482
|
-
end
|
388
|
+
def coord_sys4326
|
389
|
+
return @coord_sys4326 if defined?(@coord_sys4326)
|
483
390
|
|
484
|
-
|
485
|
-
unless defined?(@coord_sys_4326)
|
486
|
-
@coord_sys_4326 = CoordSys::CS.create_from_wkt('GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]')
|
487
|
-
end
|
488
|
-
@coord_sys_4326
|
391
|
+
@coord_sys4326 = CoordSys::CONFIG.default_coord_sys_class.create(4326)
|
489
392
|
end
|
490
393
|
end
|
491
394
|
end
|
@@ -8,16 +8,18 @@
|
|
8
8
|
|
9
9
|
module RGeo
|
10
10
|
module Geographic
|
11
|
-
class ProjectedPointImpl
|
11
|
+
class ProjectedPointImpl
|
12
12
|
include Feature::Point
|
13
|
+
include ImplHelper::ValidityCheck
|
13
14
|
include ImplHelper::BasicGeometryMethods
|
14
15
|
include ImplHelper::BasicPointMethods
|
15
16
|
include ProjectedGeometryMethods
|
16
17
|
include ProjectedPointMethods
|
17
18
|
end
|
18
19
|
|
19
|
-
class ProjectedLineStringImpl
|
20
|
+
class ProjectedLineStringImpl
|
20
21
|
include Feature::LineString
|
22
|
+
include ImplHelper::ValidityCheck
|
21
23
|
include ImplHelper::BasicGeometryMethods
|
22
24
|
include ImplHelper::BasicLineStringMethods
|
23
25
|
include ProjectedGeometryMethods
|
@@ -25,18 +27,21 @@ module RGeo
|
|
25
27
|
include ProjectedLineStringMethods
|
26
28
|
end
|
27
29
|
|
28
|
-
class ProjectedLinearRingImpl
|
30
|
+
class ProjectedLinearRingImpl
|
29
31
|
include Feature::LinearRing
|
32
|
+
include ImplHelper::ValidityCheck
|
30
33
|
include ImplHelper::BasicGeometryMethods
|
31
34
|
include ImplHelper::BasicLineStringMethods
|
32
35
|
include ImplHelper::BasicLinearRingMethods
|
33
36
|
include ProjectedGeometryMethods
|
34
37
|
include ProjectedNCurveMethods
|
35
38
|
include ProjectedLineStringMethods
|
39
|
+
include ProjectedLinearRingMethods
|
36
40
|
end
|
37
41
|
|
38
|
-
class ProjectedLineImpl
|
42
|
+
class ProjectedLineImpl
|
39
43
|
include Feature::Line
|
44
|
+
include ImplHelper::ValidityCheck
|
40
45
|
include ImplHelper::BasicGeometryMethods
|
41
46
|
include ImplHelper::BasicLineStringMethods
|
42
47
|
include ImplHelper::BasicLineMethods
|
@@ -45,8 +50,9 @@ module RGeo
|
|
45
50
|
include ProjectedLineStringMethods
|
46
51
|
end
|
47
52
|
|
48
|
-
class ProjectedPolygonImpl
|
53
|
+
class ProjectedPolygonImpl
|
49
54
|
include Feature::Polygon
|
55
|
+
include ImplHelper::ValidityCheck
|
50
56
|
include ImplHelper::BasicGeometryMethods
|
51
57
|
include ImplHelper::BasicPolygonMethods
|
52
58
|
include ProjectedGeometryMethods
|
@@ -54,23 +60,26 @@ module RGeo
|
|
54
60
|
include ProjectedPolygonMethods
|
55
61
|
end
|
56
62
|
|
57
|
-
class ProjectedGeometryCollectionImpl
|
63
|
+
class ProjectedGeometryCollectionImpl
|
58
64
|
include Feature::GeometryCollection
|
65
|
+
include ImplHelper::ValidityCheck
|
59
66
|
include ImplHelper::BasicGeometryMethods
|
60
67
|
include ImplHelper::BasicGeometryCollectionMethods
|
61
68
|
include ProjectedGeometryMethods
|
62
69
|
end
|
63
70
|
|
64
|
-
class ProjectedMultiPointImpl
|
71
|
+
class ProjectedMultiPointImpl
|
65
72
|
include Feature::MultiPoint
|
73
|
+
include ImplHelper::ValidityCheck
|
66
74
|
include ImplHelper::BasicGeometryMethods
|
67
75
|
include ImplHelper::BasicGeometryCollectionMethods
|
68
76
|
include ImplHelper::BasicMultiPointMethods
|
69
77
|
include ProjectedGeometryMethods
|
70
78
|
end
|
71
79
|
|
72
|
-
class ProjectedMultiLineStringImpl
|
80
|
+
class ProjectedMultiLineStringImpl
|
73
81
|
include Feature::MultiLineString
|
82
|
+
include ImplHelper::ValidityCheck
|
74
83
|
include ImplHelper::BasicGeometryMethods
|
75
84
|
include ImplHelper::BasicGeometryCollectionMethods
|
76
85
|
include ImplHelper::BasicMultiLineStringMethods
|
@@ -78,8 +87,9 @@ module RGeo
|
|
78
87
|
include ProjectedNCurveMethods
|
79
88
|
end
|
80
89
|
|
81
|
-
class ProjectedMultiPolygonImpl
|
90
|
+
class ProjectedMultiPolygonImpl
|
82
91
|
include Feature::MultiPolygon
|
92
|
+
include ImplHelper::ValidityCheck
|
83
93
|
include ImplHelper::BasicGeometryMethods
|
84
94
|
include ImplHelper::BasicGeometryCollectionMethods
|
85
95
|
include ImplHelper::BasicMultiPolygonMethods
|
@@ -87,5 +97,7 @@ module RGeo
|
|
87
97
|
include ProjectedNSurfaceMethods
|
88
98
|
include ProjectedMultiPolygonMethods
|
89
99
|
end
|
100
|
+
|
101
|
+
ImplHelper::ValidityCheck.override_classes
|
90
102
|
end
|
91
103
|
end
|