proj4rb 3.0.0 → 4.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 +26 -15
- data/README.rdoc +82 -44
- data/Rakefile +27 -27
- data/lib/api/api.rb +96 -118
- data/lib/api/api_5_0.rb +331 -300
- data/lib/api/api_5_1.rb +6 -6
- data/lib/api/api_5_2.rb +4 -4
- data/lib/api/api_6_0.rb +116 -14
- data/lib/api/api_6_1.rb +4 -4
- data/lib/api/api_6_2.rb +9 -6
- data/lib/api/api_6_3.rb +6 -0
- data/lib/api/api_7_0.rb +68 -0
- data/lib/api/api_7_1.rb +73 -0
- data/lib/api/api_7_2.rb +14 -0
- data/lib/api/api_8_0.rb +6 -0
- data/lib/api/api_8_1.rb +24 -0
- data/lib/api/api_8_2.rb +6 -0
- data/lib/api/api_9_1.rb +7 -0
- data/lib/api/api_9_2.rb +9 -0
- data/lib/api/api_experimental.rb +196 -0
- data/lib/proj/area.rb +73 -32
- data/lib/proj/axis_info.rb +44 -0
- data/lib/proj/bounds.rb +13 -0
- data/lib/proj/context.rb +174 -28
- data/lib/proj/conversion.rb +92 -0
- data/lib/proj/coordinate.rb +281 -197
- data/lib/proj/coordinate_operation_mixin.rb +381 -0
- data/lib/proj/coordinate_system.rb +137 -0
- data/lib/proj/crs.rb +672 -204
- data/lib/proj/crs_info.rb +47 -0
- data/lib/proj/database.rb +305 -0
- data/lib/proj/datum.rb +32 -0
- data/lib/proj/datum_ensemble.rb +34 -0
- data/lib/proj/ellipsoid.rb +77 -41
- data/lib/proj/error.rb +62 -9
- data/lib/proj/file_api.rb +166 -0
- data/lib/proj/grid.rb +121 -0
- data/lib/proj/grid_cache.rb +64 -0
- data/lib/proj/grid_info.rb +19 -0
- data/lib/proj/network_api.rb +92 -0
- data/lib/proj/operation.rb +42 -42
- data/lib/proj/operation_factory_context.rb +136 -0
- data/lib/proj/parameter.rb +38 -0
- data/lib/proj/parameters.rb +106 -0
- data/lib/proj/pj_object.rb +670 -80
- data/lib/proj/pj_objects.rb +44 -0
- data/lib/proj/prime_meridian.rb +65 -39
- data/lib/proj/projection.rb +698 -207
- data/lib/proj/session.rb +46 -0
- data/lib/proj/strings.rb +32 -0
- data/lib/proj/transformation.rb +101 -60
- data/lib/proj/unit.rb +108 -53
- data/lib/proj.rb +110 -9
- data/proj4rb.gemspec +5 -5
- data/test/abstract_test.rb +23 -1
- data/test/context_test.rb +172 -82
- data/test/conversion_test.rb +368 -0
- data/test/coordinate_system_test.rb +144 -0
- data/test/crs_test.rb +770 -71
- data/test/database_test.rb +360 -0
- data/test/datum_ensemble_test.rb +65 -0
- data/test/datum_test.rb +55 -0
- data/test/ellipsoid_test.rb +64 -18
- data/test/file_api_test.rb +66 -0
- data/test/grid_cache_test.rb +72 -0
- data/test/grid_test.rb +141 -0
- data/test/network_api_test.rb +45 -0
- data/test/operation_factory_context_test.rb +201 -0
- data/test/parameters_test.rb +40 -0
- data/test/pj_object_test.rb +179 -0
- data/test/prime_meridian_test.rb +76 -0
- data/test/proj_test.rb +46 -4
- data/test/projection_test.rb +646 -222
- data/test/session_test.rb +78 -0
- data/test/transformation_test.rb +149 -7
- data/test/unit_test.rb +57 -28
- metadata +51 -13
- data/lib/api/api_4_9.rb +0 -31
- data/lib/proj/config.rb +0 -70
- data/lib/proj/point.rb +0 -72
- data/test/prime_meridians_test.rb +0 -33
data/lib/proj/coordinate.rb
CHANGED
@@ -1,197 +1,281 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Proj
|
4
|
-
# A four dimensional coordinate of double values.
|
5
|
-
#
|
6
|
-
# For most geographic
|
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(:
|
22
|
-
# coord = Proj::Coordinate.new(:
|
23
|
-
# coord = Proj::Coordinate.new(:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
[:x, :y, :z]
|
38
|
-
elsif x && y
|
39
|
-
[:x, :y]
|
40
|
-
elsif
|
41
|
-
[:
|
42
|
-
elsif u && v && w
|
43
|
-
[:u, :v, :w]
|
44
|
-
elsif u && v
|
45
|
-
[:u, :v]
|
46
|
-
elsif
|
47
|
-
[:
|
48
|
-
elsif lam && phi && z
|
49
|
-
[:lam, :phi, :z]
|
50
|
-
elsif lam && phi
|
51
|
-
[:lam, :phi]
|
52
|
-
elsif
|
53
|
-
[:
|
54
|
-
elsif
|
55
|
-
[:
|
56
|
-
elsif
|
57
|
-
[:
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
def
|
81
|
-
@coord
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
def
|
117
|
-
@coord[:
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
#
|
142
|
-
#
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
#
|
149
|
-
#
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
#
|
156
|
-
#
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
#
|
163
|
-
#
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
def
|
173
|
-
@coord[:v][0]
|
174
|
-
end
|
175
|
-
|
176
|
-
# Returns
|
177
|
-
#
|
178
|
-
# @return [Float]
|
179
|
-
def
|
180
|
-
@coord[:v][1]
|
181
|
-
end
|
182
|
-
|
183
|
-
# Returns
|
184
|
-
#
|
185
|
-
# @return [Float]
|
186
|
-
def
|
187
|
-
@coord[:v][2]
|
188
|
-
end
|
189
|
-
|
190
|
-
# Returns
|
191
|
-
#
|
192
|
-
# @return [
|
193
|
-
def
|
194
|
-
|
195
|
-
end
|
196
|
-
|
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(:lon => 9, :lat => 10, :z => 11, :t => 12)
|
22
|
+
# coord = Proj::Coordinate.new(:s => 13, :a1 => 14, :a2 => 15)
|
23
|
+
# coord = Proj::Coordinate.new(:o => 16, :p => 17, :k => 18)
|
24
|
+
# coord = Proj::Coordinate.new(:e => 19, :n => 20, :u => 21)
|
25
|
+
|
26
|
+
def initialize(x: nil, y: nil, z: nil, t: nil,
|
27
|
+
u: nil, v: nil, w: nil, # t: nil
|
28
|
+
lam: nil, phi: nil, # z: nil, t: nil,
|
29
|
+
lat: nil, lon: nil, # z: nil, t: nil,
|
30
|
+
s: nil, a1: nil, a2: nil,
|
31
|
+
o: nil, p: nil, k: nil,
|
32
|
+
e: nil, n: nil) #u: nil
|
33
|
+
|
34
|
+
@coord = Api::PJ_COORD.new
|
35
|
+
|
36
|
+
keys = if x && y && z && t
|
37
|
+
[:x, :y, :z, :t]
|
38
|
+
elsif x && y && z
|
39
|
+
[:x, :y, :z]
|
40
|
+
elsif x && y
|
41
|
+
[:x, :y]
|
42
|
+
elsif u && v && w && t
|
43
|
+
[:u, :v, :w, :t]
|
44
|
+
elsif u && v && w
|
45
|
+
[:u, :v, :w]
|
46
|
+
elsif u && v
|
47
|
+
[:u, :v]
|
48
|
+
elsif lam && phi && z && t
|
49
|
+
[:lam, :phi, :z, :t]
|
50
|
+
elsif lam && phi && z
|
51
|
+
[:lam, :phi, :z]
|
52
|
+
elsif lam && phi
|
53
|
+
[:lam, :phi]
|
54
|
+
elsif lon && lat && z && t
|
55
|
+
[:lon, :lat, :z, :t]
|
56
|
+
elsif lon && lat && z
|
57
|
+
[:lon, :lat, :z]
|
58
|
+
elsif lon && lat
|
59
|
+
[:lon, :lat]
|
60
|
+
elsif s && a1 && a2
|
61
|
+
[:s, :a1, :a2]
|
62
|
+
elsif e && n && u
|
63
|
+
[:e, :n, :u]
|
64
|
+
elsif o && p && k
|
65
|
+
[:o, :p, :k]
|
66
|
+
else
|
67
|
+
[]
|
68
|
+
end
|
69
|
+
|
70
|
+
coord_struct = @coord[:v]
|
71
|
+
keys.each_with_index do |key, index|
|
72
|
+
coord_struct[index] = binding.local_variable_get(key)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_ptr
|
77
|
+
@coord.to_ptr
|
78
|
+
end
|
79
|
+
|
80
|
+
def pj_coord
|
81
|
+
@coord
|
82
|
+
end
|
83
|
+
|
84
|
+
def eql?(other)
|
85
|
+
@coord == other.instance_variable_get(:@coord)
|
86
|
+
end
|
87
|
+
|
88
|
+
def ==(other)
|
89
|
+
@coord.eql?(other.instance_variable_get(:@coord))
|
90
|
+
end
|
91
|
+
|
92
|
+
def enu
|
93
|
+
@coord[:enu]
|
94
|
+
end
|
95
|
+
|
96
|
+
def geod
|
97
|
+
@coord[:geod]
|
98
|
+
end
|
99
|
+
|
100
|
+
def lp
|
101
|
+
@coord[:lp]
|
102
|
+
end
|
103
|
+
|
104
|
+
def lpz
|
105
|
+
@coord[:lpz]
|
106
|
+
end
|
107
|
+
|
108
|
+
def lpzt
|
109
|
+
@coord[:lpzt]
|
110
|
+
end
|
111
|
+
|
112
|
+
def opk
|
113
|
+
@coord[:opk]
|
114
|
+
end
|
115
|
+
|
116
|
+
def uv
|
117
|
+
@coord[:uv]
|
118
|
+
end
|
119
|
+
|
120
|
+
def uvw
|
121
|
+
@coord[:uvw]
|
122
|
+
end
|
123
|
+
|
124
|
+
def uvwt
|
125
|
+
@coord[:uvwt]
|
126
|
+
end
|
127
|
+
|
128
|
+
def xy
|
129
|
+
@coord[:xy]
|
130
|
+
end
|
131
|
+
|
132
|
+
def xyz
|
133
|
+
@coord[:xyz]
|
134
|
+
end
|
135
|
+
|
136
|
+
def xyzt
|
137
|
+
@coord[:xyzt]
|
138
|
+
end
|
139
|
+
|
140
|
+
# Returns x coordinate
|
141
|
+
#
|
142
|
+
# @return [Float]
|
143
|
+
def x
|
144
|
+
@coord[:v][0]
|
145
|
+
end
|
146
|
+
|
147
|
+
# Returns y coordinate
|
148
|
+
#
|
149
|
+
# @return [Float]
|
150
|
+
def y
|
151
|
+
@coord[:v][1]
|
152
|
+
end
|
153
|
+
|
154
|
+
# Returns z coordinate
|
155
|
+
#
|
156
|
+
# @return [Float]
|
157
|
+
def z
|
158
|
+
@coord[:v][2]
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns t coordinate
|
162
|
+
#
|
163
|
+
# @return [Float]
|
164
|
+
def t
|
165
|
+
@coord[:v][3]
|
166
|
+
end
|
167
|
+
|
168
|
+
# Returns u coordinate
|
169
|
+
#
|
170
|
+
# @return [Float]
|
171
|
+
# TODO - This could be u in uvw or enu. Going to ignore that
|
172
|
+
def u
|
173
|
+
@coord[:v][0]
|
174
|
+
end
|
175
|
+
|
176
|
+
# Returns v coordinate
|
177
|
+
#
|
178
|
+
# @return [Float]
|
179
|
+
def v
|
180
|
+
@coord[:v][1]
|
181
|
+
end
|
182
|
+
|
183
|
+
# Returns w coordinate
|
184
|
+
#
|
185
|
+
# @return [Float]
|
186
|
+
def w
|
187
|
+
@coord[:v][2]
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns longitude coordinate
|
191
|
+
#
|
192
|
+
# @return [Float]
|
193
|
+
def lon
|
194
|
+
@coord[:v][0]
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns latitude coordinate
|
198
|
+
#
|
199
|
+
# @return [Float]
|
200
|
+
def lat
|
201
|
+
@coord[:v][1]
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns lam coordinate
|
205
|
+
#
|
206
|
+
# @return [Float]
|
207
|
+
def lam
|
208
|
+
@coord[:v][0]
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns phi coordinate
|
212
|
+
#
|
213
|
+
# @return [Float]
|
214
|
+
def phi
|
215
|
+
@coord[:v][1]
|
216
|
+
end
|
217
|
+
|
218
|
+
# Returns o coordinate
|
219
|
+
#
|
220
|
+
# @return [Float]
|
221
|
+
def o
|
222
|
+
@coord[:v][0]
|
223
|
+
end
|
224
|
+
|
225
|
+
# Returns p coordinate
|
226
|
+
#
|
227
|
+
# @return [Float]
|
228
|
+
def p
|
229
|
+
@coord[:v][1]
|
230
|
+
end
|
231
|
+
|
232
|
+
# Returns k coordinate
|
233
|
+
#
|
234
|
+
# @return [Float]
|
235
|
+
def k
|
236
|
+
@coord[:v][3]
|
237
|
+
end
|
238
|
+
|
239
|
+
# Returns e coordinate
|
240
|
+
#
|
241
|
+
# @return [Float]
|
242
|
+
def e
|
243
|
+
@coord[:v][0]
|
244
|
+
end
|
245
|
+
|
246
|
+
# Returns n coordinate
|
247
|
+
#
|
248
|
+
# @return [Float]
|
249
|
+
def n
|
250
|
+
@coord[:v][1]
|
251
|
+
end
|
252
|
+
|
253
|
+
# Returns s coordinate
|
254
|
+
#
|
255
|
+
# @return [Float]
|
256
|
+
def s
|
257
|
+
@coord[:v][0]
|
258
|
+
end
|
259
|
+
|
260
|
+
# Returns a1 coordinate
|
261
|
+
#
|
262
|
+
# @return [Float]
|
263
|
+
def a1
|
264
|
+
@coord[:v][1]
|
265
|
+
end
|
266
|
+
|
267
|
+
# Returns a2 coordinate
|
268
|
+
#
|
269
|
+
# @return [Float]
|
270
|
+
def a2
|
271
|
+
@coord[:v][2]
|
272
|
+
end
|
273
|
+
|
274
|
+
# Returns nice printout of coordinate contents
|
275
|
+
#
|
276
|
+
# @return [String]
|
277
|
+
def to_s
|
278
|
+
"v0: #{self.x}, v1: #{self.y}, v2: #{self.z}, v3: #{self.t}"
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|