rgeo 1.1.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/ext/geos_c_impl/extconf.rb +5 -3
  3. data/ext/geos_c_impl/factory.c +4 -4
  4. data/ext/geos_c_impl/geometry.c +1 -1
  5. data/lib/rgeo.rb +2 -4
  6. data/lib/rgeo/cartesian.rb +6 -16
  7. data/lib/rgeo/cartesian/analysis.rb +22 -20
  8. data/lib/rgeo/cartesian/bounding_box.rb +83 -79
  9. data/lib/rgeo/cartesian/calculations.rb +40 -38
  10. data/lib/rgeo/cartesian/factory.rb +134 -169
  11. data/lib/rgeo/cartesian/feature_classes.rb +2 -18
  12. data/lib/rgeo/cartesian/feature_methods.rb +37 -39
  13. data/lib/rgeo/cartesian/interface.rb +11 -9
  14. data/lib/rgeo/coord_sys.rb +9 -8
  15. data/lib/rgeo/coord_sys/cs/entities.rb +345 -303
  16. data/lib/rgeo/coord_sys/cs/factories.rb +30 -28
  17. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +128 -126
  18. data/lib/rgeo/coord_sys/srs_database/{interface.rb → entry.rb} +26 -32
  19. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +19 -17
  20. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +21 -19
  21. data/lib/rgeo/error.rb +3 -1
  22. data/lib/rgeo/feature.rb +23 -34
  23. data/lib/rgeo/feature/curve.rb +2 -0
  24. data/lib/rgeo/feature/factory.rb +15 -13
  25. data/lib/rgeo/feature/factory_generator.rb +7 -5
  26. data/lib/rgeo/feature/geometry.rb +31 -29
  27. data/lib/rgeo/feature/geometry_collection.rb +6 -4
  28. data/lib/rgeo/feature/line.rb +2 -0
  29. data/lib/rgeo/feature/line_string.rb +3 -1
  30. data/lib/rgeo/feature/linear_ring.rb +2 -0
  31. data/lib/rgeo/feature/multi_curve.rb +2 -0
  32. data/lib/rgeo/feature/multi_line_string.rb +2 -0
  33. data/lib/rgeo/feature/multi_point.rb +2 -0
  34. data/lib/rgeo/feature/multi_polygon.rb +2 -0
  35. data/lib/rgeo/feature/multi_surface.rb +2 -0
  36. data/lib/rgeo/feature/point.rb +2 -0
  37. data/lib/rgeo/feature/polygon.rb +3 -1
  38. data/lib/rgeo/feature/surface.rb +2 -0
  39. data/lib/rgeo/feature/types.rb +107 -103
  40. data/lib/rgeo/geographic.rb +17 -27
  41. data/lib/rgeo/geographic/factory.rb +154 -199
  42. data/lib/rgeo/geographic/interface.rb +141 -137
  43. data/lib/rgeo/geographic/proj4_projector.rb +28 -23
  44. data/lib/rgeo/geographic/projected_feature_classes.rb +2 -18
  45. data/lib/rgeo/geographic/projected_feature_methods.rb +59 -49
  46. data/lib/rgeo/geographic/projected_window.rb +4 -2
  47. data/lib/rgeo/geographic/simple_mercator_projector.rb +41 -39
  48. data/lib/rgeo/geographic/spherical_feature_classes.rb +2 -18
  49. data/lib/rgeo/geographic/spherical_feature_methods.rb +67 -67
  50. data/lib/rgeo/geographic/spherical_math.rb +81 -87
  51. data/lib/rgeo/geos.rb +23 -34
  52. data/lib/rgeo/geos/capi_factory.rb +106 -135
  53. data/lib/rgeo/geos/capi_feature_classes.rb +19 -37
  54. data/lib/rgeo/geos/ffi_factory.rb +276 -297
  55. data/lib/rgeo/geos/ffi_feature_classes.rb +2 -20
  56. data/lib/rgeo/geos/ffi_feature_methods.rb +170 -166
  57. data/lib/rgeo/geos/interface.rb +25 -23
  58. data/lib/rgeo/geos/utils.rb +47 -39
  59. data/lib/rgeo/geos/zm_factory.rb +171 -185
  60. data/lib/rgeo/geos/zm_feature_classes.rb +2 -20
  61. data/lib/rgeo/geos/zm_feature_methods.rb +76 -72
  62. data/lib/rgeo/impl_helper.rb +1 -11
  63. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +72 -75
  64. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +21 -23
  65. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +57 -49
  66. data/lib/rgeo/impl_helper/basic_point_methods.rb +29 -25
  67. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +31 -27
  68. data/lib/rgeo/impl_helper/math.rb +2 -0
  69. data/lib/rgeo/impl_helper/utils.rb +9 -15
  70. data/lib/rgeo/version.rb +3 -1
  71. data/lib/rgeo/wkrep.rb +20 -30
  72. data/lib/rgeo/wkrep/wkb_generator.rb +87 -84
  73. data/lib/rgeo/wkrep/wkb_parser.rb +93 -93
  74. data/lib/rgeo/wkrep/wkt_generator.rb +67 -63
  75. data/lib/rgeo/wkrep/wkt_parser.rb +172 -168
  76. metadata +17 -32
  77. 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 value should be an implementation of
