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
  # Cartesian feature classes
@@ -12,8 +14,6 @@ module RGeo
12
14
  include RGeo::ImplHelper::BasicPointMethods
13
15
  include RGeo::Cartesian::GeometryMethods
14
16
  include RGeo::Cartesian::PointMethods
15
-
16
- Feature::MixinCollection::GLOBAL.for_type(Feature::Point).include_in_class(self, true)
17
17
  end
18
18
 
19
19
  class LineStringImpl # :nodoc:
@@ -22,8 +22,6 @@ module RGeo
22
22
  include RGeo::ImplHelper::BasicLineStringMethods
23
23
  include RGeo::Cartesian::GeometryMethods
24
24
  include RGeo::Cartesian::LineStringMethods
25
-
26
- Feature::MixinCollection::GLOBAL.for_type(Feature::LineString).include_in_class(self, true)
27
25
  end
28
26
 
29
27
  class LineImpl # :nodoc:
@@ -33,8 +31,6 @@ module RGeo
33
31
  include RGeo::ImplHelper::BasicLineMethods
34
32
  include RGeo::Cartesian::GeometryMethods
35
33
  include RGeo::Cartesian::LineStringMethods
36
-
37
- Feature::MixinCollection::GLOBAL.for_type(Feature::Line).include_in_class(self, true)
38
34
  end
39
35
 
40
36
  class LinearRingImpl # :nodoc:
@@ -44,8 +40,6 @@ module RGeo
44
40
  include RGeo::ImplHelper::BasicLinearRingMethods
45
41
  include RGeo::Cartesian::GeometryMethods
46
42
  include RGeo::Cartesian::LineStringMethods
47
-
48
- Feature::MixinCollection::GLOBAL.for_type(Feature::LinearRing).include_in_class(self, true)
49
43
  end
50
44
 
51
45
  class PolygonImpl # :nodoc:
@@ -53,8 +47,6 @@ module RGeo
53
47
  include RGeo::ImplHelper::BasicGeometryMethods
54
48
  include RGeo::ImplHelper::BasicPolygonMethods
55
49
  include RGeo::Cartesian::GeometryMethods
56
-
57
- Feature::MixinCollection::GLOBAL.for_type(Feature::Polygon).include_in_class(self, true)
58
50
  end
59
51
 
60
52
  class GeometryCollectionImpl # :nodoc:
@@ -62,8 +54,6 @@ module RGeo
62
54
  include RGeo::ImplHelper::BasicGeometryMethods
63
55
  include RGeo::ImplHelper::BasicGeometryCollectionMethods
64
56
  include RGeo::Cartesian::GeometryMethods
65
-
66
- Feature::MixinCollection::GLOBAL.for_type(Feature::GeometryCollection).include_in_class(self, true)
67
57
  end
68
58
 
69
59
  class MultiPointImpl # :nodoc:
@@ -72,8 +62,6 @@ module RGeo
72
62
  include RGeo::ImplHelper::BasicGeometryCollectionMethods
73
63
  include RGeo::ImplHelper::BasicMultiPointMethods
74
64
  include RGeo::Cartesian::GeometryMethods
75
-
76
- Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPoint).include_in_class(self, true)
77
65
  end
78
66
 
79
67
  class MultiLineStringImpl # :nodoc:
@@ -83,8 +71,6 @@ module RGeo
83
71
  include RGeo::ImplHelper::BasicMultiLineStringMethods
84
72
  include RGeo::Cartesian::GeometryMethods
85
73
  include RGeo::Cartesian::MultiLineStringMethods
86
-
87
- Feature::MixinCollection::GLOBAL.for_type(Feature::MultiLineString).include_in_class(self, true)
88
74
  end
89
75
 
90
76
  class MultiPolygonImpl # :nodoc:
@@ -93,8 +79,6 @@ module RGeo
93
79
  include RGeo::ImplHelper::BasicGeometryCollectionMethods
94
80
  include RGeo::ImplHelper::BasicMultiPolygonMethods
95
81
  include RGeo::Cartesian::GeometryMethods
96
-
97
- Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPolygon).include_in_class(self, true)
98
82
  end
99
83
  end
100
84
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -----------------------------------------------------------------------------
2
4
  #
3
5
  # Cartesian common methods
@@ -17,71 +19,67 @@ module RGeo
17
19
  end
18
20
 
19
21
  module PointMethods # :nodoc:
20
- def distance(rhs_)
21
- rhs_ = RGeo::Feature.cast(rhs_, @factory)
22
- case rhs_
22
+ def distance(rhs)
23
+ rhs = RGeo::Feature.cast(rhs, @factory)
24
+ case rhs
23
25
  when PointImpl
24
- dx_ = @x - rhs_.x
25
- dy_ = @y - rhs_.y
26
- ::Math.sqrt(dx_ * dx_ + dy_ * dy_)
26
+ dx = @x - rhs.x
27
+ dy = @y - rhs.y
28
+ Math.sqrt(dx * dx + dy * dy)
27
29
  else
28
30
  super
29
31
  end
30
32
  end
31
33
 
32
- def buffer(distance_)
33
- point_count_ = factory.property(:buffer_resolution) * 4
34
- angle_ = -::Math::PI * 2.0 / point_count_
35
- points_ = (0...point_count_).map do |i_|
36
- r_ = angle_ * i_
37
- factory.point(@x + distance_ * ::Math.cos(r_), @y + distance_ * ::Math.sin(r_))
34
+ def buffer(distance)
35
+ point_count = factory.property(:buffer_resolution) * 4
36
+ angle = -::Math::PI * 2.0 / point_count
37
+ points = (0...point_count).map do |i|
38
+ r = angle * i
39
+ factory.point(@x + distance * Math.cos(r), @y + distance * Math.sin(r))
38
40
  end
39
- factory.polygon(factory.linear_ring(points_))
41
+ factory.polygon(factory.linear_ring(points))
40
42
  end
41
43
  end
42
44
 
43
45
  module LineStringMethods # :nodoc:
44
- def _segments
45
- unless defined?(@segments)
46
- @segments = (0..num_points - 2).map do |i_|
47
- Segment.new(point_n(i_), point_n(i_ + 1))
48
- end
46
+ def segments
47
+ @segments ||= (0..num_points - 2).map do |i|
48
+ Segment.new(point_n(i), point_n(i + 1))
49
49
  end
50
- @segments
51
50
  end
52
51
 
53
52
  def is_simple?
54
- segs_ = _segments
55
- len_ = segs_.length
56
- return false if segs_.any?(&:degenerate?)
57
- return true if len_ == 1
58
- return segs_[0].s != segs_[1].e if len_ == 2
59
- segs_.each_with_index do |seg_, index_|
60
- nindex_ = index_ + 1
61
- nindex_ = nil if nindex_ == len_
62
- return false if nindex_ && seg_.contains_point?(segs_[nindex_].e)
63
- pindex_ = index_ - 1
64
- pindex_ = nil if pindex_ < 0
65
- return false if pindex_ && seg_.contains_point?(segs_[pindex_].s)
66
- next unless nindex_
67
- oindex_ = nindex_ + 1
68
- while oindex_ < len_
69
- oseg_ = segs_[oindex_]
70
- return false if !(index_ == 0 && oindex_ == len_ - 1 && seg_.s == oseg_.e) && seg_.intersects_segment?(oseg_)
71
- oindex_ += 1
53
+ len = segments.length
54
+ return false if segments.any?(&:degenerate?)
55
+ return true if len == 1
56
+ return segments[0].s != segments[1].e if len == 2
57
+ segments.each_with_index do |seg, index|
58
+ nindex = index + 1
59
+ nindex = nil if nindex == len
60
+ return false if nindex && seg.contains_point?(segments[nindex].e)
61
+ pindex = index - 1
62
+ pindex = nil if pindex < 0
63
+ return false if pindex && seg.contains_point?(segments[pindex].s)
64
+ next unless nindex
65
+ oindex = nindex + 1
66
+ while oindex < len
67
+ oseg = segments[oindex]
68
+ return false if !(index == 0 && oindex == len - 1 && seg.s == oseg.e) && seg.intersects_segment?(oseg)
69
+ oindex += 1
72
70
  end
