proj4rb 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +26 -15
  3. data/README.rdoc +82 -44
  4. data/Rakefile +27 -27
  5. data/lib/api/api.rb +96 -118
  6. data/lib/api/api_5_0.rb +331 -300
  7. data/lib/api/api_5_1.rb +6 -6
  8. data/lib/api/api_5_2.rb +4 -4
  9. data/lib/api/api_6_0.rb +116 -14
  10. data/lib/api/api_6_1.rb +4 -4
  11. data/lib/api/api_6_2.rb +9 -6
  12. data/lib/api/api_6_3.rb +6 -0
  13. data/lib/api/api_7_0.rb +68 -0
  14. data/lib/api/api_7_1.rb +73 -0
  15. data/lib/api/api_7_2.rb +14 -0
  16. data/lib/api/api_8_0.rb +6 -0
  17. data/lib/api/api_8_1.rb +24 -0
  18. data/lib/api/api_8_2.rb +6 -0
  19. data/lib/api/api_9_1.rb +7 -0
  20. data/lib/api/api_9_2.rb +9 -0
  21. data/lib/api/api_experimental.rb +196 -0
  22. data/lib/proj/area.rb +73 -32
  23. data/lib/proj/axis_info.rb +44 -0
  24. data/lib/proj/bounds.rb +13 -0
  25. data/lib/proj/context.rb +174 -28
  26. data/lib/proj/conversion.rb +92 -0
  27. data/lib/proj/coordinate.rb +281 -197
  28. data/lib/proj/coordinate_operation_mixin.rb +381 -0
  29. data/lib/proj/coordinate_system.rb +137 -0
  30. data/lib/proj/crs.rb +672 -204
  31. data/lib/proj/crs_info.rb +47 -0
  32. data/lib/proj/database.rb +305 -0
  33. data/lib/proj/datum.rb +32 -0
  34. data/lib/proj/datum_ensemble.rb +34 -0
  35. data/lib/proj/ellipsoid.rb +77 -41
  36. data/lib/proj/error.rb +62 -9
  37. data/lib/proj/file_api.rb +166 -0
  38. data/lib/proj/grid.rb +121 -0
  39. data/lib/proj/grid_cache.rb +64 -0
  40. data/lib/proj/grid_info.rb +19 -0
  41. data/lib/proj/network_api.rb +92 -0
  42. data/lib/proj/operation.rb +42 -42
  43. data/lib/proj/operation_factory_context.rb +136 -0
  44. data/lib/proj/parameter.rb +38 -0
  45. data/lib/proj/parameters.rb +106 -0
  46. data/lib/proj/pj_object.rb +670 -80
  47. data/lib/proj/pj_objects.rb +44 -0
  48. data/lib/proj/prime_meridian.rb +65 -39
  49. data/lib/proj/projection.rb +698 -207
  50. data/lib/proj/session.rb +46 -0
  51. data/lib/proj/strings.rb +32 -0
  52. data/lib/proj/transformation.rb +101 -60
  53. data/lib/proj/unit.rb +108 -53
  54. data/lib/proj.rb +110 -9
  55. data/proj4rb.gemspec +5 -5
  56. data/test/abstract_test.rb +23 -1
  57. data/test/context_test.rb +172 -82
  58. data/test/conversion_test.rb +368 -0
  59. data/test/coordinate_system_test.rb +144 -0
  60. data/test/crs_test.rb +770 -71
  61. data/test/database_test.rb +360 -0
  62. data/test/datum_ensemble_test.rb +65 -0
  63. data/test/datum_test.rb +55 -0
  64. data/test/ellipsoid_test.rb +64 -18
  65. data/test/file_api_test.rb +66 -0
  66. data/test/grid_cache_test.rb +72 -0
  67. data/test/grid_test.rb +141 -0
  68. data/test/network_api_test.rb +45 -0
  69. data/test/operation_factory_context_test.rb +201 -0
  70. data/test/parameters_test.rb +40 -0
  71. data/test/pj_object_test.rb +179 -0
  72. data/test/prime_meridian_test.rb +76 -0
  73. data/test/proj_test.rb +46 -4
  74. data/test/projection_test.rb +646 -222
  75. data/test/session_test.rb +78 -0
  76. data/test/transformation_test.rb +149 -7
  77. data/test/unit_test.rb +57 -28
  78. metadata +51 -13
  79. data/lib/api/api_4_9.rb +0 -31
  80. data/lib/proj/config.rb +0 -70
  81. data/lib/proj/point.rb +0 -72
  82. data/test/prime_meridians_test.rb +0 -33
@@ -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 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(: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