rgeo 1.1.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/geos_c_impl/extconf.rb +5 -3
- data/ext/geos_c_impl/factory.c +4 -4
- data/ext/geos_c_impl/geometry.c +1 -1
- data/lib/rgeo.rb +2 -4
- data/lib/rgeo/cartesian.rb +6 -16
- data/lib/rgeo/cartesian/analysis.rb +22 -20
- data/lib/rgeo/cartesian/bounding_box.rb +83 -79
- data/lib/rgeo/cartesian/calculations.rb +40 -38
- data/lib/rgeo/cartesian/factory.rb +134 -169
- data/lib/rgeo/cartesian/feature_classes.rb +2 -18
- data/lib/rgeo/cartesian/feature_methods.rb +37 -39
- data/lib/rgeo/cartesian/interface.rb +11 -9
- data/lib/rgeo/coord_sys.rb +9 -8
- data/lib/rgeo/coord_sys/cs/entities.rb +345 -303
- data/lib/rgeo/coord_sys/cs/factories.rb +30 -28
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +128 -126
- data/lib/rgeo/coord_sys/srs_database/{interface.rb → entry.rb} +26 -32
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +19 -17
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +21 -19
- data/lib/rgeo/error.rb +3 -1
- data/lib/rgeo/feature.rb +23 -34
- data/lib/rgeo/feature/curve.rb +2 -0
- data/lib/rgeo/feature/factory.rb +15 -13
- data/lib/rgeo/feature/factory_generator.rb +7 -5
- data/lib/rgeo/feature/geometry.rb +31 -29
- data/lib/rgeo/feature/geometry_collection.rb +6 -4
- data/lib/rgeo/feature/line.rb +2 -0
- data/lib/rgeo/feature/line_string.rb +3 -1
- data/lib/rgeo/feature/linear_ring.rb +2 -0
- data/lib/rgeo/feature/multi_curve.rb +2 -0
- data/lib/rgeo/feature/multi_line_string.rb +2 -0
- data/lib/rgeo/feature/multi_point.rb +2 -0
- data/lib/rgeo/feature/multi_polygon.rb +2 -0
- data/lib/rgeo/feature/multi_surface.rb +2 -0
- data/lib/rgeo/feature/point.rb +2 -0
- data/lib/rgeo/feature/polygon.rb +3 -1
- data/lib/rgeo/feature/surface.rb +2 -0
- data/lib/rgeo/feature/types.rb +107 -103
- data/lib/rgeo/geographic.rb +17 -27
- data/lib/rgeo/geographic/factory.rb +154 -199
- data/lib/rgeo/geographic/interface.rb +141 -137
- data/lib/rgeo/geographic/proj4_projector.rb +28 -23
- data/lib/rgeo/geographic/projected_feature_classes.rb +2 -18
- data/lib/rgeo/geographic/projected_feature_methods.rb +59 -49
- data/lib/rgeo/geographic/projected_window.rb +4 -2
- data/lib/rgeo/geographic/simple_mercator_projector.rb +41 -39
- data/lib/rgeo/geographic/spherical_feature_classes.rb +2 -18
- data/lib/rgeo/geographic/spherical_feature_methods.rb +67 -67
- data/lib/rgeo/geographic/spherical_math.rb +81 -87
- data/lib/rgeo/geos.rb +23 -34
- data/lib/rgeo/geos/capi_factory.rb +106 -135
- data/lib/rgeo/geos/capi_feature_classes.rb +19 -37
- data/lib/rgeo/geos/ffi_factory.rb +276 -297
- data/lib/rgeo/geos/ffi_feature_classes.rb +2 -20
- data/lib/rgeo/geos/ffi_feature_methods.rb +170 -166
- data/lib/rgeo/geos/interface.rb +25 -23
- data/lib/rgeo/geos/utils.rb +47 -39
- data/lib/rgeo/geos/zm_factory.rb +171 -185
- data/lib/rgeo/geos/zm_feature_classes.rb +2 -20
- data/lib/rgeo/geos/zm_feature_methods.rb +76 -72
- data/lib/rgeo/impl_helper.rb +1 -11
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +72 -75
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +21 -23
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +57 -49
- data/lib/rgeo/impl_helper/basic_point_methods.rb +29 -25
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +31 -27
- data/lib/rgeo/impl_helper/math.rb +2 -0
- data/lib/rgeo/impl_helper/utils.rb +9 -15
- data/lib/rgeo/version.rb +3 -1
- data/lib/rgeo/wkrep.rb +20 -30
- data/lib/rgeo/wkrep/wkb_generator.rb +87 -84
- data/lib/rgeo/wkrep/wkb_parser.rb +93 -93
- data/lib/rgeo/wkrep/wkt_generator.rb +67 -63
- data/lib/rgeo/wkrep/wkt_parser.rb +172 -168
- metadata +17 -32
- data/lib/rgeo/feature/mixins.rb +0 -143
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -----------------------------------------------------------------------------
|
2
4
|
#
|
3
5
|
# 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(
|
21
|
-
|
22
|
-
case
|
22
|
+
def distance(rhs)
|
23
|
+
rhs = RGeo::Feature.cast(rhs, @factory)
|
24
|
+
case rhs
|
23
25
|
when PointImpl
|
24
|
-
|
25
|
-
|
26
|
-
|
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(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
factory.point(@x +
|
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(
|
41
|
+
factory.polygon(factory.linear_ring(points))
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
45
|
module LineStringMethods # :nodoc:
|
44
|
-
def
|
45
|
-
|
46
|
-
|
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
|
-
|
55
|
-
|
56
|
-
return
|
57
|
-
return
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
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) { |
|
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(
|
29
|
+
def preferred_factory(opts = {})
|
28
30
|
if RGeo::Geos.supported?
|
29
|
-
RGeo::Geos.factory(
|
31
|
+
RGeo::Geos.factory(opts)
|
30
32
|
else
|
31
|
-
simple_factory(
|
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(
|
106
|
-
Cartesian::Factory.new(
|
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(
|
118
|
-
|
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(
|
131
|
-
|
132
|
+
def simple_factory_generator(defaults = {})
|
133
|
+
proc { |c| simple_factory(defaults.merge(c)) }
|
132
134
|
end
|
133
135
|
end
|
134
136
|
end
|
data/lib/rgeo/coord_sys.rb
CHANGED
@@ -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?(
|
152
|
-
|
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
|
-
#
|
170
|
+
# Return the WKT representation.
|
169
171
|
#
|
170
|
-
#
|
171
|
-
# If
|
172
|
+
# <tt>:standard_brackets</tt>
|
173
|
+
# If true, outputs parentheses rather than square
|
172
174
|
# brackets. Default is false.
|
173
|
-
|
174
|
-
|
175
|
-
|
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
|
-
|
179
|
+
authority = ",AUTHORITY#{open}#{@authority.inspect},#{@authority_code.inspect}#{close}"
|
186
180
|
else
|
187
|
-
|
181
|
+
authority = ""
|
188
182
|
end
|
189
183
|
if defined?(@extensions) && @extensions
|
190
|
-
|
184
|
+
extensions = @extensions.map { |k, v| ",EXTENSION#{open}#{k.inspect},#{v.inspect}#{close}" }.join
|
191
185
|
else
|
192
|
-
|
186
|
+
extensions = ""
|
193
187
|
end
|
194
|
-
"#{
|
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(
|
204
|
-
|
205
|
-
|
206
|
-
if
|
207
|
-
|
208
|
-
instance_variable_set(
|
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
|
205
|
+
raise TypeError, "Bad Marshal data"
|
212
206
|
end
|
213
207
|
end
|
214
208
|
|
215
209
|
# Psych support
|
216
210
|
|
217
|
-
def encode_with(
|
218
|
-
|
211
|
+
def encode_with(coder) # :nodoc:
|
212
|
+
coder["wkt"] = to_wkt
|
219
213
|
end
|
220
214
|
|
221
|
-
def init_with(
|
222
|
-
|
223
|
-
if
|
224
|
-
|
225
|
-
instance_variable_set(
|
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
|
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
|
244
|
+
NAMES_BY_VALUE = %w[OTHER NORTH SOUTH EAST WEST UP DOWN].freeze
|
245
245
|
# :startdoc:
|
246
246
|
|
247
|
-
def initialize(
|
248
|
-
@name =
|
249
|
-
case
|
250
|
-
when
|
251
|
-
@orientation = NAMES_BY_VALUE.index(
|
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 =
|
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
|
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(
|
282
|
-
new(
|
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(
|
297
|
-
@name =
|
298
|
-
@value =
|
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
|
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(
|
319
|
-
new(
|
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(
|
333
|
-
@dx =
|
334
|
-
@dy =
|
335
|
-
@dz =
|
336
|
-
@ex =
|
337
|
-
@ey =
|
338
|
-
@ez =
|
339
|
-
@ppm =
|
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
|
364
|
-
|
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(
|
374
|
-
new(
|
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"
|
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(
|
420
|
-
@name =
|
421
|
-
@authority =
|
422
|
-
@authority_code =
|
423
|
-
@abbreviation =
|
424
|
-
@alias =
|
425
|
-
@remarks =
|
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
|
-
|
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(
|
467
|
-
@extensions[
|
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(
|
483
|
-
super(
|
484
|
-
@conversion_factor =
|
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
|
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(
|
507
|
-
new(
|
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(
|
530
|
-
new(
|
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(
|
553
|
-
new(
|
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(
|
564
|
-
super(
|
565
|
-
@angular_unit =
|
566
|
-
@longitude =
|
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
|
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(
|
591
|
-
new(
|
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(
|
602
|
-
super(
|
603
|
-
@semi_major_axis =
|
604
|
-
@semi_minor_axis =
|
605
|
-
@inverse_flattening =
|
606
|
-
@ivf_definitive =
|
607
|
-
@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 :
|
640
|
+
attr_reader :axisunit
|
634
641
|
|
635
|
-
def
|
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(
|
652
|
-
new(
|
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(
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
new(
|
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(
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
new(
|
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(
|
707
|
-
super(
|
708
|
-
@datum_type =
|
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
|
-
|
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
|
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(
|
738
|
-
new(
|
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
|
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(
|
766
|
-
new(
|
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(
|
777
|
-
super(
|
778
|
-
@ellipsoid =
|
779
|
-
@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
|
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(
|
807
|
-
new(
|
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(
|
818
|
-
super(
|
819
|
-
@class_name =
|
820
|
-
@parameters =
|
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(
|
836
|
-
@parameters[
|
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(&
|
842
|
-
@parameters.each(&
|
858
|
+
def each_parameter(&block)
|
859
|
+
@parameters.each(&block)
|
843
860
|
end
|
844
861
|
|
845
|
-
def
|
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(
|
859
|
-
new(
|
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(
|
895
|
-
super(
|
896
|
-
@dimension =
|
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(
|
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(
|
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(
|
927
|
-
super(
|
928
|
-
@head =
|
929
|
-
@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(
|
941
|
-
|
942
|
-
|
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(
|
948
|
-
|
949
|
-
|
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
|
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(
|
966
|
-
new(
|
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(
|
992
|
-
super(
|
993
|
-
@local_datum =
|
994
|
-
@unit =
|
995
|
-
@axes =
|
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(
|
1004
|
-
@axes[
|
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(
|
1030
|
+
def get_units(index)
|
1010
1031
|
@unit
|
1011
1032
|
end
|
1012
1033
|
|
1013
|
-
def
|
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(
|
1028
|
-
new(
|
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(
|
1044
|
-
super(
|
1045
|
-
@horizontal_datum =
|
1046
|
-
@prime_meridian =
|
1047
|
-
@linear_unit =
|
1048
|
-
@axis0 =
|
1049
|
-
@axis1 =
|
1050
|
-
@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(
|
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(
|
1074
|
-
[@axis0, @axis1, @axis2][
|
1099
|
+
def get_axis(index)
|
1100
|
+
[@axis0, @axis1, @axis2][index]
|
1075
1101
|
end
|
1076
1102
|
|
1077
|
-
def
|
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(
|
1097
|
-
new(
|
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(
|
1109
|
-
super(
|
1110
|
-
@vertical_datum =
|
1111
|
-
@vertical_unit =
|
1112
|
-
@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(
|
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(
|
1162
|
+
def get_axis(index)
|
1131
1163
|
@axis
|
1132
1164
|
end
|
1133
1165
|
|
1134
|
-
def
|
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(
|
1151
|
-
new(
|
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(
|
1168
|
-
super(
|
1169
|
-
@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(
|
1186
|
-
super(
|
1187
|
-
@prime_meridian =
|
1188
|
-
@angular_unit =
|
1189
|
-
@axis0 =
|
1190
|
-
@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(
|
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(
|
1209
|
-
|
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(
|
1258
|
+
def get_wgs84_conversion_info(index)
|
1225
1259
|
@horizontal_datum.wgs84_parameters
|
1226
1260
|
end
|
1227
1261
|
|
1228
|
-
def
|
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(
|
1247
|
-
new(
|
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(
|
1258
|
-
super(
|
1259
|
-
@geographic_coordinate_system =
|
1260
|
-
@projection =
|
1261
|
-
@linear_unit =
|
1262
|
-
@axis0 =
|
1263
|
-
@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(
|
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(
|
1285
|
-
|
1324
|
+
def get_axis(index)
|
1325
|
+
index == 1 ? @axis1 : @axis0
|
1286
1326
|
end
|
1287
1327
|
|
1288
|
-
def
|
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(
|
1309
|
-
new(
|
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
|