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.
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
  # OGC CS factory for RGeo
@@ -40,31 +42,31 @@ module RGeo
40
42
  # Create a CompoundCoordinateSystem from a name, and two
41
43
  # constituent coordinate systems.
42
44
 
43
- def create_compound_coordinate_system(name_, head_, tail_)
44
- CompoundCoordinateSystem.create(name_, head_, tail_)
45
+ def create_compound_coordinate_system(name, head, tail)
46
+ CompoundCoordinateSystem.create(name, head, tail)
45
47
  end
46
48
 
47
49
  # Create an Ellipsoid from a name, semi-major axis, and semi-minor
48
50
  # axis. You can also provide a LinearUnit, but this is optional
49
51
  # and may be set to nil.
50
52
 
51
- def create_ellipsoid(name_, semi_major_axis_, semi_minor_axis_, linear_unit_)
52
- Ellipsoid.create_ellipsoid(name_, semi_major_axis_, semi_minor_axis_, linear_unit_)
53
+ def create_ellipsoid(name, semi_major_axis, semi_minor_axis, linear_unit)
54
+ Ellipsoid.create_ellipsoid(name, semi_major_axis, semi_minor_axis, linear_unit)
53
55
  end
54
56
 
55
57
  # Create an Ellipsoid from a name, semi-major axis, and an inverse
56
58
  # flattening factor. You can also provide a LinearUnit, but this
57
59
  # is optional and may be set to nil.
58
60
 
59
- def create_flattened_sphere(name_, semi_major_axis_, inverse_flattening_, linear_unit_)
60
- Ellipsoid.create_flattened_sphere(name_, semi_major_axis_, inverse_flattening_, linear_unit_)
61
+ def create_flattened_sphere(name, semi_major_axis, inverse_flattening, linear_unit)
62
+ Ellipsoid.create_flattened_sphere(name, semi_major_axis, inverse_flattening, linear_unit)
61
63
  end
62
64
 
63
65
  # Create any object given the OGC WKT format. Raises
64
66
  # Error::ParseError if a syntax error is encounterred.
65
67
 
66
- def create_from_wkt(str_)
67
- WKTParser.new(str_).parse
68
+ def create_from_wkt(str)
69
+ WKTParser.new(str).parse
68
70
  end
69
71
 
70
72
  # Create a GeographicCoordinateSystem, given a name, an
@@ -72,36 +74,36 @@ module RGeo
72
74
  # AxisInfo objects. The AxisInfo objects are optional and may be
73
75
  # set to nil.
74
76
 
75
- def create_geographic_coordinate_system(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_)
76
- GeographicCoordinateSystem.create(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_)
77
+ def create_geographic_coordinate_system(name, angular_unit, horizontal_datum, prime_meridian, axis0, axis1)
78
+ GeographicCoordinateSystem.create(name, angular_unit, horizontal_datum, prime_meridian, axis0, axis1)
77
79
  end
78
80
 
79
81
  # Create a HorizontalDatum given a name, a horizontal datum type
80
82
  # code, an Ellipsoid, and a WGS84ConversionInfo. The
81
83
  # WGS84ConversionInfo is optional and may be set to nil.
82
84
 
83
- def create_horizontal_datum(name_, horizontal_datum_type_, ellipsoid_, to_wgs84_)
84
- HorizontalDatum.create(name_, horizontal_datum_type_, ellipsoid_, to_wgs84_)
85
+ def create_horizontal_datum(name, horizontal_datum_type, ellipsoid, to_wgs84)
86
+ HorizontalDatum.create(name, horizontal_datum_type, ellipsoid, to_wgs84)
85
87
  end
86
88
 
87
89
  # Create a LocalCoordinateSystem given a name, a LocalDatum, a
88
90
  # Unit, and an array of at least one AxisInfo.
89
91
 
90
- def create_local_coordinate_system(name_, datum_, unit_, axes_)
91
- LocalCoordinateSystem.create(name_, datum_, unit_, axes_)
92
+ def create_local_coordinate_system(name, datum, unit, axes)
93
+ LocalCoordinateSystem.create(name, datum, unit, axes)
92
94
  end
93
95
 
94
96
  # Create a LocalDatum given a name and a local datum type code.
95
97
 
96
- def create_local_datum(_name_, local_datum_type_)
97
- LocalDatum.create(name, local_datum_type_)
98
+ def create_local_datum(_name, local_datum_type)
99
+ LocalDatum.create(name, local_datum_type)
98
100
  end
99
101
 