92
- # CoordSys::SRSDatabase::Interface. If both this and an SRID are
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(opts_ = {})
116
- proj4_ = opts_[:proj4]
117
- coord_sys_ = opts_[:coord_sys]
118
- srid_ = opts_[:srid]
119
- if (!proj4_ || !coord_sys_) && srid_ && (db_ = opts_[:srs_database])
120
- entry_ = db_.get(srid_.to_i)
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
- proj4_ ||= entry_.proj4
123
- coord_sys_ ||= entry_.coord_sys
124
+ proj4 ||= entry_.proj4
125
+ coord_sys ||= entry_.coord_sys
124
126
  end
125
127
  end
126
- srid_ ||= coord_sys_.authority_code if coord_sys_
128
+ srid ||= coord_sys.authority_code if coord_sys
127
129
  Geographic::Factory.new("Spherical",
128
- has_z_coordinate: opts_[:has_z_coordinate],
129
- has_m_coordinate: opts_[:has_m_coordinate],
130
- proj4: proj4_ || _proj4_4055,
131
- coord_sys: coord_sys_ || _coordsys_4055,
132
- uses_lenient_assertions: opts_[:uses_lenient_assertions],
133
- buffer_resolution: opts_[:buffer_resolution],
134
- wkt_parser: opts_[:wkt_parser],
135
- wkb_parser: opts_[:wkb_parser],
136
- wkt_generator: opts_[:wkt_generator],
137
- wkb_generator: opts_[:wkb_generator],
138
- srid: (srid_ || 4055).to_i)
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(opts_ = {})
214
- factory_ = Geographic::Factory.new("Projected",
215
- proj4: _proj4_4326,
216
- coord_sys: _coordsys_4326,
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: opts_[:wkt_parser],
219
- wkb_parser: opts_[:wkb_parser],
220
- wkt_generator: opts_[:wkt_generator],
221
- wkb_generator: opts_[:wkb_generator],
222
- has_z_coordinate: opts_[:has_z_coordinate],
223
- has_m_coordinate: opts_[:has_m_coordinate])
224
- projector_ = Geographic::SimpleMercatorProjector.new(factory_,
225
- buffer_resolution: opts_[:buffer_resolution],
226
- lenient_multi_polygon_assertions: opts_[:lenient_multi_polygon_assertions],
227
- uses_lenient_assertions: opts_[:uses_lenient_assertions],
228
- has_z_coordinate: opts_[:has_z_coordinate],
229
- has_m_coordinate: opts_[:has_m_coordinate])
230
- factory_._set_projector(projector_)
231
- factory_
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 value should be an implementation of
306
- # CoordSys::SRSDatabase::Interface. If both this and an SRID are
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(opts_ = {})
348
+ def projected_factory(opts = {})
347
349
  CoordSys.check!(:proj4)
348
- db_ = opts_[:srs_database]
349
- if (projection_factory_ = opts_[:projection_factory])
350
+ db_ = opts[:srs_database]
351
+ if (projection_factory = opts[:projection_factory])
350
352
  # Get the projection coordinate systems from the given factory