73
71
  end
74
72
  true
75
73
  end
76
74
 
77
75
  def length
78
- _segments.inject(0.0) { |sum_, seg_| sum_ + seg_.length }
76
+ segments.inject(0.0) { |sum, seg| sum + seg.length }
79
77
  end
80
78
  end
81
79
 
82
80
  module MultiLineStringMethods # :nodoc:
83
81
  def length
84
- inject(0.0) { |sum_, geom_| sum_ + geom_.length }
82
+ inject(0.0) { |sum, geom| sum + geom.length }
85
83
  end
86
84
  end
87
85
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -----------------------------------------------------------------------------
2
4
  #
3
5
  # Cartesian toplevel interface
@@ -24,11 +26,11 @@ module RGeo
24
26
  # RGeo::Cartesian.simple_factory for details. Unsupported options
25
27
  # are ignored.
26
28
 
27
- def preferred_factory(opts_ = {})
29
+ def preferred_factory(opts = {})
28
30
  if RGeo::Geos.supported?
29
- RGeo::Geos.factory(opts_)
31
+ RGeo::Geos.factory(opts)
30
32
  else
31
- simple_factory(opts_)
33
+ simple_factory(opts)
32
34
  end
33
35
  end
34
36
  alias factory preferred_factory
@@ -102,8 +104,8 @@ module RGeo
102
104
  # Default is the empty hash, indicating the default configuration
103
105
  # for WKRep::WKBGenerator.
104
106
 
105
- def simple_factory(opts_ = {})
106
- Cartesian::Factory.new(opts_)
107
+ def simple_factory(opts = {})
108
+ Cartesian::Factory.new(opts)
107
109
  end
108
110
 
109
111
  # Returns a Feature::FactoryGenerator that creates preferred
@@ -114,8 +116,8 @@ module RGeo
114
116
  # an SRID and it will automatically fetch the appropriate Proj4
115
117
  # and CoordSys objects.
116
118
 
117
- def preferred_factory_generator(defaults_ = {})
118
- ::Proc.new { |c_| preferred_factory(defaults_.merge(c_)) }
119
+ def preferred_factory_generator(defaults = {})
120
+ proc { |c| preferred_factory(defaults.merge(c)) }
119
121
  end
120
122
  alias factory_generator preferred_factory_generator
121
123
 
@@ -127,8 +129,8 @@ module RGeo
127
129
  # an SRID and it will automatically fetch the appropriate Proj4
128
130
  # and CoordSys objects.
129
131
 
130
- def simple_factory_generator(defaults_ = {})
131
- ::Proc.new { |c_| simple_factory(defaults_.merge(c_)) }
132
+ def simple_factory_generator(defaults = {})
133
+ proc { |c| simple_factory(defaults.merge(c)) }
132
134
  end
133
135
  end
134
136
  end
@@ -1,9 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -----------------------------------------------------------------------------
2
4
  #
3
5
  # Coordinate systems for RGeo
4
6
  #
5
7
  # -----------------------------------------------------------------------------
6
8
 
9
+ require "rgeo/coord_sys/cs/factories"
10
+ require "rgeo/coord_sys/cs/entities"
11
+ require "rgeo/coord_sys/cs/wkt_parser"
12
+ require "rgeo/coord_sys/srs_database/entry"
13
+ require "rgeo/coord_sys/srs_database/url_reader"
14
+ require "rgeo/coord_sys/srs_database/sr_org"
15
+
7
16
  module RGeo
8
17
  # This module provides data structures and tools related to coordinate
9
18
  # systems and coordinate transforms. It comprises the following parts:
@@ -37,11 +46,3 @@ module RGeo
37
46
  end
38
47
  end
39
48
  end
40
-
41
- # Implementation files
42
- require "rgeo/coord_sys/cs/factories"
43
- require "rgeo/coord_sys/cs/entities"
44
- require "rgeo/coord_sys/cs/wkt_parser"
45
- require "rgeo/coord_sys/srs_database/interface.rb"
46
- require "rgeo/coord_sys/srs_database/url_reader.rb"
47
- require "rgeo/coord_sys/srs_database/sr_org.rb"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -----------------------------------------------------------------------------
2
4
  #
3
5
  # OGC CS objects for RGeo
@@ -148,8 +150,8 @@ module RGeo
148
150
  # Tests for equality. Two objects are defined as equal if they
149
151
  # have the same type (class) and the same WKT representation.
150
152
 
151
- def eql?(rhs_)
152
- rhs_.class == self.class && rhs_.to_wkt == to_wkt
153
+ def eql?(rhs)
154
+ rhs.class == self.class && rhs.to_wkt == to_wkt
153
155
  end
154
156
  alias == eql?
155
157
 
@@ -165,33 +167,25 @@ module RGeo
165
167
  to_wkt
166
168
  end
167
169
 
168
- # Computes the WKT representation. Options include:
170
+ # Return the WKT representation.
169
171
  #
170
- # [<tt>:standard_brackets</tt>]
171
- # If set to true, outputs parentheses rather than square
172
+ # <tt>:standard_brackets</tt>
173
+ # If true, outputs parentheses rather than square
172
174
  # brackets. Default is false.
173
-
174
- def to_wkt(opts_ = {})
175
- if opts_[:standard_brackets]
176
- @standard_wkt ||= _to_wkt("(", ")")
177
- else
178
- @square_wkt ||= _to_wkt("[", "]")
179
- end
180
- end
181
-
182
- def _to_wkt(open_, close_) # :nodoc:
183
- content_ = _wkt_content(open_, close_).map { |obj_| ",#{obj_}" }.join
175
+ def to_wkt(standard_brackets = false)
176
+ open, close = brackets(standard_brackets)
177
+ content = wkt_content(standard_brackets).map { |obj| ",#{obj}" }.join
184
178
  if defined?(@authority) && @authority
185
- authority_ = ",AUTHORITY#{open_}#{@authority.inspect},#{@authority_code.inspect}#{close_}"
179
+ authority = ",AUTHORITY#{open}#{@authority.inspect},#{@authority_code.inspect}#{close}"
186
180
  else
187
- authority_ = ""
181
+ authority = ""
188
182
  end
189
183
  if defined?(@extensions) && @extensions
190
- extensions_ = @extensions.map { |k_, v_| ",EXTENSION#{open_}#{k_.inspect},#{v_.inspect}#{close_}" }.join
184
+ extensions = @extensions.map { |k, v| ",EXTENSION#{open}#{k.inspect},#{v.inspect}#{close}" }.join
191
185
  else
192
- extensions_ = ""
186
+ extensions = ""
193
187
  end
194
- "#{_wkt_typename}#{open_}#{@name.inspect}#{content_}#{extensions_}#{authority_}#{close_}"
188
+ "#{wkt_typename}#{open}#{@name.inspect}#{content}#{extensions}#{authority}#{close}"
195
189
  end
196
190
 
197
191
  # Marshal support
@@ -200,38 +194,44 @@ module RGeo
200
194
  to_wkt
201
195
  end
202
196
 
203
- def marshal_load(data_) # :nodoc:
204
- data_ = data_["wkt"] if data_.is_a?(::Hash)
205
- temp_ = CS.create_from_wkt(data_)
206
- if temp_.class == self.class
207
- temp_.instance_variables.each do |iv_|
208
- instance_variable_set(iv_, temp_.instance_variable_get(iv_))
197
+ def marshal_load(data) # :nodoc:
198
+ data = data["wkt"] if data.is_a?(Hash)
199
+ temp = CS.create_from_wkt(data)
200
+ if temp.class == self.class
201
+ temp.instance_variables.each do |iv|
202
+ instance_variable_set(iv, temp.instance_variable_get(iv))
209
203
  end
210
204
  else
211
- raise ::TypeError, "Bad Marshal data"
205
+ raise TypeError, "Bad Marshal data"
212
206
  end
213
207
  end