100
102
  # Create a PrimeMeridian given a name, an AngularUnit, and a
101
103
  # longitude offset.
102
104
 
103
- def create_prime_meridian(_name_, angular_unit_, longitude_)
104
- PrimeMeridian.create(name, angular_unit_, longitude_)
105
+ def create_prime_meridian(_name, angular_unit, longitude)
106
+ PrimeMeridian.create(name, angular_unit, longitude)
105
107
  end
106
108
 
107
109
  # Create a ProjectedCoordinateSystem given a name, a
@@ -109,29 +111,29 @@ module RGeo
109
111
  # two AxisInfo objects. The AxisInfo objects are optional and may
110
112
  # be set to nil.
111
113
 
112
- def create_projected_coordinate_system(name_, gcs_, projection_, linear_unit_, axis0_, axis1_)
113
- ProjectedCoordinateSystem.create(name_, gcs_, projection_, linear_unit_, axis0_, axis1_)
114
+ def create_projected_coordinate_system(name, gcs, projection, linear_unit, axis0, axis1)
115
+ ProjectedCoordinateSystem.create(name, gcs, projection, linear_unit, axis0, axis1)
114
116
  end
115
117
 
116
118
  # Create a Projection given a name, a projection class, and an
117
119
  # array of ProjectionParameter.
118
120
 
119
- def create_projection(name_, wkt_projection_class_, parameters_)
120
- Projection.create(name_, wkt_projection_class_, parameters_)
121
+ def create_projection(name, wkt_projection_class, parameters)
122
+ Projection.create(name, wkt_projection_class, parameters)
121
123
  end
122
124
 
123
125
  # Create a VerticalCoordinateSystem given a name, a VerticalDatum,
124
126
  # a VerticalUnit, and an AxisInfo. The AxisInfo is optional and
125
127
  # may be nil.
126
128
 
127
- def create_vertical_coordinate_system(name_, vertical_datum_, vertical_unit_, axis_)
128
- VerticalCoordinateSystem.create(name_, vertical_datum_, vertical_unit_, axis_)
129
+ def create_vertical_coordinate_system(name, vertical_datum, vertical_unit, axis)
130
+ VerticalCoordinateSystem.create(name, vertical_datum, vertical_unit, axis)
129
131
  end
130
132
 
131
133
  # Create a VerticalDatum given a name ane a datum type code.
132
134
 
133
- def create_vertical_datum(name_, vertical_datum_type_)
134
- VerticalDatum.create(name_, vertical_datum_type_)
135
+ def create_vertical_datum(name, vertical_datum_type)
136
+ VerticalDatum.create(name, vertical_datum_type)
135
137
  end
136
138
  end
137
139
 
@@ -139,8 +141,8 @@ module RGeo
139
141
  # Parsees OGC WKT format and returns the object created. Raises
140
142
  # Error::ParseError if a syntax error is encounterred.
141
143
 
142
- def create_from_wkt(str_)
143
- WKTParser.new(str_).parse
144
+ def create_from_wkt(str)
145
+ WKTParser.new(str).parse
144
146
  end
145
147
  end
146
148
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -----------------------------------------------------------------------------
2
4
  #
3
5
  # OGC CS wkt parser for RGeo
@@ -8,141 +10,141 @@ module RGeo
8
10
  module CoordSys
9
11
  module CS
10
12
  class WKTParser # :nodoc:
11
- def initialize(str_)
12
- @scanner = ::StringScanner.new(str_)
13
+ def initialize(str)
14
+ @scanner = StringScanner.new(str)
13
15
  next_token
14
16
  end
15
17
 
16
- def parse(containing_type_ = nil) # :nodoc:
18
+ def parse(containing_type = nil) # :nodoc:
17
19
  if @cur_token.is_a?(QuotedString) ||
18
- @cur_token.is_a?(::Numeric) ||
19
- (containing_type_ == "AXIS" && @cur_token.is_a?(TypeString))
20
- value_ = @cur_token
20
+ @cur_token.is_a?(Numeric) ||
21
+ (containing_type == "AXIS" && @cur_token.is_a?(TypeString))
22
+ value = @cur_token
21
23
  next_token
22
- return value_
24
+ return value
23
25
  end
24
26
  unless @cur_token.is_a?(TypeString)
25
27
  raise Error::ParseError("Found token #{@cur_token} when we expected a value")
26
28
  end
27
- type_ = @cur_token
29
+ type = @cur_token
28
30
  next_token