351
- projection_proj4_ = projection_factory_.proj4
352
- unless projection_proj4_
353
- raise ::ArgumentError, "The :projection_factory does not have a proj4."
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
- projection_coord_sys_ = projection_factory_.coord_sys
356
- if projection_coord_sys_ && !projection_coord_sys_.is_a?(CoordSys::CS::ProjectedCoordinateSystem)
357
- raise ::ArgumentError, 'The :projection_factory\'s coord_sys is not a ProjectedCoordinateSystem.'
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
- proj4_ = opts_[:proj4]
361
- coord_sys_ = opts_[:coord_sys]
362
- srid_ = opts_[:srid]
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 (!proj4_ || !coord_sys_) && srid_ && db_
365
- entry_ = db_.get(srid_.to_i)
366
+ if (!proj4 || !coord_sys) && srid && db_
367
+ entry_ = db_.get(srid.to_i)
366
368
  if entry_
367
- proj4_ ||= entry_.proj4
368
- coord_sys_ ||= entry_.coord_sys
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
- proj4_ ||= projection_proj4_.get_geographic || _proj4_4326
373
- coord_sys_ ||= projection_coord_sys_.geographic_coordinate_system if projection_coord_sys_
374
- srid_ ||= coord_sys_.authority_code if coord_sys_
375
- srid_ ||= 4326
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
- factory_ = Geographic::Factory.new("Projected",
378
- proj4: proj4_,
379
- coord_sys: coord_sys_,
380
- srid: srid_.to_i,
381
- has_z_coordinate: projection_factory_.property(:has_z_coordinate),
382
- has_m_coordinate: projection_factory_.property(:has_m_coordinate),
383
- wkt_parser: opts_[:wkt_parser], wkt_generator: opts_[:wkt_generator],
384
- wkb_parser: opts_[:wkb_parser], wkb_generator: opts_[:wkb_generator])
385
- projector_ = Geographic::Proj4Projector.create_from_existing_factory(factory_,
386
- projection_factory_)
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
- projection_proj4_ = opts_[:projection_proj4]
390
- projection_coord_sys_ = opts_[:projection_coord_sys]
391
- projection_srid_ = opts_[:projection_srid]
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 (!projection_proj4_ || !projection_coord_sys_) && projection_srid_ && db_
394
- entry_ = db_.get(projection_srid_.to_i)
395
+ if (!projection_proj4 || !projection_coord_sys) && projection_srid && db_
396
+ entry_ = db_.get(projection_srid.to_i)
395
397
  if entry_
396
- projection_proj4_ ||= entry_.proj4
397
- projection_coord_sys_ ||= entry_.coord_sys
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 projection_proj4_
402
- raise ::ArgumentError, "Unable to determine the Proj4 for the projected coordinate system."
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 projection_proj4_.is_a?(::String) || projection_proj4_.is_a?(::Hash)
406
- actual_projection_proj4_ = CoordSys::Proj4.create(projection_proj4_)
407
- unless actual_projection_proj4_
408
- raise ::ArgumentError, "Bad proj4 syntax: #{projection_proj4_.inspect}"
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
- projection_proj4_ = actual_projection_proj4_
412
+ projection_proj4 = actual_projection_proj4
411
413
  end
412
- if projection_coord_sys_ && !projection_coord_sys_.is_a?(CoordSys::CS::ProjectedCoordinateSystem)
413
- raise ::ArgumentError, "The :projection_coord_sys is not a ProjectedCoordinateSystem."
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
- projection_srid_ ||= projection_coord_sys_.authority_code if projection_coord_sys_
417
+ projection_srid ||= projection_coord_sys.authority_code if projection_coord_sys
416
418
  # Determine geographic coordinate system. First check parameters.
417
- proj4_ = opts_[:proj4]
418
- coord_sys_ = opts_[:coord_sys]
419
- srid_ = opts_[:srid]
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 (!proj4_ || !coord_sys_) && srid_ && db_
422
- entry_ = db_.get(srid_.to_i)
423
+ if (!proj4 || !coord_sys) && srid && db_
424
+ entry_ = db_.get(srid.to_i)
423
425
  if entry_
