proj4rb 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +34 -8
- data/README.rdoc +24 -25
- data/Rakefile +1 -0
- data/lib/api/api.rb +118 -0
- data/lib/api/api_4_9.rb +31 -0
- data/lib/api/api_5_0.rb +301 -0
- data/lib/api/api_5_1.rb +7 -0
- data/lib/api/api_5_2.rb +5 -0
- data/lib/api/api_6_0.rb +42 -0
- data/lib/api/api_6_1.rb +5 -0
- data/lib/api/api_6_2.rb +7 -0
- data/lib/{area.rb → proj/area.rb} +32 -32
- data/lib/{config.rb → proj/config.rb} +69 -69
- data/lib/{context.rb → proj/context.rb} +102 -102
- data/lib/{coordinate.rb → proj/coordinate.rb} +197 -197
- data/lib/{crs.rb → proj/crs.rb} +204 -206
- data/lib/{ellipsoid.rb → proj/ellipsoid.rb} +41 -41
- data/lib/{error.rb → proj/error.rb} +17 -17
- data/lib/{operation.rb → proj/operation.rb} +42 -42
- data/lib/{pj_object.rb → proj/pj_object.rb} +80 -82
- data/lib/{point.rb → proj/point.rb} +72 -72
- data/lib/{prime_meridian.rb → proj/prime_meridian.rb} +39 -39
- data/lib/{projection.rb → proj/projection.rb} +206 -206
- data/lib/{transformation.rb → proj/transformation.rb} +60 -60
- data/lib/{unit.rb → proj/unit.rb} +53 -53
- data/lib/proj.rb +31 -31
- data/proj4rb.gemspec +5 -3
- data/test/context_test.rb +81 -81
- data/test/crs_test.rb +1 -1
- data/test/proj_test.rb +5 -5
- data/test/projection_test.rb +183 -181
- metadata +58 -22
@@ -1,197 +1,197 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Proj
|
4
|
-
# A four dimensional coordinate of double values.
|
5
|
-
#
|
6
|
-
# For most geographic Crses, the units will be in degrees.
|
7
|
-
class Coordinate
|
8
|
-
def self.from_coord(pj_coord)
|
9
|
-
result = self.allocate
|
10
|
-
result.instance_variable_set(:@coord, pj_coord)
|
11
|
-
result
|
12
|
-
end
|
13
|
-
|
14
|
-
# Creates a new coordinate.
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
#
|
18
|
-
# coord = Proj::Coordinate.new(:x => 1, :y => 2, :z => 3, :t => 4)
|
19
|
-
# coord = Proj::Coordinate.new(:u => 5, :v => 6, :w => 7, :t => 8)
|
20
|
-
# coord = Proj::Coordinate.new(:lam => 9, :phi => 10, :z => 11, :t => 12)
|
21
|
-
# coord = Proj::Coordinate.new(:s => 13, :a1 => 14, :a2 => 15)
|
22
|
-
# coord = Proj::Coordinate.new(:o => 16, :p => 17, :k => 18)
|
23
|
-
# coord = Proj::Coordinate.new(:e => 19, :n => 20, :u => 21)
|
24
|
-
|
25
|
-
def initialize(x: nil, y: nil, z: nil, t: nil,
|
26
|
-
u: nil, v: nil, w: nil, # t: nil
|
27
|
-
lam: nil, phi: nil, # z: nil, t: nil,
|
28
|
-
s: nil, a1: nil, a2: nil,
|
29
|
-
o: nil, p: nil, k: nil,
|
30
|
-
e: nil, n: nil) #u: nil
|
31
|
-
|
32
|
-
@coord = Api::PJ_COORD.new
|
33
|
-
|
34
|
-
keys = if x && y && z && t
|
35
|
-
[:x, :y, :z, :t]
|
36
|
-
elsif x && y && z
|
37
|
-
[:x, :y, :z]
|
38
|
-
elsif x && y
|
39
|
-
[:x, :y]
|
40
|
-
elsif u && v && w && t
|
41
|
-
[:u, :v, :w, :t]
|
42
|
-
elsif u && v && w
|
43
|
-
[:u, :v, :w]
|
44
|
-
elsif u && v
|
45
|
-
[:u, :v]
|
46
|
-
elsif lam && phi && z && t
|
47
|
-
[:lam, :phi, :z, :t]
|
48
|
-
elsif lam && phi && z
|
49
|
-
[:lam, :phi, :z]
|
50
|
-
elsif lam && phi
|
51
|
-
[:lam, :phi]
|
52
|
-
elsif s && a1 && a2
|
53
|
-
[:s, :a1, :a2]
|
54
|
-
elsif e && n && u
|
55
|
-
[:e, :n, :u]
|
56
|
-
elsif o && p && k
|
57
|
-
[:o, :p, :k]
|
58
|
-
end
|
59
|
-
|
60
|
-
coord_struct = @coord[:v]
|
61
|
-
keys.each_with_index do |key, index|
|
62
|
-
coord_struct[index] = binding.local_variable_get(key)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def to_ptr
|
67
|
-
@coord.to_ptr
|
68
|
-
end
|
69
|
-
|
70
|
-
# Returns x coordinate
|
71
|
-
#
|
72
|
-
# @return [Float]
|
73
|
-
def x
|
74
|
-
@coord[:v][0]
|
75
|
-
end
|
76
|
-
|
77
|
-
# Returns y coordinate
|
78
|
-
#
|
79
|
-
# @return [Float]
|
80
|
-
def y
|
81
|
-
@coord[:v][1]
|
82
|
-
end
|
83
|
-
|
84
|
-
# Returns z coordinate
|
85
|
-
#
|
86
|
-
# @return [Float]
|
87
|
-
def z
|
88
|
-
@coord[:v][2]
|
89
|
-
end
|
90
|
-
|
91
|
-
# Returns t coordinate
|
92
|
-
#
|
93
|
-
# @return [Float]
|
94
|
-
def t
|
95
|
-
@coord[:v][3]
|
96
|
-
end
|
97
|
-
|
98
|
-
# Returns u coordinate
|
99
|
-
#
|
100
|
-
# @return [Float]
|
101
|
-
# TODO - This could be u in uvw or enu. Going to ignore that
|
102
|
-
def u
|
103
|
-
@coord[:v][0]
|
104
|
-
end
|
105
|
-
|
106
|
-
# Returns v coordinate
|
107
|
-
#
|
108
|
-
# @return [Float]
|
109
|
-
def v
|
110
|
-
@coord[:v][1]
|
111
|
-
end
|
112
|
-
|
113
|
-
# Returns w coordinate
|
114
|
-
#
|
115
|
-
# @return [Float]
|
116
|
-
def w
|
117
|
-
@coord[:v][2]
|
118
|
-
end
|
119
|
-
|
120
|
-
# Returns lam coordinate
|
121
|
-
#
|
122
|
-
# @return [Float]
|
123
|
-
def lam
|
124
|
-
@coord[:v][0]
|
125
|
-
end
|
126
|
-
|
127
|
-
# Returns phi coordinate
|
128
|
-
#
|
129
|
-
# @return [Float]
|
130
|
-
def phi
|
131
|
-
@coord[:v][1]
|
132
|
-
end
|
133
|
-
|
134
|
-
# Returns o coordinate
|
135
|
-
#
|
136
|
-
# @return [Float]
|
137
|
-
def o
|
138
|
-
@coord[:v][0]
|
139
|
-
end
|
140
|
-
|
141
|
-
# Returns p coordinate
|
142
|
-
#
|
143
|
-
# @return [Float]
|
144
|
-
def p
|
145
|
-
@coord[:v][1]
|
146
|
-
end
|
147
|
-
|
148
|
-
# Returns k coordinate
|
149
|
-
#
|
150
|
-
# @return [Float]
|
151
|
-
def k
|
152
|
-
@coord[:v][3]
|
153
|
-
end
|
154
|
-
|
155
|
-
# Returns e coordinate
|
156
|
-
#
|
157
|
-
# @return [Float]
|
158
|
-
def e
|
159
|
-
@coord[:v][0]
|
160
|
-
end
|
161
|
-
|
162
|
-
# Returns n coordinate
|
163
|
-
#
|
164
|
-
# @return [Float]
|
165
|
-
def n
|
166
|
-
@coord[:v][1]
|
167
|
-
end
|
168
|
-
|
169
|
-
# Returns s coordinate
|
170
|
-
#
|
171
|
-
# @return [Float]
|
172
|
-
def s
|
173
|
-
@coord[:v][0]
|
174
|
-
end
|
175
|
-
|
176
|
-
# Returns a1 coordinate
|
177
|
-
#
|
178
|
-
# @return [Float]
|
179
|
-
def a1
|
180
|
-
@coord[:v][1]
|
181
|
-
end
|
182
|
-
|
183
|
-
# Returns a2 coordinate
|
184
|
-
#
|
185
|
-
# @return [Float]
|
186
|
-
def a2
|
187
|
-
@coord[:v][2]
|
188
|
-
end
|
189
|
-
|
190
|
-
# Returns nice printout of coordinate contents
|
191
|
-
#
|
192
|
-
# @return [String]
|
193
|
-
def to_s
|
194
|
-
"v0: #{self.x}, v1: #{self.y}, v2: #{self.z}, v3: #{self.t}"
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Proj
|
4
|
+
# A four dimensional coordinate of double values.
|
5
|
+
#
|
6
|
+
# For most geographic Crses, the units will be in degrees.
|
7
|
+
class Coordinate
|
8
|
+
def self.from_coord(pj_coord)
|
9
|
+
result = self.allocate
|
10
|
+
result.instance_variable_set(:@coord, pj_coord)
|
11
|
+
result
|
12
|
+
end
|
13
|
+
|
14
|
+
# Creates a new coordinate.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
#
|
18
|
+
# coord = Proj::Coordinate.new(:x => 1, :y => 2, :z => 3, :t => 4)
|
19
|
+
# coord = Proj::Coordinate.new(:u => 5, :v => 6, :w => 7, :t => 8)
|
20
|
+
# coord = Proj::Coordinate.new(:lam => 9, :phi => 10, :z => 11, :t => 12)
|
21
|
+
# coord = Proj::Coordinate.new(:s => 13, :a1 => 14, :a2 => 15)
|
22
|
+
# coord = Proj::Coordinate.new(:o => 16, :p => 17, :k => 18)
|
23
|
+
# coord = Proj::Coordinate.new(:e => 19, :n => 20, :u => 21)
|
24
|
+
|
25
|
+
def initialize(x: nil, y: nil, z: nil, t: nil,
|
26
|
+
u: nil, v: nil, w: nil, # t: nil
|
27
|
+
lam: nil, phi: nil, # z: nil, t: nil,
|
28
|
+
s: nil, a1: nil, a2: nil,
|
29
|
+
o: nil, p: nil, k: nil,
|
30
|
+
e: nil, n: nil) #u: nil
|
31
|
+
|
32
|
+
@coord = Api::PJ_COORD.new
|
33
|
+
|
34
|
+
keys = if x && y && z && t
|
35
|
+
[:x, :y, :z, :t]
|
36
|
+
elsif x && y && z
|
37
|
+
[:x, :y, :z]
|
38
|
+
elsif x && y
|
39
|
+
[:x, :y]
|
40
|
+
elsif u && v && w && t
|
41
|
+
[:u, :v, :w, :t]
|
42
|
+
elsif u && v && w
|
43
|
+
[:u, :v, :w]
|
44
|
+
elsif u && v
|
45
|
+
[:u, :v]
|
46
|
+
elsif lam && phi && z && t
|
47
|
+
[:lam, :phi, :z, :t]
|
48
|
+
elsif lam && phi && z
|
49
|
+
[:lam, :phi, :z]
|
50
|
+
elsif lam && phi
|
51
|
+
[:lam, :phi]
|
52
|
+
elsif s && a1 && a2
|
53
|
+
[:s, :a1, :a2]
|
54
|
+
elsif e && n && u
|
55
|
+
[:e, :n, :u]
|
56
|
+
elsif o && p && k
|
57
|
+
[:o, :p, :k]
|
58
|
+
end
|
59
|
+
|
60
|
+
coord_struct = @coord[:v]
|
61
|
+
keys.each_with_index do |key, index|
|
62
|
+
coord_struct[index] = binding.local_variable_get(key)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_ptr
|
67
|
+
@coord.to_ptr
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns x coordinate
|
71
|
+
#
|
72
|
+
# @return [Float]
|
73
|
+
def x
|
74
|
+
@coord[:v][0]
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns y coordinate
|
78
|
+
#
|
79
|
+
# @return [Float]
|
80
|
+
def y
|
81
|
+
@coord[:v][1]
|
82
|
+
end
|
83
|
+
|
84
|
+
# Returns z coordinate
|
85
|
+
#
|
86
|
+
# @return [Float]
|
87
|
+
def z
|
88
|
+
@coord[:v][2]
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns t coordinate
|
92
|
+
#
|
93
|
+
# @return [Float]
|
94
|
+
def t
|
95
|
+
@coord[:v][3]
|
96
|
+
end
|
97
|
+
|
98
|
+
# Returns u coordinate
|
99
|
+
#
|
100
|
+
# @return [Float]
|
101
|
+
# TODO - This could be u in uvw or enu. Going to ignore that
|
102
|
+
def u
|
103
|
+
@coord[:v][0]
|
104
|
+
end
|
105
|
+
|
106
|
+
# Returns v coordinate
|
107
|
+
#
|
108
|
+
# @return [Float]
|
109
|
+
def v
|
110
|
+
@coord[:v][1]
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns w coordinate
|
114
|
+
#
|
115
|
+
# @return [Float]
|
116
|
+
def w
|
117
|
+
@coord[:v][2]
|
118
|
+
end
|
119
|
+
|
120
|
+
# Returns lam coordinate
|
121
|
+
#
|
122
|
+
# @return [Float]
|
123
|
+
def lam
|
124
|
+
@coord[:v][0]
|
125
|
+
end
|
126
|
+
|
127
|
+
# Returns phi coordinate
|
128
|
+
#
|
129
|
+
# @return [Float]
|
130
|
+
def phi
|
131
|
+
@coord[:v][1]
|
132
|
+
end
|
133
|
+
|
134
|
+
# Returns o coordinate
|
135
|
+
#
|
136
|
+
# @return [Float]
|
137
|
+
def o
|
138
|
+
@coord[:v][0]
|
139
|
+
end
|
140
|
+
|
141
|
+
# Returns p coordinate
|
142
|
+
#
|
143
|
+
# @return [Float]
|
144
|
+
def p
|
145
|
+
@coord[:v][1]
|
146
|
+
end
|
147
|
+
|
148
|
+
# Returns k coordinate
|
149
|
+
#
|
150
|
+
# @return [Float]
|
151
|
+
def k
|
152
|
+
@coord[:v][3]
|
153
|
+
end
|
154
|
+
|
155
|
+
# Returns e coordinate
|
156
|
+
#
|
157
|
+
# @return [Float]
|
158
|
+
def e
|
159
|
+
@coord[:v][0]
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns n coordinate
|
163
|
+
#
|
164
|
+
# @return [Float]
|
165
|
+
def n
|
166
|
+
@coord[:v][1]
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns s coordinate
|
170
|
+
#
|
171
|
+
# @return [Float]
|
172
|
+
def s
|
173
|
+
@coord[:v][0]
|
174
|
+
end
|
175
|
+
|
176
|
+
# Returns a1 coordinate
|
177
|
+
#
|
178
|
+
# @return [Float]
|
179
|
+
def a1
|
180
|
+
@coord[:v][1]
|
181
|
+
end
|
182
|
+
|
183
|
+
# Returns a2 coordinate
|
184
|
+
#
|
185
|
+
# @return [Float]
|
186
|
+
def a2
|
187
|
+
@coord[:v][2]
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns nice printout of coordinate contents
|
191
|
+
#
|
192
|
+
# @return [String]
|
193
|
+
def to_s
|
194
|
+
"v0: #{self.x}, v1: #{self.y}, v2: #{self.z}, v3: #{self.t}"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|