29
- consume_token_type(:begin)
30
- args_ = ArgumentList.new
31
- args_ << parse(type_)
31
+ consume_tokentype(:begin)
32
+ args = ArgumentList.new
33
+ args << parse(type)
32
34
  loop do
33
35
  break unless @cur_token == :comma
34
36
  next_token
35
- args_ << parse(type_)
37
+ args << parse(type)
36
38
  end
37
- consume_token_type(:end)
38
- obj_ = nil
39
- case type_
39
+ consume_tokentype(:end)
40
+ obj = nil
41
+ case type
40
42
  when "AUTHORITY"
41
- obj_ = AuthorityClause.new(args_.shift(QuotedString), args_.shift(QuotedString))
43
+ obj = AuthorityClause.new(args.shift(QuotedString), args.shift(QuotedString))
42
44
  when "EXTENSION"
43
- obj_ = ExtensionClause.new(args_.shift(QuotedString), args_.shift(QuotedString))
45
+ obj = ExtensionClause.new(args.shift(QuotedString), args.shift(QuotedString))
44
46
  when "AXIS"
45
- obj_ = AxisInfo.create(args_.shift(QuotedString), args_.shift(TypeString))
47
+ obj = AxisInfo.create(args.shift(QuotedString), args.shift(TypeString))
46
48
  when "TOWGS84"
47
- bursa_wolf_params_ = args_.find_all(::Numeric)
48
- unless bursa_wolf_params_.size == 7
49
- raise Error::ParseError("Expected 7 Bursa Wolf parameters but found #{bursa_wolf_params_.size}")
49
+ bursa_wolf_params = args.find_all(Numeric)
50
+ unless bursa_wolf_params.size == 7
51
+ raise Error::ParseError("Expected 7 Bursa Wolf parameters but found #{bursa_wolf_params.size}")
50
52
  end
51
- obj_ = WGS84ConversionInfo.create(*bursa_wolf_params_)
53
+ obj = WGS84ConversionInfo.create(*bursa_wolf_params)
52
54
  when "UNIT"
53
- case containing_type_
55
+ case containing_type
54
56
  when "GEOCCS", "VERT_CS", "PROJCS", "SPHEROID"
55
- klass_ = LinearUnit
57
+ klass = LinearUnit
56
58
  when "GEOGCS"
57
- klass_ = AngularUnit
59
+ klass = AngularUnit
58
60
  else
59
- klass_ = Unit
61
+ klass = Unit
60
62
  end
61
- obj_ = klass_.create(args_.shift(QuotedString), args_.shift(::Numeric), *args_.create_optionals)
63
+ obj = klass.create(args.shift(QuotedString), args.shift(Numeric), *args.create_optionals)
62
64
  when "PARAMETER"
63
- obj_ = ProjectionParameter.create(args_.shift(QuotedString), args_.shift(::Numeric))
65
+ obj = ProjectionParameter.create(args.shift(QuotedString), args.shift(Numeric))
64
66
  when "PRIMEM"
65
- obj_ = PrimeMeridian.create(args_.shift(QuotedString), nil, args_.shift(::Numeric), *args_.create_optionals)
67
+ obj = PrimeMeridian.create(args.shift(QuotedString), nil, args.shift(Numeric), *args.create_optionals)
66
68
  when "SPHEROID"
67
- obj_ = Ellipsoid.create_flattened_sphere(args_.shift(QuotedString), args_.shift(::Numeric), args_.shift(::Numeric), args_.find_first(LinearUnit), *args_.create_optionals)
69
+ obj = Ellipsoid.create_flattened_sphere(args.shift(QuotedString), args.shift(Numeric), args.shift(Numeric), args.find_first(LinearUnit), *args.create_optionals)
68
70
  when "PROJECTION"
69
- name_ = args_.shift(QuotedString)
70
- obj_ = Projection.create(name_, name_, args_.find_all(ProjectionParameter), *args_.create_optionals)
71
+ name = args.shift(QuotedString)
72
+ obj = Projection.create(name, name, args.find_all(ProjectionParameter), *args.create_optionals)
71
73
  when "DATUM"
72
- name_ = args_.shift(QuotedString)
73
- ellipsoid_ = args_.find_first(Ellipsoid)
74
- to_wgs84_ = args_.find_first(WGS84ConversionInfo)
75
- obj_ = HorizontalDatum.create(name_, HD_GEOCENTRIC, ellipsoid_, to_wgs84_, *args_.create_optionals)
74
+ name = args.shift(QuotedString)
75
+ ellipsoid = args.find_first(Ellipsoid)
76
+ to_wgs84 = args.find_first(WGS84ConversionInfo)
77
+ obj = HorizontalDatum.create(name, HD_GEOCENTRIC, ellipsoid, to_wgs84, *args.create_optionals)
76
78
  when "VERT_DATUM"