214
208
 
215
209
  # Psych support
216
210
 
217
- def encode_with(coder_) # :nodoc:
218
- coder_["wkt"] = to_wkt
211
+ def encode_with(coder) # :nodoc:
212
+ coder["wkt"] = to_wkt
219
213
  end
220
214
 
221
- def init_with(coder_) # :nodoc:
222
- temp_ = CS.create_from_wkt(coder_.type == :scalar ? coder_.scalar : coder_["wkt"])
223
- if temp_.class == self.class
224
- temp_.instance_variables.each do |iv_|
225
- instance_variable_set(iv_, temp_.instance_variable_get(iv_))
215
+ def init_with(coder) # :nodoc:
216
+ temp = CS.create_from_wkt(coder.type == :scalar ? coder.scalar : coder["wkt"])
217
+ if temp.class == self.class
218
+ temp.instance_variables.each do |iv|
219
+ instance_variable_set(iv, temp.instance_variable_get(iv))
226
220
  end
227
221
  else
228
- raise ::TypeError, "Bad YAML data"
222
+ raise TypeError, "Bad YAML data"
229
223
  end
230
224
  end
231
225
 
232
226
  class << self
233
227
  private :new
234
228
  end
229
+
230
+ private
231
+
232
+ def brackets(standard)
233
+ standard ? %w[( )] : %w([ ])
234
+ end
235
235
  end
236
236
 
237
237
  # == OGC spec description
@@ -241,16 +241,16 @@ module RGeo
241
241
 
242
242
  class AxisInfo < Base
243
243
  # :stopdoc:
244
- NAMES_BY_VALUE = %w(OTHER NORTH SOUTH EAST WEST UP DOWN)
244
+ NAMES_BY_VALUE = %w[OTHER NORTH SOUTH EAST WEST UP DOWN].freeze
245
245
  # :startdoc:
246
246
 
247
- def initialize(name_, orientation_) # :nodoc:
248
- @name = name_
249
- case orientation_
250
- when ::String, ::Symbol
251
- @orientation = NAMES_BY_VALUE.index(orientation_.to_s.upcase).to_i
247
+ def initialize(name, orientation) # :nodoc:
248
+ @name = name
249
+ case orientation
250
+ when String, Symbol
251
+ @orientation = NAMES_BY_VALUE.index(orientation.to_s.upcase).to_i
252
252
  else
253
- @orientation = orientation_.to_i
253
+ @orientation = orientation.to_i
254
254
  end
255
255
  end
256
256
 
@@ -261,14 +261,10 @@ module RGeo
261
261
  # Gets enumerated value for orientation.
262
262
  attr_reader :orientation
263
263
 
264
- def _wkt_typename # :nodoc:
264
+ def wkt_typename
265
265
  "AXIS"
266
266
  end
267
267
 
268
- def _wkt_content(_open_, _close_) # :nodoc:
269
- [NAMES_BY_VALUE[@orientation]]
270
- end
271
-
272
268
  class << self
273
269
  # Creates an AxisInfo. you must pass the human readable name for
274
270
  # the axis (e.g. "X", "Y", "Long", "Lat", or other short string)
@@ -278,10 +274,16 @@ module RGeo
278
274
  # "<tt>UP</tt>", and "<tt>DOWN</tt>", or the corresponding
279
275
  # integer values 0-5.
280
276
 
281
- def create(name_, orientation_)
282
- new(name_, orientation_)
277
+ def create(name, orientation)
278
+ new(name, orientation)
283
279
  end
284
280
  end
281
+
282
+ private
283
+
284
+ def wkt_content(_)
285
+ [NAMES_BY_VALUE[@orientation]]
286
+ end
285
287
  end
286
288
 
287
289
  # == OGC spec description
@@ -293,9 +295,9 @@ module RGeo
293
295
  # system that the projected coordinate system is based on.
294
296
 
295
297
  class ProjectionParameter < Base
296
- def initialize(name_, value_) # :nodoc:
297
- @name = name_
298
- @value = value_.to_f
298
+ def initialize(name, value) # :nodoc:
299
+ @name = name
300
+ @value = value.to_f
299
301
  end
300
302
 
301
303
  # The parameter name.
@@ -304,21 +306,23 @@ module RGeo
304
306
  # The parameter value.
305
307
  attr_reader :value
306
308
 
307
- def _wkt_typename # :nodoc:
309
+ def wkt_typename
308
310
  "PARAMETER"
309
311
  end
310
312
 
311
- def _wkt_content(_open_, _close_) # :nodoc:
312
- [@value]
313
- end
314
-
315
313
  class << self
316
314
  # Create a parameter given the name and value.
317
315
 
318
- def create(name_, value_)
319
- new(name_, value_)
316
+ def create(name, value)
317
+ new(name, value)
320
318
  end
321
319
  end
320
+
321
+ private
322
+
323
+ def wkt_content(_)
324
+ [@value]
325
+ end
322
326
  end
323
327
 
324
328
  # == OGC spec description
@@ -329,14 +333,14 @@ module RGeo
329
333
  # points East, and the Z axis points North.
330
334
 
331
335
  class WGS84ConversionInfo < Base
332
- def initialize(dx_, dy_, dz_, ex_, ey_, ez_, ppm_) # :nodoc:
333
- @dx = dx_.to_f
334
- @dy = dy_.to_f
335
- @dz = dz_.to_f
336
- @ex = ex_.to_f
337
- @ey = ey_.to_f
338
- @ez = ez_.to_f
339
- @ppm = ppm_.to_f
336
+ def initialize(dx, dy, dz, ex, ey, ez, ppm) # :nodoc:
337
+ @dx = dx.to_f
338
+ @dy = dy.to_f
339
+ @dz = dz.to_f
340
+ @ex = ex.to_f
341
+ @ey = ey.to_f
342
+ @ez = ez.to_f
343
+ @ppm = ppm.to_f
340
344
  end
341
345
 
342
346
  # Bursa Wolf shift in meters.
@@ -360,8 +364,9 @@ module RGeo
360
364
  # Bursa Wolf scaling in in parts per million.
361
365
  attr_reader :ppm
362
366
 
363
- def _to_wkt(open_, close_) # :nodoc:
364
- "TOWGS84#{open_}#{@dx},#{@dy},#{@dz},#{@ex},#{@ey},#{@ez},#{@ppm}#{close_}"
367
+ def to_wkt(standard_brackets = false)
368
+ open, close = brackets(standard_brackets)
369
+ "TOWGS84#{open}#{@dx},#{@dy},#{@dz},#{@ex},#{@ey},#{@ez},#{@ppm}#{close}"
365
370
  end
366
371
 
367
372
  class << self
@@ -370,8 +375,8 @@ module RGeo
370
375
  # The Bursa Wolf shift should be in meters, the rotation in arc
371
376
  # seconds, and the scaling in parts per million.
372
377
 
373
- def create(dx_, dy_, dz_, ex_, ey_, ez_, ppm_)
374
- new(dx_, dy_, dz_, ex_, ey_, ez_, ppm_)
378
+ def create(dx, dy, dz, ex, ey, ez, ppm)
379
+ new(dx, dy, dz, ex, ey, ez, ppm)
375
380
  end
376
381
  end
377
382
  end
@@ -381,7 +386,7 @@ module RGeo
381
386
  # A base interface for metadata applicable to coordinate system
382
387
  # objects.
383
388
  #
384
- # The metadata items "Abbreviation"’, "Alias", "Authority",
389
+ # The metadata items "Abbreviation", "Alias", "Authority",
385
390
  # "AuthorityCode", "Name" and "Remarks" were specified in the Simple
386
391
  # Features interfaces, so they have been kept here.
387
392
  #
@@ -416,17 +421,15 @@ module RGeo
416
421
  # * <b>extensions</b>: a hash of extension keys and values
417
422
 
418
423
  class Info < Base
