proj4rb 2.2.2 → 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 +71 -66
- data/Gemfile +4 -4
- data/README.rdoc +5 -6
- data/Rakefile +27 -27
- data/lib/api/api.rb +11 -4
- data/lib/api/api_6_0.rb +1 -1
- data/lib/{area.rb → proj/area.rb} +0 -0
- data/lib/{config.rb → proj/config.rb} +0 -0
- data/lib/{context.rb → proj/context.rb} +0 -0
- data/lib/{coordinate.rb → proj/coordinate.rb} +0 -0
- data/lib/{crs.rb → proj/crs.rb} +0 -0
- data/lib/{ellipsoid.rb → proj/ellipsoid.rb} +0 -0
- data/lib/{error.rb → proj/error.rb} +0 -0
- data/lib/{operation.rb → proj/operation.rb} +0 -0
- data/lib/{pj_object.rb → proj/pj_object.rb} +0 -0
- data/lib/{point.rb → proj/point.rb} +0 -0
- data/lib/{prime_meridian.rb → proj/prime_meridian.rb} +0 -0
- data/lib/{projection.rb → proj/projection.rb} +0 -0
- data/lib/{transformation.rb → proj/transformation.rb} +0 -0
- data/lib/{unit.rb → proj/unit.rb} +0 -0
- data/lib/proj.rb +15 -15
- data/proj4rb.gemspec +32 -32
- data/test/abstract_test.rb +7 -7
- data/test/coordinate_test.rb +34 -34
- data/test/crs_test.rb +372 -372
- data/test/ellipsoid_test.rb +34 -34
- data/test/operation_test.rb +29 -29
- data/test/prime_meridians_test.rb +33 -33
- data/test/proj_test.rb +16 -16
- data/test/projection_test.rb +225 -223
- data/test/transformation_test.rb +67 -67
- data/test/unit_test.rb +47 -47
- metadata +21 -21
data/test/projection_test.rb
CHANGED
@@ -1,224 +1,226 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require_relative './abstract_test'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
Proj::
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
Proj::
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
if Proj::Api::PROJ_VERSION < Gem::Version.new('8.0.0')
|
6
|
+
class ProjectionTest < AbstractTest
|
7
|
+
PRECISION = 0.1 ** 4
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@proj_wgs84 = Proj::Projection.new(["init=epsg:4326"]) # WGS84
|
11
|
+
@proj_gk = Proj::Projection.new(["+init=epsg:31467"]) # Gauss-Kruger Zone 3
|
12
|
+
@proj_merc = Proj::Projection.new(["proj=merc"])
|
13
|
+
@proj_conakry = Proj::Projection.new(["+init=epsg:31528"]) # Conakry 1905 / UTM zone 28N
|
14
|
+
@proj_ortel = Proj::Projection.new(["+proj=ortel", "+lon_0=90w"]) # Ortelius Oval Projection
|
15
|
+
@epsg2029i = ['+init=epsg:2029']
|
16
|
+
@epsg2029_args = ['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs']
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_arg_fail
|
20
|
+
assert_raises ArgumentError do
|
21
|
+
Proj::Projection.parse()
|
22
|
+
end
|
23
|
+
assert_raises ArgumentError do
|
24
|
+
Proj::Projection.parse(nil)
|
25
|
+
end
|
26
|
+
assert_raises ArgumentError do
|
27
|
+
Proj::Projection.parse(1)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_arg_string
|
32
|
+
args = Proj::Projection.parse('+init=epsg:2029')
|
33
|
+
assert_equal(@epsg2029i, args)
|
34
|
+
args = Proj::Projection.parse(' +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs ')
|
35
|
+
assert_equal(@epsg2029_args, args)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_arg_string_with_plus
|
39
|
+
args = Proj::Projection.parse('+init=epsg:2029')
|
40
|
+
assert_equal(@epsg2029i, args)
|
41
|
+
args = Proj::Projection.parse('+proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs')
|
42
|
+
assert_equal(@epsg2029_args, args)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_arg_array
|
46
|
+
args = Proj::Projection.parse(['+init=epsg:2029'])
|
47
|
+
assert_equal(@epsg2029i, args)
|
48
|
+
args = Proj::Projection.parse(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
|
49
|
+
assert_equal(@epsg2029_args, args)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_arg_array_with_plus
|
53
|
+
args = Proj::Projection.parse(['+init=epsg:2029'])
|
54
|
+
assert_equal(@epsg2029i, args)
|
55
|
+
args = Proj::Projection.parse(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
|
56
|
+
assert_equal(@epsg2029_args, args)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_arg_hash_with_string
|
60
|
+
args = Proj::Projection.parse('init' => 'epsg:2029')
|
61
|
+
assert_equal(@epsg2029i, args)
|
62
|
+
args = Proj::Projection.parse('proj' => 'utm', 'zone' => '17', 'ellps' => 'clrk66', 'units' => 'm', 'no_defs' => nil)
|
63
|
+
assert_equal(@epsg2029_args, args)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_arg_hash_with_symbol
|
67
|
+
args = Proj::Projection.parse(:init => 'epsg:2029')
|
68
|
+
assert_equal(@epsg2029i, args)
|
69
|
+
args = Proj::Projection.parse(:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil)
|
70
|
+
assert_equal(@epsg2029_args, args)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_arg_hash_with_symbol_simple
|
74
|
+
args = Proj::Projection.parse(:init => 'epsg:2029')
|
75
|
+
assert_equal(@epsg2029i, args)
|
76
|
+
args = Proj::Projection.parse(:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil)
|
77
|
+
assert_equal(@epsg2029_args, args)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_arg_projection
|
81
|
+
proj = Proj::Projection.new(['+init=epsg:2029'])
|
82
|
+
args = Proj::Projection.parse(proj)
|
83
|
+
assert_equal(["+init=epsg:2029", "+proj=utm", "+zone=17", "+ellps=clrk66", "+units=m", "+no_defs"], args)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_init_arg_string
|
87
|
+
proj = Proj::Projection.new('+init=epsg:2029')
|
88
|
+
assert_equal(' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs', proj.getDef)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_init_arg_array
|
92
|
+
proj = Proj::Projection.new(['+init=epsg:2029'])
|
93
|
+
assert_equal(' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs', proj.getDef)
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_init_arg_hash
|
97
|
+
proj = Proj::Projection.new(:proj => 'utm', 'zone' => '17', 'ellps' => 'clrk66', :units => 'm', :no_defs => nil)
|
98
|
+
assert_equal(' +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs', proj.getDef)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_init_arg_fail
|
102
|
+
assert_raises Proj::Error do
|
103
|
+
Proj::Projection.new(:proj => 'xxxx')
|
104
|
+
end
|
105
|
+
|
106
|
+
assert_raises Proj::Error do
|
107
|
+
Proj::Projection.new(:foo => 'xxxx')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_is_latlong
|
112
|
+
assert(@proj_wgs84.isLatLong?)
|
113
|
+
refute(@proj_gk.isLatLong?)
|
114
|
+
refute(@proj_conakry.isLatLong?)
|
115
|
+
refute(@proj_ortel.isLatLong?)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_is_geocent
|
119
|
+
assert_equal(@proj_gk.isGeocent?, @proj_gk.isGeocentric?) # two names for same method
|
120
|
+
refute(@proj_wgs84.isGeocent?)
|
121
|
+
refute(@proj_gk.isGeocent?)
|
122
|
+
refute(@proj_conakry.isGeocent?)
|
123
|
+
refute(@proj_ortel.isGeocent?)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_get_def
|
127
|
+
assert_equal(' +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0', @proj_wgs84.getDef)
|
128
|
+
assert_equal(' +init=epsg:31467 +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +units=m +no_defs', @proj_gk.getDef)
|
129
|
+
assert_equal('+proj=ortel +lon_0=90w +ellps=GRS80', @proj_ortel.getDef.strip)
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_to_s
|
133
|
+
assert_equal('#<Proj::Projection +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0>', @proj_wgs84.to_s)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_projection
|
137
|
+
assert_equal('longlat', @proj_wgs84.projection)
|
138
|
+
assert_equal('tmerc', @proj_gk.projection)
|
139
|
+
assert_equal('utm', @proj_conakry.projection)
|
140
|
+
assert_equal('ortel', @proj_ortel.projection)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_datum
|
144
|
+
assert_equal('WGS84', @proj_wgs84.datum)
|
145
|
+
assert_nil(@proj_gk.datum)
|
146
|
+
assert_nil(@proj_conakry.datum)
|
147
|
+
end
|
148
|
+
|
149
|
+
# echo "8.4302123334 48.9906726079" | proj +init=epsg:31467 -
|
150
|
+
def test_forward_gk
|
151
|
+
point = Proj::Point.new(8.4302123334, 48.9906726079)
|
152
|
+
result = @proj_gk.forward(point.to_radians)
|
153
|
+
assert_in_delta(3458305.0, result.x, 0.1)
|
154
|
+
assert_in_delta(5428192.0, result.y, 0.1)
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_forward_gk_degrees
|
158
|
+
point = Proj::Point.new(8.4302123334, 48.9906726079)
|
159
|
+
result = @proj_gk.forwardDeg(point)
|
160
|
+
assert_in_delta(3458305.0, result.x, 0.1)
|
161
|
+
assert_in_delta(5428192.0, result.y, 0.1)
|
162
|
+
end
|
163
|
+
|
164
|
+
# echo "3458305 5428192" | invproj -f '%.10f' +init=epsg:31467 -
|
165
|
+
def test_inverse_gk
|
166
|
+
point = Proj::Point.new(3458305.0, 5428192.0)
|
167
|
+
result = @proj_gk.inverse(point).to_degrees
|
168
|
+
assert_in_delta(result.x, 8.4302123334, PRECISION)
|
169
|
+
assert_in_delta(result.y, 48.9906726079, PRECISION)
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_inverse_gk_degrees
|
173
|
+
point = Proj::Point.new(3458305.0, 5428192.0)
|
174
|
+
result = @proj_gk.inverseDeg(point)
|
175
|
+
assert_in_delta(result.x, 8.4302123334, PRECISION)
|
176
|
+
assert_in_delta(result.y, 48.9906726079, PRECISION)
|
177
|
+
end
|
178
|
+
|
179
|
+
# echo "190 92" | proj +init=epsg:31467 -
|
180
|
+
def test_out_of_bounds
|
181
|
+
error = assert_raises(Proj::Error) do
|
182
|
+
point = Proj::Point.new(190, 92).to_radians
|
183
|
+
@proj_gk.forward(point)
|
184
|
+
end
|
185
|
+
assert_equal('latitude or longitude exceeded limits', error.message)
|
186
|
+
end
|
187
|
+
|
188
|
+
# echo "3458305 5428192" | cs2cs -f '%.10f' +init=epsg:31467 +to +init=epsg:4326 -
|
189
|
+
def test_gk_to_wgs84
|
190
|
+
from = Proj::Point.new(3458305.0, 5428192.0)
|
191
|
+
to = @proj_gk.transform(@proj_wgs84, from).to_degrees
|
192
|
+
assert_in_delta(8.4302123334, to.x, PRECISION)
|
193
|
+
assert_in_delta(48.9906726079, to.y, PRECISION)
|
194
|
+
end
|
195
|
+
|
196
|
+
# echo "8.4293092923 48.9896114523" | cs2cs -f '%.10f' +init=epsg:4326 +to +init=epsg:31467 -
|
197
|
+
def test_wgs84_to_gk
|
198
|
+
from = Proj::Point.new(8.4302123334, 48.9906726079)
|
199
|
+
to = @proj_wgs84.transform(@proj_gk, from.to_radians)
|
200
|
+
assert_in_delta(3458305.0, to.x, PRECISION)
|
201
|
+
assert_in_delta(5428192.0, to.y, PRECISION)
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_mercator_at_pole_raise
|
205
|
+
from = Proj::Point.new(0, 90)
|
206
|
+
assert_raises(Proj::Error) do
|
207
|
+
@proj_wgs84.transform(@proj_merc, from.to_radians)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_collection
|
212
|
+
from0 = Proj::Point.new(3458305.0, 5428192.0)
|
213
|
+
from1 = Proj::Point.new(0, 0)
|
214
|
+
collection = @proj_gk.transform_all(@proj_wgs84, [from0, from1])
|
215
|
+
|
216
|
+
to0 = collection[0].to_degrees
|
217
|
+
to1 = collection[1].to_degrees
|
218
|
+
|
219
|
+
assert_in_delta(8.4302123334, to0.x, PRECISION)
|
220
|
+
assert_in_delta(48.9906726079, to0.y, PRECISION)
|
221
|
+
|
222
|
+
assert_in_delta(-20.9657785647, to1.x, PRECISION)
|
223
|
+
assert_in_delta(0, to1.y, PRECISION)
|
224
|
+
end
|
225
|
+
end
|
224
226
|
end
|
data/test/transformation_test.rb
CHANGED
@@ -1,68 +1,68 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require_relative './abstract_test'
|
4
|
-
|
5
|
-
class TransformationTest < AbstractTest
|
6
|
-
PRECISION = 0.5
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@crs_wgs84 = Proj::Crs.new('epsg:4326')
|
10
|
-
@crs_gk = Proj::Crs.new('epsg:31467')
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_create_from_strings
|
14
|
-
transform = Proj::Transformation.new('epsg:31467', 'epsg:4326')
|
15
|
-
assert(transform.info)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_create_crs
|
19
|
-
transform = Proj::Transformation.new(@crs_wgs84, @crs_gk)
|
20
|
-
assert(transform.info)
|
21
|
-
end
|
22
|
-
|
23
|
-
# echo "3458305 5428192" | cs2cs -f '%.10f' +init=epsg:31467 +to +init=epsg:4326 -
|
24
|
-
def test_gk_to_wgs84_forward
|
25
|
-
transform = Proj::Transformation.new(@crs_gk, @crs_wgs84)
|
26
|
-
from = Proj::Coordinate.new(x: 5428192.0, y: 3458305.0, z: -5.1790915237)
|
27
|
-
to = transform.forward(from)
|
28
|
-
|
29
|
-
assert_in_delta(48.98963932450735, to.x, PRECISION)
|
30
|
-
assert_in_delta(8.429263044355544, to.y, PRECISION)
|
31
|
-
assert_in_delta(-5.1790915237, to.z, PRECISION)
|
32
|
-
assert_in_delta(0, to.t, PRECISION)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_gk_to_wgs84_inverse
|
36
|
-
transform = Proj::Transformation.new(@crs_gk, @crs_wgs84)
|
37
|
-
from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
|
38
|
-
to = transform.inverse(from)
|
39
|
-
|
40
|
-
assert_in_delta(
|
41
|
-
assert_in_delta(3458375, to.y, PRECISION)
|
42
|
-
assert_in_delta(0, to.z, PRECISION)
|
43
|
-
assert_in_delta(0, to.t, PRECISION)
|
44
|
-
end
|
45
|
-
|
46
|
-
# echo "8.4293092923 48.9896114523" | cs2cs -f '%.10f' +init=epsg:4326 +to +init=epsg:31467 -
|
47
|
-
def test_wgs84_to_gk_forward
|
48
|
-
transform = Proj::Transformation.new(@crs_wgs84, @crs_gk)
|
49
|
-
from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
|
50
|
-
to = transform.forward(from)
|
51
|
-
|
52
|
-
assert_in_delta(
|
53
|
-
assert_in_delta(3458375, to.y, PRECISION)
|
54
|
-
assert_in_delta(0, to.z, PRECISION)
|
55
|
-
assert_in_delta(0, to.t, PRECISION)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_wgs84_to_gk_forward_inverse
|
59
|
-
transform = Proj::Transformation.new(@crs_wgs84, @crs_gk)
|
60
|
-
from = Proj::Coordinate.new(x: 5428192.0, y: 3458305.0, z: -5.1790915237)
|
61
|
-
to = transform.inverse(from)
|
62
|
-
|
63
|
-
assert_in_delta(48.98963932450735, to.x, PRECISION)
|
64
|
-
assert_in_delta(8.429263044355544, to.y, PRECISION)
|
65
|
-
assert_in_delta(-5.1790915237, to.z, PRECISION)
|
66
|
-
assert_in_delta(0, to.t, PRECISION)
|
67
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class TransformationTest < AbstractTest
|
6
|
+
PRECISION = 0.5
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@crs_wgs84 = Proj::Crs.new('epsg:4326')
|
10
|
+
@crs_gk = Proj::Crs.new('epsg:31467')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_create_from_strings
|
14
|
+
transform = Proj::Transformation.new('epsg:31467', 'epsg:4326')
|
15
|
+
assert(transform.info)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create_crs
|
19
|
+
transform = Proj::Transformation.new(@crs_wgs84, @crs_gk)
|
20
|
+
assert(transform.info)
|
21
|
+
end
|
22
|
+
|
23
|
+
# echo "3458305 5428192" | cs2cs -f '%.10f' +init=epsg:31467 +to +init=epsg:4326 -
|
24
|
+
def test_gk_to_wgs84_forward
|
25
|
+
transform = Proj::Transformation.new(@crs_gk, @crs_wgs84)
|
26
|
+
from = Proj::Coordinate.new(x: 5428192.0, y: 3458305.0, z: -5.1790915237)
|
27
|
+
to = transform.forward(from)
|
28
|
+
|
29
|
+
assert_in_delta(48.98963932450735, to.x, PRECISION)
|
30
|
+
assert_in_delta(8.429263044355544, to.y, PRECISION)
|
31
|
+
assert_in_delta(-5.1790915237, to.z, PRECISION)
|
32
|
+
assert_in_delta(0, to.t, PRECISION)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_gk_to_wgs84_inverse
|
36
|
+
transform = Proj::Transformation.new(@crs_gk, @crs_wgs84)
|
37
|
+
from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
|
38
|
+
to = transform.inverse(from)
|
39
|
+
|
40
|
+
assert_in_delta(5428307, to.x, PRECISION)
|
41
|
+
assert_in_delta(3458375, to.y, PRECISION)
|
42
|
+
assert_in_delta(0, to.z, PRECISION)
|
43
|
+
assert_in_delta(0, to.t, PRECISION)
|
44
|
+
end
|
45
|
+
|
46
|
+
# echo "8.4293092923 48.9896114523" | cs2cs -f '%.10f' +init=epsg:4326 +to +init=epsg:31467 -
|
47
|
+
def test_wgs84_to_gk_forward
|
48
|
+
transform = Proj::Transformation.new(@crs_wgs84, @crs_gk)
|
49
|
+
from = Proj::Coordinate.new(lam: 48.9906726079, phi: 8.4302123334)
|
50
|
+
to = transform.forward(from)
|
51
|
+
|
52
|
+
assert_in_delta(5428307, to.x, PRECISION)
|
53
|
+
assert_in_delta(3458375, to.y, PRECISION)
|
54
|
+
assert_in_delta(0, to.z, PRECISION)
|
55
|
+
assert_in_delta(0, to.t, PRECISION)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_wgs84_to_gk_forward_inverse
|
59
|
+
transform = Proj::Transformation.new(@crs_wgs84, @crs_gk)
|
60
|
+
from = Proj::Coordinate.new(x: 5428192.0, y: 3458305.0, z: -5.1790915237)
|
61
|
+
to = transform.inverse(from)
|
62
|
+
|
63
|
+
assert_in_delta(48.98963932450735, to.x, PRECISION)
|
64
|
+
assert_in_delta(8.429263044355544, to.y, PRECISION)
|
65
|
+
assert_in_delta(-5.1790915237, to.z, PRECISION)
|
66
|
+
assert_in_delta(0, to.t, PRECISION)
|
67
|
+
end
|
68
68
|
end
|