77
- obj_ = VerticalDatum.create(args_.shift(QuotedString), args_.shift(::Numeric), *args_.create_optionals)
79
+ obj = VerticalDatum.create(args.shift(QuotedString), args.shift(Numeric), *args.create_optionals)
78
80
  when "LOCAL_DATUM"
79
- obj_ = LocalDatum.create(args_.shift(QuotedString), args_.shift(::Numeric), *args_.create_optionals)
81
+ obj = LocalDatum.create(args.shift(QuotedString), args.shift(Numeric), *args.create_optionals)
80
82
  when "COMPD_CS"
81
- obj_ = CompoundCoordinateSystem.create(args_.shift(QuotedString), args_.shift(CoordinateSystem), args_.shift(CoordinateSystem), *args_.create_optionals)
83
+ obj = CompoundCoordinateSystem.create(args.shift(QuotedString), args.shift(CoordinateSystem), args.shift(CoordinateSystem), *args.create_optionals)
82
84
  when "LOCAL_CS"
83
- name_ = args_.shift(QuotedString)
84
- local_datum_ = args_.find_first(LocalDatum)
85
- unit_ = args_.find_first(Unit)
86
- axes_ = args_.find_all(AxisInfo)
87
- unless axes_.size > 0
85
+ name = args.shift(QuotedString)
86
+ local_datum = args.find_first(LocalDatum)
87
+ unit = args.find_first(Unit)
88
+ axes = args.find_all(AxisInfo)
89
+ unless axes.size > 0
88
90
  raise Error::ParseError("Expected at least one AXIS in a LOCAL_CS")
89
91
  end
90
- obj_ = LocalCoordinateSystem.create(name_, local_datum_, unit_, axes_, *args_.create_optionals)
92
+ obj = LocalCoordinateSystem.create(name, local_datum, unit, axes, *args.create_optionals)
91
93
  when "GEOCCS"
92
- name_ = args_.shift(QuotedString)
93
- horizontal_datum_ = args_.find_first(HorizontalDatum)
94
- prime_meridian_ = args_.find_first(PrimeMeridian)
95
- linear_unit_ = args_.find_first(LinearUnit)
96
- axes_ = args_.find_all(AxisInfo)
97
- unless axes_.size == 0 || axes_.size == 3
94
+ name = args.shift(QuotedString)
95
+ horizontal_datum = args.find_first(HorizontalDatum)
96
+ prime_meridian = args.find_first(PrimeMeridian)
97
+ linear_unit = args.find_first(LinearUnit)
98
+ axes = args.find_all(AxisInfo)
99
+ unless axes.size == 0 || axes.size == 3
98
100
  raise Error::ParseError("GEOCCS must contain either 0 or 3 AXIS parameters")
99
101
  end
100
- obj_ = GeocentricCoordinateSystem.create(name_, horizontal_datum_, prime_meridian_, linear_unit_, axes_[0], axes_[1], axes_[2], *args_.create_optionals)
102
+ obj = GeocentricCoordinateSystem.create(name, horizontal_datum, prime_meridian, linear_unit, axes[0], axes[1], axes[2], *args.create_optionals)
101
103
  when "VERT_CS"
102
- name_ = args_.shift(QuotedString)
103
- vertical_datum_ = args_.find_first(VerticalDatum)
104
- linear_unit_ = args_.find_first(LinearUnit)
105
- axis_ = args_.find_first(AxisInfo)
106
- obj_ = VerticalCoordinateSystem.create(name_, vertical_datum_, linear_unit_, axis_, *args_.create_optionals)
104
+ name = args.shift(QuotedString)
105
+ vertical_datum = args.find_first(VerticalDatum)
106
+ linear_unit = args.find_first(LinearUnit)
107
+ axis = args.find_first(AxisInfo)
108
+ obj = VerticalCoordinateSystem.create(name, vertical_datum, linear_unit, axis, *args.create_optionals)
107
109
  when "GEOGCS"