419
- def initialize(name_, authority_ = nil, authority_code_ = nil, abbreviation_ = nil, alias_ = nil, remarks_ = nil, extensions_ = nil) # :nodoc:
420
- @name = name_
421
- @authority = authority_ ? authority_.to_s : nil
422
- @authority_code = authority_code_ ? authority_code_.to_s : nil
423
- @abbreviation = abbreviation_ ? abbreviation_.to_s : nil
424
- @alias = alias_ ? alias_.to_s : nil
425
- @remarks = remarks_ ? remarks_.to_s : nil
424
+ def initialize(name, authority = nil, authority_code = nil, abbreviation = nil, init_alias = nil, remarks = nil, extensions = nil) # :nodoc:
425
+ @name = name
426
+ @authority = authority ? authority.to_s : nil
427
+ @authority_code = authority_code ? authority_code.to_s : nil
428
+ @abbreviation = abbreviation ? abbreviation.to_s : nil
429
+ @alias = init_alias ? init_alias.to_s : nil
430
+ @remarks = remarks ? remarks.to_s : nil
426
431
  @extensions = {}
427
- if extensions_
428
- extensions_.each { |k_, v_| @extensions[k_.to_s] = v_.to_s }
429
- end
432
+ extensions&.each { |k, v| @extensions[k.to_s] = v.to_s }
430
433
  end
431
434
 
432
435
  # Gets the abbreviation.
@@ -463,8 +466,8 @@ module RGeo
463
466
  # This is not part of the OGC spec, but it is supported because
464
467
  # some coordinate system databases (such as the spatial_ref_sys
465
468
  # table for PostGIS 2.0) include it.
466
- def extension(key_)
467
- @extensions[key_.to_s]
469
+ def extension(key)
470
+ @extensions[key.to_s]
468
471
  end
469
472
  end
470
473
 
@@ -479,9 +482,9 @@ module RGeo
479
482
  # not clear whether the data refers to a LinearUnit or AngularUnit.
480
483
 
481
484
  class Unit < Info
482
- def initialize(name_, conversion_factor_, *optional_) # :nodoc:
483
- super(name_, *optional_)
484
- @conversion_factor = conversion_factor_.to_f
485
+ def initialize(name, conversion_factor, *optional) # :nodoc:
486
+ super(name, *optional)
487
+ @conversion_factor = conversion_factor.to_f
485
488
  end
486
489
 
487
490
  # This field is not part of the OGC CT spec, but is part of the
@@ -489,24 +492,26 @@ module RGeo
489
492
  # i.e. LinearUnit#meters_per_unit or AngularUnit#radians_per_unit.
490
493
  attr_reader :conversion_factor
491
494
 
492
- def _wkt_typename # :nodoc:
495
+ def wkt_typename
493
496
  "UNIT"
494
497
  end
495
498
 
496
- def _wkt_content(_open_, _close_) # :nodoc:
497
- [@conversion_factor]
498
- end
499
-
500
499
  class << self
501
500
  # Create a bare Unit that does not specify whether it is a
502
501
  # LinearUnit or an AngularUnit, given a unit name and a
503
502
  # conversion factor. You may also provide the optional
504
503
  # parameters specified by the Info interface.
505
504
 
506
- def create(name_, conversion_factor_, *optional_)
507
- new(name_, conversion_factor_, *optional_)
505
+ def create(name, conversion_factor, *optional)
506
+ new(name, conversion_factor, *optional)
508
507
  end
509
508
  end
509
+
510
+ private
511
+
512
+ def wkt_content(_)
513
+ [@conversion_factor]
514
+ end
510
515
  end
511
516
 
512
517
  # == OGC spec description
@@ -526,8 +531,8 @@ module RGeo
526
531
  # in meters per unit. You may also provide the optional
527
532
  # parameters specified by the Info interface.
528
533
 
529
- def create(name_, meters_per_unit_, *optional_)
530
- new(name_, meters_per_unit_, *optional_)
534
+ def create(name, meters_per_unit, *optional)
535
+ new(name, meters_per_unit, *optional)
531
536
  end
532
537
  end
533
538
  end
@@ -549,8 +554,8 @@ module RGeo
549
554
  # factor in radians per unit. You may also provide the optional
550
555
  # parameters specified by the Info interface.
551
556
 
552
- def create(name_, radians_per_unit_, *optional_)
553
- new(name_, radians_per_unit_, *optional_)
557
+ def create(name, radians_per_unit, *optional)
558
+ new(name, radians_per_unit, *optional)
554
559
  end
555
560
  end
556
561
  end
@@ -560,10 +565,10 @@ module RGeo
560
565
  # A meridian used to take longitude measurements from.
561
566
 
562
567
  class PrimeMeridian < Info
563
- def initialize(name_, angular_unit_, longitude_, *optional_) # :nodoc:
564
- super(name_, *optional_)
565
- @angular_unit = angular_unit_
566
- @longitude = longitude_.to_f
568
+ def initialize(name, angular_unit, longitude, *optional) # :nodoc:
569
+ super(name, *optional)
570
+ @angular_unit = angular_unit
571
+ @longitude = longitude.to_f
567
572
  end
568
573
 
569
574
  # Returns the AngularUnits.
@@ -573,24 +578,26 @@ module RGeo
573
578
  # The longitude is expressed in this objects angular units.
574
579
  attr_reader :longitude
575
580
 
576
- def _wkt_typename # :nodoc:
581
+ def wkt_typename
577
582
  "PRIMEM"
578
583
  end
579
584
 
580
- def _wkt_content(_open_, _close_) # :nodoc:
581
- [@longitude]
582
- end
583
-
584
585
  class << self
585
586
  # Create a PrimeMeridian given a name, AngularUnits, and the
586
587
  # longitude relative to the Greenwich Meridian, expressed in
587
588
  # the AngularUnits. You may also provide the optional parameters
588
589
  # specified by the Info interface.
589
590
 
590
- def create(name_, angular_unit_, longitude_, *optional_)
591
- new(name_, angular_unit_, longitude_, *optional_)
591
+ def create(name, angular_unit, longitude, *optional)
592
+ new(name, angular_unit, longitude, *optional)
592
593
  end
593
594
  end
595
+
596
+ private
597
+
598
+ def wkt_content(_)
599
+ [@longitude]
600
+ end
594
601
  end
595
602
 
596
603
  # == OGC spec description
@@ -598,13 +605,13 @@ module RGeo
598
605
  # An approximation of the Earth's surface as a squashed sphere.
599
606
 
600
607
  class Ellipsoid < Info
601
- def initialize(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_) # :nodoc:
602
- super(name_, *optional_)
603
- @semi_major_axis = semi_major_axis_.to_f
604
- @semi_minor_axis = semi_minor_axis_.to_f
605
- @inverse_flattening = inverse_flattening_.to_f
606
- @ivf_definitive = ivf_definitive_ ? true : false
607
- @linear_unit = linear_unit_
608
+ def initialize(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional) # :nodoc:
609
+ super(name, *optional)
610
+ @semi_major_axis = semi_major_axis.to_f
611
+ @semi_minor_axis = semi_minor_axis.to_f
612
+ @inverse_flattening = inverse_flattening.to_f
613
+ @ivf_definitive = ivf_definitive ? true : false
614
+ @linear_unit = linear_unit
608
615
  end
609
616
 
610
617
  # Gets the equatorial radius. The returned length is expressed in
@@ -630,16 +637,12 @@ module RGeo
630
637
 
631
638
  # Returns the LinearUnit. The units of the semi-major and
632
639
  # semi-minor axis values.
633
- attr_reader :axis_unit
640
+ attr_reader :axisunit
634
641
 
635
- def _wkt_typename # :nodoc:
642
+ def wkt_typename
636
643
  "SPHEROID"
637
644
  end
638
645
 
639
- def _wkt_content(_open_, _close_) # :nodoc:
640
- [@semi_major_axis, @inverse_flattening]
641
- end
642
-
643
646
  class << self
644
647
  # Create an Ellipsoid given a name, semi-major and semi-minor
645
648
  # axes, the inverse flattening, a boolean indicating whether
@@ -648,8 +651,8 @@ module RGeo
648
651
  # may be set to nil. You may also provide the optional parameters
