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
|
# Access to geographic data factories
|
@@ -88,8 +90,8 @@ module RGeo
|
|
88
90
|
# to 4326, indicating the WGS84 crs, but note that that value
|
89
91
|
# implies an ellipsoidal datum, not a spherical datum.
|
90
92
|
# [<tt>:srs_database</tt>]
|
91
|
-
# Optional. If provided, the
|
92
|
-
#
|
93
|
+
# Optional. If provided, the object should respond to #get and
|
94
|
+
# #clear_cache. If both this and an SRID are
|
93
95
|
# provided, they are used to look up the proj4 and coord_sys
|
94
96
|
# objects from a spatial reference system database.
|
95
97
|
# [<tt>:wkt_parser</tt>]
|
@@ -112,30 +114,30 @@ module RGeo
|
|
112
114
|
# Default is the empty hash, indicating the default configuration
|
113
115
|
# for WKRep::WKBGenerator.
|
114
116
|
|
115
|
-
def spherical_factory(
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
if (!
|
120
|
-
entry_ = db_.get(
|
117
|
+
def spherical_factory(opts = {})
|
118
|
+
proj4 = opts[:proj4]
|
119
|
+
coord_sys = opts[:coord_sys]
|
120
|
+
srid = opts[:srid]
|
121
|
+
if (!proj4 || !coord_sys) && srid && (db_ = opts[:srs_database])
|
122
|
+
entry_ = db_.get(srid.to_i)
|
121
123
|
if entry_
|
122
|
-
|
123
|
-
|
124
|
+
proj4 ||= entry_.proj4
|
125
|
+
coord_sys ||= entry_.coord_sys
|
124
126
|
end
|
125
127
|
end
|
126
|
-
|
128
|
+
srid ||= coord_sys.authority_code if coord_sys
|
127
129
|
Geographic::Factory.new("Spherical",
|
128
|
-
has_z_coordinate:
|
129
|
-
has_m_coordinate:
|
130
|
-
proj4:
|
131
|
-
coord_sys:
|
132
|
-
uses_lenient_assertions:
|
133
|
-
buffer_resolution:
|
134
|
-
wkt_parser:
|
135
|
-
wkb_parser:
|
136
|
-
wkt_generator:
|
137
|
-
wkb_generator:
|
138
|
-
srid: (
|
130
|
+
has_z_coordinate: opts[:has_z_coordinate],
|
131
|
+
has_m_coordinate: opts[:has_m_coordinate],
|
132
|
+
proj4: proj4 || proj_4055,
|
133
|
+
coord_sys: coord_sys || coord_sys_4055,
|
134
|
+
uses_lenient_assertions: opts[:uses_lenient_assertions],
|
135
|
+
buffer_resolution: opts[:buffer_resolution],
|
136
|
+
wkt_parser: opts[:wkt_parser],
|
137
|
+
wkb_parser: opts[:wkb_parser],
|
138
|
+
wkt_generator: opts[:wkt_generator],
|
139
|
+
wkb_generator: opts[:wkb_generator],
|
140
|
+
srid: (srid || 4055).to_i)
|
139
141
|
end
|
140
142
|
|
141
143
|
# Creates and returns a geographic factory that is designed for
|
@@ -210,25 +212,25 @@ module RGeo
|
|
210
212
|
# <tt>:buffer_resolution</tt> options. See RGeo::Geos.factory for
|
211
213
|
# more details.
|
212
214
|
|
213
|
-
def simple_mercator_factory(
|
214
|
-
|
215
|
-
proj4:
|
216
|
-
coord_sys:
|
215
|
+
def simple_mercator_factory(opts = {})
|
216
|
+
factory = Geographic::Factory.new("Projected",
|
217
|
+
proj4: proj_4326,
|
218
|
+
coord_sys: coord_sys_4326,
|
217
219
|
srid: 4326,
|
218
|
-
wkt_parser:
|
219
|
-
wkb_parser:
|
220
|
-
wkt_generator:
|
221
|
-
wkb_generator:
|
222
|
-
has_z_coordinate:
|
223
|
-
has_m_coordinate:
|
224
|
-
|
225
|
-
buffer_resolution:
|
226
|
-
lenient_multi_polygon_assertions:
|
227
|
-
uses_lenient_assertions:
|
228
|
-
has_z_coordinate:
|
229
|
-
has_m_coordinate:
|
230
|
-
|
231
|
-
|
220
|
+
wkt_parser: opts[:wkt_parser],
|
221
|
+
wkb_parser: opts[:wkb_parser],
|
222
|
+
wkt_generator: opts[:wkt_generator],
|
223
|
+
wkb_generator: opts[:wkb_generator],
|
224
|
+
has_z_coordinate: opts[:has_z_coordinate],
|
225
|
+
has_m_coordinate: opts[:has_m_coordinate])
|
226
|
+
projector = Geographic::SimpleMercatorProjector.new(factory,
|
227
|
+
buffer_resolution: opts[:buffer_resolution],
|
228
|
+
lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions],
|
229
|
+
uses_lenient_assertions: opts[:uses_lenient_assertions],
|
230
|
+
has_z_coordinate: opts[:has_z_coordinate],
|
231
|
+
has_m_coordinate: opts[:has_m_coordinate])
|
232
|
+
factory.projector = projector
|
233
|
+
factory
|
232
234
|
end
|
233
235
|
|
234
236
|
# Creates and returns a geographic factory that includes a
|
@@ -302,8 +304,8 @@ module RGeo
|
|
302
304
|
# to the given geographic coordinate system's authority code, or
|
303
305
|
# to 0 if no geographic coordinate system is known.
|
304
306
|
# [<tt>:srs_database</tt>]
|
305
|
-
# Optional. If provided, the
|
306
|
-
#
|
307
|
+
# Optional. If provided, the object should respond to #get and
|
308
|
+
# #clear_cache. If both this and an SRID are
|
307
309
|
# provided, they are used to look up the proj4 and coord_sys
|
308
310
|
# objects from a spatial reference system database.
|
309
311
|
# [<tt>:has_z_coordinate</tt>]
|
@@ -343,144 +345,146 @@ module RGeo
|
|
343
345
|
# <tt>:buffer_resolution</tt> options. See RGeo::Geos.factory for
|
344
346
|
# more details.
|
345
347
|
|
346
|
-
def projected_factory(
|
348
|
+
def projected_factory(opts = {})
|
347
349
|
CoordSys.check!(:proj4)
|
348
|
-
db_ =
|
349
|
-
if (
|
350
|
+
db_ = opts[:srs_database]
|
351
|
+
if (projection_factory = opts[:projection_factory])
|
350
352
|
# Get the projection coordinate systems from the given factory
|
351
|
-
|
352
|
-
unless
|
353
|
-
raise
|
353
|
+
projection_proj4 = projection_factory.proj4
|
354
|
+
unless projection_proj4
|
355
|
+
raise ArgumentError, "The :projection_factory does not have a proj4."
|
354
356
|
end
|
355
|
-
|
356
|
-
if
|
357
|
-
raise
|
357
|
+
projection_coord_sys = projection_factory.coord_sys
|
358
|
+
if projection_coord_sys && !projection_coord_sys.is_a?(CoordSys::CS::ProjectedCoordinateSystem)
|
359
|
+
raise ArgumentError, "The :projection_factory's coord_sys is not a ProjectedCoordinateSystem."
|
358
360
|
end
|
359
361
|
# Determine geographic coordinate system. First check parameters.
|
360
|
-
|
361
|
-
|
362
|
-
|
362
|
+
proj4 = opts[:proj4]
|
363
|
+
coord_sys = opts[:coord_sys]
|
364
|
+
srid = opts[:srid]
|
363
365
|
# Lookup srid from srs database if needed
|
364
|
-
if (!
|
365
|
-
entry_ = db_.get(
|
366
|
+
if (!proj4 || !coord_sys) && srid && db_
|
367
|
+
entry_ = db_.get(srid.to_i)
|
366
368
|
if entry_
|
367
|
-
|
368
|
-
|
369
|
+
proj4 ||= entry_.proj4
|
370
|
+
coord_sys ||= entry_.coord_sys
|
369
371
|
end
|
370
372
|
end
|
371
373
|
# Fall back to getting the values from the projection.
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
374
|
+
proj4 ||= projection_proj4.get_geographic || _proj_4326
|
375
|
+
coord_sys ||= projection_coord_sys.geographic_coordinate_system if projection_coord_sys
|
376
|
+
srid ||= coord_sys.authority_code if coord_sys
|
377
|
+
srid ||= 4326
|
376
378
|
# Now we should have all the coordinate system info.
|
377
|
-
|
378
|
-
proj4:
|
379
|
-
coord_sys:
|
380
|
-
srid:
|
381
|
-
has_z_coordinate:
|
382
|
-
has_m_coordinate:
|
383
|
-
wkt_parser:
|
384
|
-
wkb_parser:
|
385
|
-
|
386
|
-
|
379
|
+
factory = Geographic::Factory.new("Projected",
|
380
|
+
proj4: proj4,
|
381
|
+
coord_sys: coord_sys,
|
382
|
+
srid: srid.to_i,
|
383
|
+
has_z_coordinate: projection_factory.property(:has_z_coordinate),
|
384
|
+
has_m_coordinate: projection_factory.property(:has_m_coordinate),
|
385
|
+
wkt_parser: opts[:wkt_parser], wkt_generator: opts[:wkt_generator],
|
386
|
+
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator])
|
387
|
+
projector = Geographic::Proj4Projector.create_from_existing_factory(factory,
|
388
|
+
projection_factory)
|
387
389
|
else
|
388
390
|
# Determine projection coordinate system. First check the parameters.
|
389
|
-
|
390
|
-
|
391
|
-
|
391
|
+
projection_proj4 = opts[:projection_proj4]
|
392
|
+
projection_coord_sys = opts[:projection_coord_sys]
|
393
|
+
projection_srid = opts[:projection_srid]
|
392
394
|
# Check the case where we need to look up a srid from an srs database.
|
393
|
-
if (!
|
394
|
-
entry_ = db_.get(
|
395
|
+
if (!projection_proj4 || !projection_coord_sys) && projection_srid && db_
|
396
|
+
entry_ = db_.get(projection_srid.to_i)
|
395
397
|
if entry_
|
396
|
-
|
397
|
-
|
398
|
+
projection_proj4 ||= entry_.proj4
|
399
|
+
projection_coord_sys ||= entry_.coord_sys
|
398
400
|
end
|
399
401
|
end
|
400
402
|
# A projection proj4 is absolutely required.
|
401
|
-
unless
|
402
|
-
raise
|
403
|
+
unless projection_proj4
|
404
|
+
raise ArgumentError, "Unable to determine the Proj4 for the projected coordinate system."
|
403
405
|
end
|
404
406
|
# Check the projection coordinate systems, and parse if needed.
|
405
|
-
if
|
406
|
-
|
407
|
-
unless
|
408
|
-
raise
|
407
|
+
if projection_proj4.is_a?(String) || projection_proj4.is_a?(Hash)
|
408
|
+
actual_projection_proj4 = CoordSys::Proj4.create(projection_proj4)
|
409
|
+
unless actual_projection_proj4
|
410
|
+
raise ArgumentError, "Bad proj4 syntax: #{projection_proj4.inspect}"
|
409
411
|
end
|
410
|
-
|
412
|
+
projection_proj4 = actual_projection_proj4
|
411
413
|
end
|
412
|
-
if
|
413
|
-
raise
|
414
|
+
if projection_coord_sys && !projection_coord_sys.is_a?(CoordSys::CS::ProjectedCoordinateSystem)
|
415
|
+
raise ArgumentError, "The :projection_coord_sys is not a ProjectedCoordinateSystem."
|
414
416
|
end
|
415
|
-
|
417
|
+
projection_srid ||= projection_coord_sys.authority_code if projection_coord_sys
|
416
418
|
# Determine geographic coordinate system. First check parameters.
|
417
|
-
|
418
|
-
|
419
|
-
|
419
|
+
proj4 = opts[:proj4]
|
420
|
+
coord_sys = opts[:coord_sys]
|
421
|
+
srid = opts[:srid]
|
420
422
|
# Lookup srid from srs database if needed
|
421
|
-
if (!
|
422
|
-
entry_ = db_.get(
|
423
|
+
if (!proj4 || !coord_sys) && srid && db_
|
424
|
+
entry_ = db_.get(srid.to_i)
|
423
425
|
if entry_
|
424
|
-
|
425
|
-
|
426
|
+
proj4 ||= entry_.proj4
|
427
|
+
coord_sys ||= entry_.coord_sys
|
426
428
|
end
|
427
429
|
end
|
428
430
|
# Fall back to getting the values from the projection.
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
431
|
+
proj4 ||= projection_proj4.get_geographic || _proj_4326
|
432
|
+
coord_sys ||= projection_coord_sys.geographic_coordinate_system if projection_coord_sys
|
433
|
+
srid ||= coord_sys.authority_code if coord_sys
|
434
|
+
srid ||= 4326
|
433
435
|
# Now we should have all the coordinate system info.
|
434
|
-
|
435
|
-
proj4:
|
436
|
-
coord_sys:
|
437
|
-
srid:
|
438
|
-
has_z_coordinate:
|
439
|
-
has_m_coordinate:
|
440
|
-
wkt_parser:
|
441
|
-
wkb_parser:
|
442
|
-
|
443
|
-
|
444
|
-
srid:
|
445
|
-
coord_sys:
|
446
|
-
buffer_resolution:
|
447
|
-
lenient_multi_polygon_assertions:
|
448
|
-
uses_lenient_assertions:
|
449
|
-
has_z_coordinate:
|
450
|
-
has_m_coordinate:
|
451
|
-
wkt_parser:
|
452
|
-
wkb_parser:
|
436
|
+
factory = Geographic::Factory.new("Projected",
|
437
|
+
proj4: proj4,
|
438
|
+
coord_sys: coord_sys,
|
439
|
+
srid: srid.to_i,
|
440
|
+
has_z_coordinate: opts[:has_z_coordinate],
|
441
|
+
has_m_coordinate: opts[:has_m_coordinate],
|
442
|
+
wkt_parser: opts[:wkt_parser], wkt_generator: opts[:wkt_generator],
|
443
|
+
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator])
|
444
|
+
projector = Geographic::Proj4Projector.create_from_proj4(factory,
|
445
|
+
projection_proj4,
|
446
|
+
srid: projection_srid,
|
447
|
+
coord_sys: projection_coord_sys,
|
448
|
+
buffer_resolution: opts[:buffer_resolution],
|
449
|
+
lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions],
|
450
|
+
uses_lenient_assertions: opts[:uses_lenient_assertions],
|
451
|
+
has_z_coordinate: opts[:has_z_coordinate],
|
452
|
+
has_m_coordinate: opts[:has_m_coordinate],
|
453
|
+
wkt_parser: opts[:wkt_parser], wkt_generator: opts[:wkt_generator],
|
454
|
+
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator])
|
453
455
|
end
|
454
|
-
|
455
|
-
|
456
|
+
factory.projector = projector
|
457
|
+
factory
|
456
458
|
end
|
457
459
|
|
458
|
-
|
459
|
-
|
460
|
-
|
460
|
+
private
|
461
|
+
|
462
|
+
def proj_4055
|
463
|
+
unless defined?(@proj44055)
|
464
|
+
@proj44055 = CoordSys.supported?(:proj4) && CoordSys::Proj4.create("+proj=longlat +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +no_defs")
|
461
465
|
end
|
462
|
-
@
|
466
|
+
@proj44055
|
463
467
|
end
|
464
468
|
|
465
|
-
def
|
466
|
-
unless defined?(@
|
467
|
-
@
|
469
|
+
def coord_sys_4055
|
470
|
+
unless defined?(@coord_sys_4055)
|
471
|
+
@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"]]')
|
468
472
|
end
|
469
|
-
@
|
473
|
+
@coord_sys_4055
|
470
474
|
end
|
471
475
|
|
472
|
-
def
|
473
|
-
unless defined?(@
|
474
|
-
@
|
476
|
+
def proj_4326
|
477
|
+
unless defined?(@proj_4326)
|
478
|
+
@proj_4326 = CoordSys.supported?(:proj4) && CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
475
479
|
end
|
476
|
-
@
|
480
|
+
@proj_4326
|
477
481
|
end
|
478
482
|
|
479
|
-
def
|
480
|
-
unless defined?(@
|
481
|
-
@
|
483
|
+
def coord_sys_4326
|
484
|
+
unless defined?(@coord_sys_4326)
|
485
|
+
@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"]]')
|
482
486
|
end
|
483
|
-
@
|
487
|
+
@coord_sys_4326
|
484
488
|
end
|
485
489
|
end
|
486
490
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -----------------------------------------------------------------------------
|
2
4
|
#
|
3
5
|
# Proj4 projection
|
@@ -7,22 +9,22 @@
|
|
7
9
|
module RGeo
|
8
10
|
module Geographic
|
9
11
|
class Proj4Projector # :nodoc:
|
10
|
-
def initialize(
|
11
|
-
@geography_factory =
|
12
|
-
@projection_factory =
|
12
|
+
def initialize(geography_factory, projection_factory)
|
13
|
+
@geography_factory = geography_factory
|
14
|
+
@projection_factory = projection_factory
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
16
|
-
@geography_factory =
|
17
|
-
@projection_factory =
|
17
|
+
def set_factories(geography_factory, projection_factory)
|
18
|
+
@geography_factory = geography_factory
|
19
|
+
@projection_factory = projection_factory
|
18
20
|
end
|
19
21
|
|
20
|
-
def project(
|
21
|
-
Feature.cast(
|
22
|
+
def project(geometry)
|
23
|
+
Feature.cast(geometry, @projection_factory, :project)
|
22
24
|
end
|
23
25
|
|
24
|
-
def unproject(
|
25
|
-
Feature.cast(
|
26
|
+
def unproject(geometry)
|
27
|
+
Feature.cast(geometry, @geography_factory, :project)
|
26
28
|
end
|
27
29
|
|
28
30
|
attr_reader :projection_factory
|
@@ -36,21 +38,24 @@ module RGeo
|
|
36
38
|
end
|
37
39
|
|
38
40
|
class << self
|
39
|
-
def create_from_existing_factory(
|
40
|
-
new(
|
41
|
+
def create_from_existing_factory(geography_factory, projection_factory)
|
42
|
+
new(geography_factory, projection_factory)
|
41
43
|
end
|
42
44
|
|
43
|
-
def create_from_proj4(
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
def create_from_proj4(geography_factory, proj4, opts = {})
|
46
|
+
projection_factory =
|
47
|
+
Cartesian.preferred_factory(
|
48
|
+
proj4: proj4,
|
49
|
+
coord_sys: opts[:coord_sys], srid: opts[:srid],
|
50
|
+
buffer_resolution: opts[:buffer_resolution],
|
51
|
+
lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions],
|
52
|
+
uses_lenient_assertions: opts[:uses_lenient_assertions],
|
53
|
+
has_z_coordinate: opts[:has_z_coordinate],
|
54
|
+
has_m_coordinate: opts[:has_m_coordinate],
|
55
|
+
wkt_parser: opts[:wkt_parser], wkt_generator: opts[:wkt_generator],
|
56
|
+
wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator]
|
57
|
+
)
|
58
|
+
new(geography_factory, projection_factory)
|
54
59
|
end
|
55
60
|
end
|
56
61
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -----------------------------------------------------------------------------
|
2
4
|
#
|
3
5
|
# Projtected geographic feature classes
|
@@ -12,8 +14,6 @@ module RGeo
|
|
12
14
|
include ImplHelper::BasicPointMethods
|
13
15
|
include ProjectedGeometryMethods
|
14
16
|
include ProjectedPointMethods
|
15
|
-
|
16
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::Point).include_in_class(self, true)
|
17
17
|
end
|
18
18
|
|
19
19
|
class ProjectedLineStringImpl # :nodoc:
|
@@ -23,8 +23,6 @@ module RGeo
|
|
23
23
|
include ProjectedGeometryMethods
|
24
24
|
include ProjectedNCurveMethods
|
25
25
|
include ProjectedLineStringMethods
|
26
|
-
|
27
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::LineString).include_in_class(self, true)
|
28
26
|
end
|
29
27
|
|
30
28
|
class ProjectedLinearRingImpl # :nodoc:
|
@@ -35,8 +33,6 @@ module RGeo
|
|
35
33
|
include ProjectedGeometryMethods
|
36
34
|
include ProjectedNCurveMethods
|
37
35
|
include ProjectedLineStringMethods
|
38
|
-
|
39
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::LinearRing).include_in_class(self, true)
|
40
36
|
end
|
41
37
|
|
42
38
|
class ProjectedLineImpl # :nodoc:
|
@@ -47,8 +43,6 @@ module RGeo
|
|
47
43
|
include ProjectedGeometryMethods
|
48
44
|
include ProjectedNCurveMethods
|
49
45
|
include ProjectedLineStringMethods
|
50
|
-
|
51
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::Line).include_in_class(self, true)
|
52
46
|
end
|
53
47
|
|
54
48
|
class ProjectedPolygonImpl # :nodoc:
|
@@ -58,8 +52,6 @@ module RGeo
|
|
58
52
|
include ProjectedGeometryMethods
|
59
53
|
include ProjectedNSurfaceMethods
|
60
54
|
include ProjectedPolygonMethods
|
61
|
-
|
62
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::Polygon).include_in_class(self, true)
|
63
55
|
end
|
64
56
|
|
65
57
|
class ProjectedGeometryCollectionImpl # :nodoc:
|
@@ -67,8 +59,6 @@ module RGeo
|
|
67
59
|
include ImplHelper::BasicGeometryMethods
|
68
60
|
include ImplHelper::BasicGeometryCollectionMethods
|
69
61
|
include ProjectedGeometryMethods
|
70
|
-
|
71
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::GeometryCollection).include_in_class(self, true)
|
72
62
|
end
|
73
63
|
|
74
64
|
class ProjectedMultiPointImpl # :nodoc:
|
@@ -77,8 +67,6 @@ module RGeo
|
|
77
67
|
include ImplHelper::BasicGeometryCollectionMethods
|
78
68
|
include ImplHelper::BasicMultiPointMethods
|
79
69
|
include ProjectedGeometryMethods
|
80
|
-
|
81
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPoint).include_in_class(self, true)
|
82
70
|
end
|
83
71
|
|
84
72
|
class ProjectedMultiLineStringImpl # :nodoc:
|
@@ -88,8 +76,6 @@ module RGeo
|
|
88
76
|
include ImplHelper::BasicMultiLineStringMethods
|
89
77
|
include ProjectedGeometryMethods
|
90
78
|
include ProjectedNCurveMethods
|
91
|
-
|
92
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiLineString).include_in_class(self, true)
|
93
79
|
end
|
94
80
|
|
95
81
|
class ProjectedMultiPolygonImpl # :nodoc:
|
@@ -100,8 +86,6 @@ module RGeo
|
|
100
86
|
include ProjectedGeometryMethods
|
101
87
|
include ProjectedNSurfaceMethods
|
102
88
|
include ProjectedMultiPolygonMethods
|
103
|
-
|
104
|
-
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPolygon).include_in_class(self, true)
|
105
89
|
end
|
106
90
|
end
|
107
91
|
end
|