108
- name_ = args_.shift(QuotedString)
109
- horizontal_datum_ = args_.find_first(HorizontalDatum)
110
- prime_meridian_ = args_.find_first(PrimeMeridian)
111
- angular_unit_ = args_.find_first(AngularUnit)
112
- axes_ = args_.find_all(AxisInfo)
113
- unless axes_.size == 0 || axes_.size == 2
110
+ name = args.shift(QuotedString)
111
+ horizontal_datum = args.find_first(HorizontalDatum)
112
+ prime_meridian = args.find_first(PrimeMeridian)
113
+ angular_unit = args.find_first(AngularUnit)
114
+ axes = args.find_all(AxisInfo)
115
+ unless axes.size == 0 || axes.size == 2
114
116
  raise Error::ParseError("GEOGCS must contain either 0 or 2 AXIS parameters")
115
117
  end
116
- obj_ = GeographicCoordinateSystem.create(name_, angular_unit_, horizontal_datum_, prime_meridian_, axes_[0], axes_[1], *args_.create_optionals)
118
+ obj = GeographicCoordinateSystem.create(name, angular_unit, horizontal_datum, prime_meridian, axes[0], axes[1], *args.create_optionals)
117
119
  when "PROJCS"
118
- name_ = args_.shift(QuotedString)
119
- geographic_coordinate_system_ = args_.find_first(GeographicCoordinateSystem)
120
- projection_ = args_.find_first(Projection)
121
- parameters_ = args_.find_all(ProjectionParameter)
122
- projection_.instance_variable_get(:@parameters).concat(parameters_)
123
- linear_unit_ = args_.find_first(LinearUnit)
124
- axes_ = args_.find_all(AxisInfo)
125
- unless axes_.size == 0 || axes_.size == 2
120
+ name = args.shift(QuotedString)
121
+ geographic_coordinate_system = args.find_first(GeographicCoordinateSystem)
122
+ projection = args.find_first(Projection)
123
+ parameters = args.find_all(ProjectionParameter)
124
+ projection.instance_variable_get(:@parameters).concat(parameters)
125
+ linear_unit = args.find_first(LinearUnit)
126
+ axes = args.find_all(AxisInfo)
127
+ unless axes.size == 0 || axes.size == 2
126
128
  raise Error::ParseError("PROJCS must contain either 0 or 2 AXIS parameters")
127
129
  end
128
- obj_ = ProjectedCoordinateSystem.create(name_, geographic_coordinate_system_, projection_, linear_unit_, axes_[0], axes_[1], *args_.create_optionals)
130
+ obj = ProjectedCoordinateSystem.create(name, geographic_coordinate_system, projection, linear_unit, axes[0], axes[1], *args.create_optionals)
129
131
  else
130
- raise Error::ParseError, "Unrecognized type: #{type_}"
132
+ raise Error::ParseError, "Unrecognized type: #{type}"
131
133
  end
132
- args_.assert_empty
133
- obj_
134
+ args.assert_empty
135
+ obj
134
136
  end
135
137
 
136
- def consume_token_type(type_) # :nodoc:
137
- expect_token_type(type_)
138
- tok_ = @cur_token
138
+ def consume_tokentype(type) # :nodoc:
139
+ expect_tokentype(type)
140
+ tok = @cur_token
139
141
  next_token
140
- tok_
142
+ tok
141
143
  end
142
144
 
143
- def expect_token_type(type_) # :nodoc:
144
- unless type_ === @cur_token
145
- raise Error::ParseError, "#{type_.inspect} expected but #{@cur_token.inspect} found."
145
+ def expect_tokentype(type) # :nodoc:
146
+ unless type === @cur_token
147
+ raise Error::ParseError, "#{type.inspect} expected but #{@cur_token.inspect} found."
146
148
  end
147
149
  end
148
150
 
@@ -168,11 +170,11 @@ module RGeo
168
170
  @cur_token = nil
169
171
  else