649
652
  # specified by the Info interface.
650
653
 
651
- def create(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_)
652
- new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_)
654
+ def create(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional)
655
+ new(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional)
653
656
  end
654
657
 
655
658
  # Create an Ellipsoid given a name, semi-major and semi-minor
@@ -658,12 +661,12 @@ module RGeo
658
661
  # The LinearUnit is optional and may be set to nil. You may also
659
662
  # provide the optional parameters specified by the Info interface.
660
663
 
661
- def create_ellipsoid(name_, semi_major_axis_, semi_minor_axis_, linear_unit_, *optional_)
662
- semi_major_axis_ = semi_major_axis_.to_f
663
- semi_minor_axis_ = semi_minor_axis_.to_f
664
- inverse_flattening_ = semi_major_axis_ / (semi_major_axis_ - semi_minor_axis_)
665
- inverse_flattening_ = 0.0 if inverse_flattening_.infinite?
666
- new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, false, linear_unit_, *optional_)
664
+ def create_ellipsoid(name, semi_major_axis, semi_minor_axis, linear_unit, *optional)
665
+ semi_major_axis = semi_major_axis.to_f
666
+ semi_minor_axis = semi_minor_axis.to_f
667
+ inverse_flattening = semi_major_axis / (semi_major_axis - semi_minor_axis)
668
+ inverse_flattening = 0.0 if inverse_flattening.infinite?
669
+ new(name, semi_major_axis, semi_minor_axis, inverse_flattening, false, linear_unit, *optional)
667
670
  end
668
671
 
669
672
  # Create an Ellipsoid given a name, semi-major axis, inverse
@@ -672,14 +675,20 @@ module RGeo
672
675
  # The LinearUnit is optional and may be set to nil. You may also
673
676
  # provide the optional parameters specified by the Info interface.
674
677
 
675
- def create_flattened_sphere(name_, semi_major_axis_, inverse_flattening_, linear_unit_, *optional_)
676
- semi_major_axis_ = semi_major_axis_.to_f
677
- inverse_flattening_ = inverse_flattening_.to_f
678
- semi_minor_axis_ = semi_major_axis_ - semi_major_axis_ / inverse_flattening_
679
- semi_minor_axis_ = semi_major_axis_ if semi_minor_axis_.infinite?
680
- new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, true, linear_unit_, *optional_)
678
+ def create_flattened_sphere(name, semi_major_axis, inverse_flattening, linear_unit, *optional)
679
+ semi_major_axis = semi_major_axis.to_f
680
+ inverse_flattening = inverse_flattening.to_f
681
+ semi_minor_axis = semi_major_axis - semi_major_axis / inverse_flattening
682
+ semi_minor_axis = semi_major_axis if semi_minor_axis.infinite?
683
+ new(name, semi_major_axis, semi_minor_axis, inverse_flattening, true, linear_unit, *optional)
681
684
  end
682
685
  end
686
+
687
+ private
688
+
689
+ def wkt_content(_)
690
+ [@semi_major_axis, @inverse_flattening]
691
+ end
683
692
  end
684
693
 
685
694
  # == OGC spec description
@@ -703,15 +712,17 @@ module RGeo
703
712
  # LocalDatum.
704
713
 
705
714
  class Datum < Info
706
- def initialize(name_, datum_type_, *optional_) # :nodoc:
707
- super(name_, *optional_)
708
- @datum_type = datum_type_.to_i
715
+ def initialize(name, datum_type, *optional) # :nodoc:
716
+ super(name, *optional)
717
+ @datum_type = datum_type.to_i
709
718
  end
710
719
 
711
720
  # Gets the type of the datum as an enumerated code.
712
721
  attr_reader :datum_type
713
722
 
714
- def _wkt_content(_open_, _close_) # :nodoc:
723
+ private
724
+
725
+ def wkt_content(_)
715
726
  []
716
727
  end
717
728
  end
@@ -721,23 +732,25 @@ module RGeo
721
732
  # Procedure used to measure vertical distances.
722
733
 
723
734
  class VerticalDatum < Datum
724
- def _wkt_typename # :nodoc:
735
+ def wkt_typename
725
736
  "VERT_DATUM"
726
737
  end
727
738
 
728
- def _wkt_content(_open_, _close_) # :nodoc:
729
- [@datum_type]
730
- end
731
-
732
739
  class << self
733
740
  # Create a VerticalDatum given a name and a datum type code.
734
741
  # You may also provide the optional parameters specified by the
735
742
  # Info interface.
736
743
 
737
- def create(name_, datum_type_, *optional_)
738
- new(name_, datum_type_, *optional_)
744
+ def create(name, datum_type, *optional)
745
+ new(name, datum_type, *optional)
739
746
  end
740
747
  end
748
+
749
+ private
750
+
751
+ def wkt_content(_)
752
+ [@datum_type]
753
+ end
741
754
  end
742
755
 
743
756
  # == OGC spec description
@@ -749,23 +762,25 @@ module RGeo
749
762
  # datum.
750
763
 
751
764
  class LocalDatum < Datum
752
- def _wkt_typename # :nodoc:
765
+ def wkt_typename
753
766
  "LOCAL_DATUM"
754
767
  end
755
768
 
756
- def _wkt_content(_open_, _close_) # :nodoc:
757
- [@datum_type]
758
- end
759
-
760
769
  class << self
761
770
  # Create a LocalDatum given a name and a datum type code. You
762
771
  # may also provide the optional parameters specified by the
763
772
  # Info interface.
764
773
 
765
- def create(name_, datum_type_, *optional_)
766
- new(name_, datum_type_, *optional_)
774
+ def create(name, datum_type, *optional)
775
+ new(name, datum_type, *optional)
767
776
  end
768
777
  end
778
+
779
+ private
780
+
781
+ def wkt_content(_)
782
+ [@datum_type]
783
+ end
769
784
  end
770
785
 
771
786
  # == OGC spec description
@@ -773,10 +788,10 @@ module RGeo
773
788
  # Procedure used to measure positions on the surface of the Earth.
774
789
 
775
790
  class HorizontalDatum < Datum
776
- def initialize(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_) # :nodoc:
777
- super(name_, datum_type_, *optional_)
778
- @ellipsoid = ellipsoid_
779
- @wgs84_parameters = wgs84_parameters_
791
+ def initialize(name, datum_type, ellipsoid, wgs84_parameters, *optional) # :nodoc:
792
+ super(name, datum_type, *optional)
793
+ @ellipsoid = ellipsoid
794
+ @wgs84_parameters = wgs84_parameters
780
795
  end
781
796
 
782
797
  # Returns the Ellipsoid.
@@ -787,26 +802,28 @@ module RGeo
787
802
  # (ex,ey,ez) in arc-seconds, and scaling in parts-per-million.
788
803
  attr_reader :wgs84_parameters
789
804
 
790
- def _wkt_typename # :nodoc:
805
+ def wkt_typename
791
806
  "DATUM"
792
807
  end
793
808
 
794
- def _wkt_content(open_, close_) # :nodoc:
795
- array_ = [@ellipsoid._to_wkt(open_, close_)]
796
- array_ << @wgs84_parameters._to_wkt(open_, close_) if @wgs84_parameters
797
- array_
798
- end
799
-
800
809
  class << self
801
810
  # Create a HorizontalDatum given a name, datum type code,
802
811
  # Ellipsoid, and WGS84ConversionInfo. The WGS84ConversionInfo
803
812
  # is optional and may be set to nil. You may also provide the
804
813
  # optional parameters specified by the Info interface.
805
814
 
806
- def create(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_)
807
- new(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_)
815
+ def create(name, datum_type, ellipsoid, wgs84_parameters, *optional)
816
+ new(name, datum_type, ellipsoid, wgs84_parameters, *optional)
808
817
  end
809
818
  end
819
+
820
+ private
821
+
822
+ def wkt_content(standard_brackets)
823
+ array = [@ellipsoid.to_wkt(standard_brackets)]
824
+ array << @wgs84_parameters.to_wkt(standard_brackets) if @wgs84_parameters
825
+ array
826
+ end
810
827
  end