424
- proj4_ ||= entry_.proj4
425
- coord_sys_ ||= entry_.coord_sys
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
- proj4_ ||= projection_proj4_.get_geographic || _proj4_4326
430
- coord_sys_ ||= projection_coord_sys_.geographic_coordinate_system if projection_coord_sys_
431
- srid_ ||= coord_sys_.authority_code if coord_sys_
432
- srid_ ||= 4326
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
- factory_ = Geographic::Factory.new("Projected",
435
- proj4: proj4_,
436
- coord_sys: coord_sys_,
437
- srid: srid_.to_i,
438
- has_z_coordinate: opts_[:has_z_coordinate],
439
- has_m_coordinate: opts_[:has_m_coordinate],
440
- wkt_parser: opts_[:wkt_parser], wkt_generator: opts_[:wkt_generator],
441
- wkb_parser: opts_[:wkb_parser], wkb_generator: opts_[:wkb_generator])
442
- projector_ = Geographic::Proj4Projector.create_from_proj4(factory_,
443
- projection_proj4_,
444
- srid: projection_srid_,
445
- coord_sys: projection_coord_sys_,
446
- buffer_resolution: opts_[:buffer_resolution],
447
- lenient_multi_polygon_assertions: opts_[:lenient_multi_polygon_assertions],
448
- uses_lenient_assertions: opts_[:uses_lenient_assertions],
449
- has_z_coordinate: opts_[:has_z_coordinate],
450
- has_m_coordinate: opts_[:has_m_coordinate],
451
- wkt_parser: opts_[:wkt_parser], wkt_generator: opts_[:wkt_generator],
452
- wkb_parser: opts_[:wkb_parser], wkb_generator: opts_[:wkb_generator])
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
- factory_._set_projector(projector_)
455
- factory_
456
+ factory.projector = projector
457
+ factory
456
458
  end
457
459
 
458
- def _proj4_4055 # :nodoc:
459
- unless defined?(@proj4_4055)
460
- @proj4_4055 = CoordSys.supported?(:proj4) && CoordSys::Proj4.create("+proj=longlat +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +no_defs")
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
- @proj4_4055
466
+ @proj44055
463
467
  end
464
468
 
465
- def _coordsys_4055 # :nodoc:
466
- unless defined?(@coordsys_4055)
467
- @coordsys_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"]]')
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
- @coordsys_4055
473
+ @coord_sys_4055
470
474
  end
471
475
 
472
- def _proj4_4326 # :nodoc:
473
- unless defined?(@proj4_4326)
474
- @proj4_4326 = CoordSys.supported?(:proj4) && CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
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
- @proj4_4326
480
+ @proj_4326
477
481
  end
478
482
 
479
- def _coordsys_4326 # :nodoc:
480
- unless defined?(@coordsys_4326)
481
- @coordsys_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"]]')
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
- @coordsys_4326
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(geography_factory_, projection_factory_)
11
- @geography_factory = geography_factory_
12
- @projection_factory = 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 _set_factories(geography_factory_, projection_factory_) # :nodoc:
16
- @geography_factory = geography_factory_
17
- @projection_factory = 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(geometry_)
21
- Feature.cast(geometry_, @projection_factory, :project)
22
+ def project(geometry)
23
+ Feature.cast(geometry, @projection_factory, :project)
22
24
  end
23
25
 
24
- def unproject(geometry_)
25
- Feature.cast(geometry_, @geography_factory, :project)
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(geography_factory_, projection_factory_)
40
- new(geography_factory_, projection_factory_)
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(geography_factory_, proj4_, opts_ = {})
44
- projection_factory_ = Cartesian.preferred_factory(proj4: proj4_,
45
- coord_sys: opts_[:coord_sys], srid: opts_[:srid],
46
- buffer_resolution: opts_[:buffer_resolution],
47
- lenient_multi_polygon_assertions: opts_[:lenient_multi_polygon_assertions],
48
- uses_lenient_assertions: opts_[:uses_lenient_assertions],
49
- has_z_coordinate: opts_[:has_z_coordinate],
50
- has_m_coordinate: opts_[:has_m_coordinate],
51
- wkt_parser: opts_[:wkt_parser], wkt_generator: opts_[:wkt_generator],
52
- wkb_parser: opts_[:wkb_parser], wkb_generator: opts_[:wkb_generator])
53
- new(geography_factory_, projection_factory_)
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