170
172
  @scanner.scan_until(/[^\s\(\)\[\],"]+/)
171
- token_ = @scanner.matched
172
- if token_ =~ /^[-+]?(\d+(\.\d*)?|\.\d+)(e[-+]?\d+)?$/
173
- @cur_token = token_.to_f
173
+ token = @scanner.matched
174
+ if token =~ /^[-+]?(\d+(\.\d*)?|\.\d+)(e[-+]?\d+)?$/
175
+ @cur_token = token.to_f
174
176
  else
175
- raise Error::ParseError, "Bad token: #{token_.inspect}"
177
+ raise Error::ParseError, "Bad token: #{token.inspect}"
176
178
  end
177
179
  end
178
180
  @cur_token
@@ -180,16 +182,16 @@ module RGeo
180
182
 
181
183
  attr_reader :cur_token
182
184
 
183
- class QuotedString < ::String # :nodoc:
185
+ class QuotedString < String # :nodoc:
184
186
  end
185
187
 
186
- class TypeString < ::String # :nodoc:
188
+ class TypeString < String # :nodoc:
187
189
  end
188
190
 
189
191
  class AuthorityClause # :nodoc:
190
- def initialize(name_, code_) # :nodoc:
191
- @name = name_
192
- @code = code_
192
+ def initialize(name, code) # :nodoc:
193
+ @name = name
194
+ @code = code
193
195
  end
194
196
 
195
197
  def to_a # :nodoc:
@@ -198,9 +200,9 @@ module RGeo
198
200
  end
199
201
 
200
202
  class ExtensionClause # :nodoc:
201
- def initialize(key_, value_) # :nodoc:
202
- @key = key_
203
- @value = value_
203
+ def initialize(key, value) # :nodoc:
204
+ @key = key
205
+ @value = value
204
206
  end
205
207
 
206
208
  attr_reader :key # :nodoc:
@@ -208,62 +210,62 @@ module RGeo
208
210
  end
209
211
 
210
212
  class ArgumentList # :nodoc:
211
- def initialize # :nodoc:
213
+ def initialize # :nodoc:
212
214
  @values = []
213
215
  end
214
216
 
215
- def <<(value_) # :nodoc:
216
- @values << value_
217
+ def <<(value) # :nodoc:
218
+ @values << value
217
219
  end
218
220
 
219
221
  def assert_empty # :nodoc:
220
222
  if @values.size > 0
221
- names_ = @values.map do |val_|
222
- val_.is_a?(Base) ? val_._wkt_typename : val_.inspect
223
+ names = @values.map do |val|
224
+ val.is_a?(Base) ? val.wkt_typename : val.inspect
223
225
  end
224
- raise Error::ParseError, "#{@values.size} unexpected arguments: #{names_.join(', ')}"
226
+ raise Error::ParseError, "#{@values.size} unexpected arguments: #{names.join(', ')}"
225
227
  end
226
228
  end
227
229
 
228
- def find_first(klass_) # :nodoc:
229
- @values.each_with_index do |val_, index_|
230
- if val_.is_a?(klass_)
231
- @values.slice!(index_)
232
- return val_
230
+ def find_first(klass) # :nodoc:
231
+ @values.each_with_index do |val, index|
232
+ if val.is_a?(klass)
233
+ @values.slice!(index)
234
+ return val
233
235
  end
234
236
  end
235
237
  nil
236
238
  end
237
239
 
238
- def find_all(klass_) # :nodoc:
239
- results_ = []
240
- nvalues_ = []
241
- @values.each do |val_|
242
- if val_.is_a?(klass_)
243
- results_ << val_
240
+ def find_all(klass) # :nodoc:
241
+ results = []
242
+ nvalues = []
243
+ @values.each do |val|
244
+ if val.is_a?(klass)
245
+ results << val
244
246
  else
245
- nvalues_ << val_
247
+ nvalues << val
246
248
  end
247
249
  end
248
- @values = nvalues_
249
- results_
250
+ @values = nvalues
251
+ results
250
252
  end
251
253
 
252
- def create_optionals # :nodoc:
253
- hash_ = {}
254
- find_all(ExtensionClause).each { |ec_| hash_[ec_.key] = ec_.value }
255
- (find_first(AuthorityClause) || [nil, nil]).to_a + [nil, nil, nil, hash_]
254
+ def create_optionals # :nodoc:
255
+ hash = {}
256
+ find_all(ExtensionClause).each { |ec| hash[ec.key] = ec.value }
257
+ (find_first(AuthorityClause) || [nil, nil]).to_a + [nil, nil, nil, hash]
256
258
  end
257
259
 
258
- def shift(klass_ = nil) # :nodoc:
259
- val_ = @values.shift
260
- unless val_
261
- raise Error::ParseError, "No arguments left... expected #{klass_}"
260
+ def shift(klass = nil) # :nodoc:
261
+ val = @values.shift
262
+ unless val
263
+ raise Error::ParseError, "No arguments left... expected #{klass}"
262
264
  end
263
- if klass_ && !val_.is_a?(klass_)
264
- raise Error::ParseError, "Expected #{klass_} but got #{val_.class}"
265
+ if klass && !val.is_a?(klass)
266
+ raise Error::ParseError, "Expected #{klass} but got #{val.class}"
265
267
  end
266
- val_
268
+ val
267
269
  end
268
270
  end
269
271
  end