811
828
 
812
829
  # == OGC spec description
@@ -814,10 +831,10 @@ module RGeo
814
831
  # A projection from geographic coordinates to projected coordinates.
815
832
 
816
833
  class Projection < Info
817
- def initialize(name_, class_name_, parameters_, *optional_) # :nodoc:
818
- super(name_, *optional_)
819
- @class_name = class_name_.to_s
820
- @parameters = parameters_ ? parameters_.dup : []
834
+ def initialize(name, class_name, parameters, *optional) # :nodoc:
835
+ super(name, *optional)
836
+ @class_name = class_name.to_s
837
+ @parameters = parameters ? parameters.dup : []
821
838
  end
822
839
 
823
840
  # Gets the projection classification name
@@ -832,33 +849,35 @@ module RGeo
832
849
 
833
850
  # Gets an inexed parameter of the projection.
834
851
 
835
- def get_parameter(index_)
836
- @parameters[index_]
852
+ def get_parameter(index)
853
+ @parameters[index]
837
854
  end
838
855
 
839
856
  # Iterates over the parameters of the projection.
840
857
 
841
- def each_parameter(&block_)
842
- @parameters.each(&block_)
858
+ def each_parameter(&block)
859
+ @parameters.each(&block)
843
860
  end
844
861
 
845
- def _wkt_typename # :nodoc:
862
+ def wkt_typename
846
863
  "PROJECTION"
847
864
  end
848
865
 
849
- def _wkt_content(_open_, _close_) # :nodoc:
850
- []
851
- end
852
-
853
866
  class << self
854
867
  # Create a Projection given a name, a projection class, and an
855
868
  # array of ProjectionParameter. You may also provide the
856
869
  # optional parameters specified by the Info interface.
857
870
 
858
- def create(name_, class_name_, parameters_, *optional_)
859
- new(name_, class_name_, parameters_, *optional_)
871
+ def create(name, class_name, parameters, *optional)
872
+ new(name, class_name, parameters, *optional)
860
873
  end
861
874
  end
875
+
876
+ private
877
+
878
+ def wkt_content(_)
879
+ []
880
+ end
862
881
  end
863
882
 
864
883
  # == OGC spec description
@@ -891,9 +910,9 @@ module RGeo
891
910
  # CompoundCoordinateSystem.
892
911
 
893
912
  class CoordinateSystem < Info
894
- def initialize(name_, dimension_, *optional_) # :nodoc:
895
- super(name_, *optional_)
896
- @dimension = dimension_.to_i
913
+ def initialize(name, dimension, *optional) # :nodoc:
914
+ super(name, *optional)
915
+ @dimension = dimension.to_i
897
916
  end
898
917
 
899
918
  # Dimension of the coordinate system
@@ -902,14 +921,14 @@ module RGeo
902
921
  # Gets axis details for dimension within coordinate system. Each
903
922
  # dimension in the coordinate system has a corresponding axis.
904
923
 
905
- def get_axis(_dimension_)
924
+ def get_axis(dimension)
906
925
  nil
907
926
  end
908
927
 
909
928
  # Gets units for dimension within coordinate system. Each
910
929
  # dimension in the coordinate system has corresponding units.
911
930
 
912
- def get_units(_dimension_)
931
+ def get_units(dimension)
913
932
  nil
914
933
  end
915
934
  end
@@ -923,10 +942,10 @@ module RGeo
923
942
  # coordinate system with a vertical datum.
924
943
 
925
944
  class CompoundCoordinateSystem < CoordinateSystem
926
- def initialize(name_, head_, tail_, *optional_) # :nodoc:
927
- super(name_, head_.dimension + tail_.dimension, *optional_)
928
- @head = head_
929
- @tail = tail_
945
+ def initialize(name, head, tail, *optional) # :nodoc:
946
+ super(name, head.dimension + tail.dimension, *optional)
947
+ @head = head
948
+ @tail = tail
930
949
  end
931
950
 
932
951
  # Gets first sub-coordinate system.
@@ -937,35 +956,37 @@ module RGeo
937
956
 
938
957
  # Implements CoordinateSystem#get_axis
939
958
 
940
- def get_axis(index_)
941
- hd_ = @head.dimension
942
- index_ < hd_ ? @head.get_axis(index_) : @tail.get_axis(index_ - hd_)
959
+ def get_axis(index)
960
+ hd = @head.dimension
961
+ index < hd ? @head.get_axis(index) : @tail.get_axis(index - hd)
943
962
  end
944
963
 
945
964
  # Implements CoordinateSystem#get_units
946
965
 
947
- def get_units(index_)
948
- hd_ = @head.dimension
949
- index_ < hd_ ? @head.get_units(index_) : @tail.get_units(index_ - hd_)
966
+ def get_units(index)
967
+ hd = @head.dimension
968
+ index < hd ? @head.get_units(index) : @tail.get_units(index - hd)
950
969
  end
951
970
 
952
- def _wkt_typename # :nodoc:
971
+ def wkt_typename
953
972
  "COMPD_CS"
954
973
  end
955
974
 
956
- def _wkt_content(open_, close_) # :nodoc:
957
- [@head._to_wkt(open_, close_), @tail._to_wkt(open_, close_)]
958
- end
959
-
960
975
  class << self
961
976
  # Create a CompoundCoordinateSystem given two sub-coordinate
962
977
  # systems. You may also provide the optional parameters
963
978
  # specified by the Info interface.
964
979
 
965
- def create(name_, head_, tail_, *optional_)
966
- new(name_, head_, tail_, *optional_)
980
+ def create(name, head, tail, *optional)
981
+ new(name, head, tail, *optional)
967
982
  end
968
983
  end
984
+
985
+ private
986
+
987
+ def wkt_content(standard_brackets)
988
+ [@head.to_wkt(standard_brackets), @tail.to_wkt(standard_brackets)]
989
+ end
969
990
  end
970
991
 
971
992
  # == OGC spec description
@@ -988,11 +1009,11 @@ module RGeo
988
1009
  # Transformation (CT) package.
989
1010
 
990
1011
  class LocalCoordinateSystem < CoordinateSystem
991
- def initialize(name_, local_datum_, unit_, axes_, *optional_) # :nodoc:
992
- super(name_, axes_.size, *optional_)
993
- @local_datum = local_datum_
994
- @unit = unit_
995
- @axes = axes_.dup
1012
+ def initialize(name, local_datum, unit, axes, *optional) # :nodoc:
1013
+ super(name, axes.size, *optional)
1014
+ @local_datum = local_datum
1015
+ @unit = unit
1016
+ @axes = axes.dup
996
1017
  end
997
1018
 
998
1019
  # Gets the local datum.
@@ -1000,34 +1021,39 @@ module RGeo
1000
1021
 
1001
1022
  # Implements CoordinateSystem#get_axis
1002
1023
 
1003
- def get_axis(index_)
1004
- @axes[index_]
1024
+ def get_axis(index)
1025
+ @axes[index]
1005
1026
  end
1006
1027
 
1007
1028
  # Implements CoordinateSystem#get_units
1008
1029
 
1009
- def get_units(_index_)
1030
+ def get_units(index)
1010
1031
  @unit
1011
1032
  end
1012
1033
 
1013
- def _wkt_typename # :nodoc:
1034
+ def wkt_typename
1014
1035
  "LOCAL_CS"
1015
1036
  end
1016
1037
 
1017
- def _wkt_content(open_, close_) # :nodoc:
1018
- [@local_datum._to_wkt(open_, close_), @unit._to_wkt(open_, close_)] + @axes.map { |ax_| ax_._to_wkt(open_, close_) }
1019
- end
1020
-
1021
1038
  class << self
1022
1039
  # Create a LocalCoordinateSystem given a name, a LocalDatum, a
1023
1040
  # Unit, and an array of at least one AxisInfo. You may also
1024
1041
  # provide the optional parameters specified by the Info
1025
1042
  # interface.
1026
1043
 
1027
- def create(name_, local_datum_, unit_, axes_, *optional_)
1028
- new(name_, local_datum_, unit_, axes_, *optional_)
1044
+ def create(name, local_datum, unit, axes, *optional)
1045
+ new(name, local_datum, unit, axes, *optional)
1029
1046
  end
1030
1047
  end
1048
+
1049
+ private
1050
+
1051
+ def wkt_content(standard_brackets)
1052
+ [
1053
+ @local_datum.to_wkt(standard_brackets),
1054
+ @unit.to_wkt(standard_brackets)
1055
+ ] + @axes.map { |ax| ax.to_wkt(standard_brackets) }
1056
+ end
1031
1057
  end
1032
1058
 
1033
1059
  # == OGC spec description
@@ -1040,14 +1066,14 @@ module RGeo
1040
1066
  # non-default values.
1041
1067
 
1042
1068
  class GeocentricCoordinateSystem < CoordinateSystem
1043
- def initialize(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_) # :nodoc:
1044
- super(name_, 3, *optional_)
1045
- @horizontal_datum = horizontal_datum_
1046
- @prime_meridian = prime_meridian_
1047
- @linear_unit = linear_unit_
1048
- @axis0 = axis0_
1049
- @axis1 = axis1_
1050
- @axis2 = axis2_
1069
+ def initialize(name, horizontal_datum, prime_meridian, linear_unit, axis0, axis1, axis2, *optional) # :nodoc:
1070
+ super(name, 3, *optional)
1071
+ @horizontal_datum = horizontal_datum
1072
+ @prime_meridian = prime_meridian
1073
+ @linear_unit = linear_unit
1074
+ @axis0 = axis0
1075
+ @axis1 = axis1
1076
+ @axis2 = axis2
1051
1077
  end
1052
1078
 
1053
1079
  # Returns the HorizontalDatum. The horizontal datum is used to
@@ -1064,28 +1090,20 @@ module RGeo
1064
1090
 
1065
1091
  # Implements CoordinateSystem#get_units
1066
1092
 
1067
- def get_units(_index_)
1093
+ def get_units(index)
1068
1094
  @linear_unit
1069
1095
  end
1070
1096
 
1071
1097
  # Implements CoordinateSystem#get_axis
1072
1098
 
1073
- def get_axis(index_)
1074
- [@axis0, @axis1, @axis2][index_]
1099
+ def get_axis(index)
1100
+ [@axis0, @axis1, @axis2][index]
1075
1101
  end
1076
1102
 
1077
- def _wkt_typename # :nodoc:
1103
+ def wkt_typename
1078
1104
  "GEOCCS"
1079
1105
  end
1080
1106
 
1081
- def _wkt_content(open_, close_) # :nodoc:
1082
- arr_ = [@horizontal_datum._to_wkt(open_, close_), @prime_meridian._to_wkt(open_, close_), @linear_unit._to_wkt(open_, close_)]
1083
- arr_ << @axis0._to_wkt(open_, close_) if @axis0
1084
- arr_ << @axis1._to_wkt(open_, close_) if @axis1
1085
- arr_ << @axis2._to_wkt(open_, close_) if @axis2
1086
- arr_
1087
- end
1088
-
1089
1107
  class << self
1090
1108
  # Create a GeocentricCoordinateSystem given a name, a
1091
1109
  # HorizontalDatum, a PrimeMeridian, a LinearUnit, and three
@@ -1093,10 +1111,24 @@ module RGeo
1093
1111
  # You may also provide the optional parameters specified by the
1094
1112
  # Info interface.
1095
1113
 
1096
- def create(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_)
1097
- new(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_)
1114
+ def create(name, horizontal_datum, prime_meridian, linear_unit, axis0, axis1, axis2, *optional)
1115
+ new(name, horizontal_datum, prime_meridian, linear_unit, axis0, axis1, axis2, *optional)
1098
1116
  end
1099
1117
  end
1118
+
1119
+ private
1120
+
1121
+ def wkt_content(standard_brackets)
1122
+ arr = [
1123
+ @horizontal_datum.to_wkt(standard_brackets),
1124
+ @prime_meridian.to_wkt(standard_brackets),
1125
+ @linear_unit.to_wkt(standard_brackets)
1126
+ ]
1127
+ arr << @axis0.to_wkt(standard_brackets) if @axis0
1128
+ arr << @axis1.to_wkt(standard_brackets) if @axis1
1129
+ arr << @axis2.to_wkt(standard_brackets) if @axis2
1130
+ arr
1131
+ end
1100
1132
  end
1101
1133
 
1102
1134
  # == OGC spec description
@@ -1105,11 +1137,11 @@ module RGeo
1105
1137
  # measurements.
1106
1138
 
1107
1139
  class VerticalCoordinateSystem < CoordinateSystem
1108
- def initialize(name_, vertical_datum_, vertical_unit_, axis_, *optional_) # :nodoc:
1109
- super(name_, 1, *optional_)
1110
- @vertical_datum = vertical_datum_
1111
- @vertical_unit = vertical_unit_
1112
- @axis = axis_
1140
+ def initialize(name, vertical_datum, vertical_unit, axis, *optional) # :nodoc:
1141
+ super(name, 1, *optional)
1142
+ @vertical_datum = vertical_datum
1143
+ @vertical_unit = vertical_unit
1144
+ @axis = axis
1113
1145
  end
1114
1146
 
1115
1147
  # Gets the vertical datum, which indicates the measurement method.
@@ -1121,36 +1153,38 @@ module RGeo
1121
1153
 
1122
1154
  # Implements CoordinateSystem#get_units
1123
1155
 
1124
- def get_units(_index_)
1156
+ def get_units(index)
1125
1157
  @vertical_unit
1126
1158
  end
1127
1159
 
1128
1160
  # Implements CoordinateSystem#get_axis
1129
1161
 
1130
- def get_axis(_index_)
1162
+ def get_axis(index)
1131
1163
  @axis
1132
1164
  end
1133
1165
 
1134
- def _wkt_typename # :nodoc:
1166
+ def wkt_typename
1135
1167
  "VERT_CS"
1136
1168
  end
1137
1169
 
1138
- def _wkt_content(open_, close_) # :nodoc:
1139
- arr_ = [@vertical_datum._to_wkt(open_, close_), @vertical_unit._to_wkt(open_, close_)]
1140
- arr_ << @axis._to_wkt(open_, close_) if @axis
1141
- arr_
1142
- end
1143
-
1144
1170
  class << self
1145
1171
  # Create a VerticalCoordinateSystem given a name, a
1146
1172
  # VerticalDatum, a LinearUnit, and an AxisInfo. The AxisInfo is
1147
1173
  # optional and may be nil. You may also provide the optional
1148
1174
  # parameters specified by the Info interface.
1149
1175
 
1150
- def create(name_, vertical_datum_, vertical_unit_, axis_, *optional_)
1151
- new(name_, vertical_datum_, vertical_unit_, axis_, *optional_)
1176
+ def create(name, vertical_datum, vertical_unit, axis, *optional)
1177
+ new(name, vertical_datum, vertical_unit, axis, *optional)
1152
1178
  end
1153
1179
  end
1180
+
1181
+ private
1182
+
1183
+ def wkt_content(standard_brackets)
1184
+ arr = [@vertical_datum.to_wkt(standard_brackets), @vertical_unit.to_wkt(standard_brackets)]
1185
+ arr << @axis.to_wkt(standard_brackets) if @axis
1186
+ arr
1187
+ end
1154
1188
  end
1155
1189
 
1156
1190
  # == OGC spec description
@@ -1164,9 +1198,9 @@ module RGeo
1164
1198
  # ProjectedCoordinateSystem.
1165
1199
 
1166
1200
  class HorizontalCoordinateSystem < CoordinateSystem
1167
- def initialize(name_, horizontal_datum_, *optional_) # :nodoc:
1168
- super(name_, 2, *optional_)
1169
- @horizontal_datum = horizontal_datum_
1201
+ def initialize(name, horizontal_datum, *optional) # :nodoc:
1202
+ super(name, 2, *optional)
1203
+ @horizontal_datum = horizontal_datum
1170
1204
  end
1171
1205
 
1172
1206
  # Returns the HorizontalDatum.
@@ -1182,12 +1216,12 @@ module RGeo
1182
1216
  # systems use degrees.
1183
1217
 
1184
1218
  class GeographicCoordinateSystem < HorizontalCoordinateSystem
1185
- def initialize(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_) # :nodoc:
1186
- super(name_, horizontal_datum_, *optional_)
1187
- @prime_meridian = prime_meridian_
1188
- @angular_unit = angular_unit_
1189
- @axis0 = axis0_
1190
- @axis1 = axis1_
1219
+ def initialize(name, angular_unit, horizontal_datum, prime_meridian, axis0, axis1, *optional) # :nodoc:
1220
+ super(name, horizontal_datum, *optional)
1221
+ @prime_meridian = prime_meridian
1222
+ @angular_unit = angular_unit
1223
+ @axis0 = axis0
1224
+ @axis1 = axis1
1191
1225
  end
1192
1226
 
1193
1227
  # Returns the PrimeMeridian.
@@ -1199,14 +1233,14 @@ module RGeo
1199
1233
 
1200
1234
  # Implements CoordinateSystem#get_units
1201
1235
 
1202
- def get_units(_index_)
1236
+ def get_units(index)
1203
1237
  @angular_unit
1204
1238
  end
1205
1239
 
1206
1240
  # Implements CoordinateSystem#get_axis
1207
1241
 
1208
- def get_axis(index_)
1209
- index_ == 1 ? @axis1 : @axis0
1242
+ def get_axis(index)
1243
+ index == 1 ? @axis1 : @axis0
1210
1244
  end
1211
1245
 
1212
1246
  # Gets the number of available conversions to WGS84 coordinates.
@@ -1221,21 +1255,14 @@ module RGeo
1221
1255
  # of interest. The first conversion (with index=0) should provide
1222
1256
  # acceptable accuracy over the largest possible area of interest.
1223
1257
 
1224
- def get_wgs84_conversion_info(_index_)
1258
+ def get_wgs84_conversion_info(index)
1225
1259
  @horizontal_datum.wgs84_parameters
1226
1260
  end
1227
1261
 
1228
- def _wkt_typename # :nodoc:
1262
+ def wkt_typename
1229
1263
  "GEOGCS"
1230
1264
  end
1231
1265
 
1232
- def _wkt_content(open_, close_) # :nodoc:
1233
- arr_ = [@horizontal_datum._to_wkt(open_, close_), @prime_meridian._to_wkt(open_, close_), @angular_unit._to_wkt(open_, close_)]
1234
- arr_ << @axis0._to_wkt(open_, close_) if @axis0
1235
- arr_ << @axis1._to_wkt(open_, close_) if @axis1
1236
- arr_
1237
- end
1238
-
1239
1266
  class << self
1240
1267
  # Create a GeographicCoordinateSystem, given a name, an
1241
1268
  # AngularUnit, a HorizontalDatum, a PrimeMeridian, and two
@@ -1243,10 +1270,23 @@ module RGeo
1243
1270
  # be set to nil. You may also provide the optional parameters
1244
1271
  # specified by the Info interface.
1245
1272
 
1246
- def create(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_)
1247
- new(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_)
1273
+ def create(name, angular_unit, horizontal_datum, prime_meridian, axis0, axis1, *optional)
1274
+ new(name, angular_unit, horizontal_datum, prime_meridian, axis0, axis1, *optional)
1248
1275
  end
1249
1276
  end
1277
+
1278
+ private
1279
+
1280
+ def wkt_content(standard_brackets)
1281
+ arr = [
1282
+ @horizontal_datum.to_wkt(standard_brackets),
1283
+ @prime_meridian.to_wkt(standard_brackets),
1284
+ @angular_unit.to_wkt(standard_brackets)
1285
+ ]
1286
+ arr << @axis0.to_wkt(standard_brackets) if @axis0
1287
+ arr << @axis1.to_wkt(standard_brackets) if @axis1
1288
+ arr
1289
+ end
1250
1290
  end
1251
1291
 
1252
1292
  # == OGC spec description
@@ -1254,13 +1294,13 @@ module RGeo
1254
1294
  # A 2D cartographic coordinate system.
1255
1295
 
1256
1296
  class ProjectedCoordinateSystem < HorizontalCoordinateSystem
1257
- def initialize(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_) # :nodoc:
1258
- super(name_, geographic_coordinate_system_.horizontal_datum, *optional_)
1259
- @geographic_coordinate_system = geographic_coordinate_system_
1260
- @projection = projection_
1261
- @linear_unit = linear_unit_
1262
- @axis0 = axis0_
1263
- @axis1 = axis1_
1297
+ def initialize(name, geographic_coordinate_system, projection, linear_unit, axis0, axis1, *optional) # :nodoc:
1298
+ super(name, geographic_coordinate_system.horizontal_datum, *optional)
1299
+ @geographic_coordinate_system = geographic_coordinate_system
1300
+ @projection = projection
1301
+ @linear_unit = linear_unit
1302
+ @axis0 = axis0
1303
+ @axis1 = axis1
1264
1304
  end
1265
1305
 
1266
1306
  # Returns the GeographicCoordinateSystem.
@@ -1275,29 +1315,20 @@ module RGeo
1275
1315
 
1276
1316
  # Implements CoordinateSystem#get_units
1277
1317
 
1278
- def get_units(_index_)
1318
+ def get_units(index)
1279
1319
  @linear_unit
1280
1320
  end
1281
1321
 
1282
1322
  # Implements CoordinateSystem#get_axis
1283
1323
 
1284
- def get_axis(index_)
1285
- index_ == 1 ? @axis1 : @axis0
1324
+ def get_axis(index)
1325
+ index == 1 ? @axis1 : @axis0
1286
1326
  end
1287
1327
 
1288
- def _wkt_typename # :nodoc:
1328
+ def wkt_typename
1289
1329
  "PROJCS"
1290
1330
  end
1291
1331
 
1292
- def _wkt_content(open_, close_) # :nodoc:
1293
- arr_ = [@geographic_coordinate_system._to_wkt(open_, close_), @projection._to_wkt(open_, close_)]
1294
- @projection.each_parameter { |param_| arr_ << param_._to_wkt(open_, close_) }
1295
- arr_ << @linear_unit._to_wkt(open_, close_)
1296
- arr_ << @axis0._to_wkt(open_, close_) if @axis0
1297
- arr_ << @axis1._to_wkt(open_, close_) if @axis1
1298
- arr_
1299
- end
1300
-
1301
1332
  class << self
1302
1333
  # Create a ProjectedCoordinateSystem given a name, a
1303
1334
  # GeographicCoordinateSystem, and Projection, a LinearUnit, and
@@ -1305,10 +1336,21 @@ module RGeo
1305
1336
  # may be set to nil. You may also provide the optional
1306
1337
  # parameters specified by the Info interface.
1307
1338
 
1308
- def create(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_)
1309
- new(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_)
1339
+ def create(name, geographic_coordinate_system, projection, linear_unit, axis0, axis1, *optional)
1340
+ new(name, geographic_coordinate_system, projection, linear_unit, axis0, axis1, *optional)
1310
1341
  end
1311
1342
  end
1343
+
1344
+ private
1345
+
1346
+ def wkt_content(standard_brackets)
1347
+ arr = [@geographic_coordinate_system.to_wkt(standard_brackets), @projection.to_wkt(standard_brackets)]
1348
+ @projection.each_parameter { |param| arr << param.to_wkt(standard_brackets) }
1349
+ arr << @linear_unit.to_wkt(standard_brackets)
1350
+ arr << @axis0.to_wkt(standard_brackets) if @axis0
1351
+ arr << @axis1.to_wkt(standard_brackets) if @axis1
1352
+ arr
1353
+ end
1312
1354
  end
1313
1355
  end
1314
1356
  end