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
@@ -0,0 +1,360 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class DatabaseTest < AbstractTest
|
6
|
+
def create_crs
|
7
|
+
Proj::Crs.new(<<~EOS)
|
8
|
+
GEOGCRS["myGDA2020",
|
9
|
+
DATUM["GDA2020",
|
10
|
+
ELLIPSOID["GRS_1980",6378137,298.257222101,
|
11
|
+
LENGTHUNIT["metre",1]]],
|
12
|
+
PRIMEM["Greenwich",0,
|
13
|
+
ANGLEUNIT["Degree",0.0174532925199433]],
|
14
|
+
CS[ellipsoidal,2],
|
15
|
+
AXIS["geodetic latitude (Lat)",north,
|
16
|
+
ORDER[1],
|
17
|
+
ANGLEUNIT["degree",0.0174532925199433]],
|
18
|
+
AXIS["geodetic longitude (Lon)",east,
|
19
|
+
ORDER[2],
|
20
|
+
ANGLEUNIT["degree",0.0174532925199433]]]
|
21
|
+
EOS
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_path
|
25
|
+
database = Proj::Database.new(Proj::Context.current)
|
26
|
+
assert_equal("proj.db", File.basename(database.path))
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_set_path_error
|
30
|
+
database = Proj::Database.new(Proj::Context.current)
|
31
|
+
|
32
|
+
error = assert_raises(Proj::Error) do
|
33
|
+
database.path = "test.db"
|
34
|
+
end
|
35
|
+
# This error is sometimes "Unknown error (code 4096)"
|
36
|
+
# assert_equal("Invalid value for an argument", error.to_s)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_structure
|
40
|
+
database = Proj::Database.new(Proj::Context.current)
|
41
|
+
structure = database.structure
|
42
|
+
assert(structure.length > 70)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_metadata
|
46
|
+
database = Proj::Database.new(Proj::Context.current)
|
47
|
+
metadata = database.metadata('IGNF.VERSION')
|
48
|
+
assert_equal('3.1.0', metadata)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_codes
|
52
|
+
types_with_no_codes = [:PJ_TYPE_TEMPORAL_CRS, :PJ_TYPE_BOUND_CRS, :PJ_TYPE_UNKNOWN, :PJ_TYPE_ENGINEERING_CRS,
|
53
|
+
:PJ_TYPE_TEMPORAL_DATUM, :PJ_TYPE_ENGINEERING_DATUM, :PJ_TYPE_PARAMETRIC_DATUM,
|
54
|
+
:PJ_TYPE_OTHER_COORDINATE_OPERATION]
|
55
|
+
|
56
|
+
database = Proj::Database.new(Proj::Context.current)
|
57
|
+
|
58
|
+
Proj::Api::PJ_TYPE.symbols.each do |type|
|
59
|
+
codes = database.codes('EPSG', type)
|
60
|
+
if types_with_no_codes.include?(type)
|
61
|
+
assert(codes.empty?)
|
62
|
+
else
|
63
|
+
refute(codes.empty?)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_authorities
|
69
|
+
database = Proj::Database.new(Proj::Context.current)
|
70
|
+
authorities = database.authorities
|
71
|
+
assert_equal(7, authorities.count)
|
72
|
+
|
73
|
+
authority = authorities[0]
|
74
|
+
assert_equal('EPSG', authority)
|
75
|
+
|
76
|
+
authority = authorities[1]
|
77
|
+
assert_equal('ESRI', authority)
|
78
|
+
|
79
|
+
authority = authorities[2]
|
80
|
+
assert_equal('IAU_2015', authority)
|
81
|
+
|
82
|
+
authority = authorities[3]
|
83
|
+
assert_equal('IGNF', authority)
|
84
|
+
|
85
|
+
authority = authorities[4]
|
86
|
+
assert_equal('NKG', authority)
|
87
|
+
|
88
|
+
authority = authorities[5]
|
89
|
+
assert_equal('OGC', authority)
|
90
|
+
|
91
|
+
authority = authorities[6]
|
92
|
+
assert_equal('PROJ', authority)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_crs_info
|
96
|
+
database = Proj::Database.new(Proj::Context.current)
|
97
|
+
crs_infos = database.crs_info
|
98
|
+
|
99
|
+
expected = case
|
100
|
+
when proj9?
|
101
|
+
13107
|
102
|
+
else
|
103
|
+
12609
|
104
|
+
end
|
105
|
+
assert_equal(expected, crs_infos.count)
|
106
|
+
|
107
|
+
crs_info = crs_infos.first
|
108
|
+
assert_equal("EPSG", crs_info.auth_name)
|
109
|
+
assert_equal("2000", crs_info.code)
|
110
|
+
assert_equal("Anguilla 1957 / British West Indies Grid", crs_info.name)
|
111
|
+
assert_equal(:PJ_TYPE_PROJECTED_CRS, crs_info.type)
|
112
|
+
refute(crs_info.deprecated)
|
113
|
+
assert(crs_info.bbox_valid)
|
114
|
+
assert_equal(-63.22, crs_info.west_lon_degree)
|
115
|
+
assert_equal(18.11, crs_info.south_lat_degree)
|
116
|
+
assert_equal(-62.92, crs_info.east_lon_degree)
|
117
|
+
assert_equal(18.33, crs_info.north_lat_degree)
|
118
|
+
assert_equal("Anguilla - onshore.", crs_info.area_name)
|
119
|
+
assert_equal("Transverse Mercator", crs_info.projection_method_name)
|
120
|
+
assert_equal("Earth", crs_info.celestial_body_name)
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_crs_info_epsg
|
124
|
+
database = Proj::Database.new(Proj::Context.current)
|
125
|
+
crs_infos = database.crs_info("EPSG")
|
126
|
+
|
127
|
+
expected = case
|
128
|
+
when proj9?
|
129
|
+
7251
|
130
|
+
else
|
131
|
+
7056
|
132
|
+
end
|
133
|
+
assert_equal(expected, crs_infos.count)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_crs_info_geodetic
|
137
|
+
database = Proj::Database.new(Proj::Context.current)
|
138
|
+
params = Proj::Parameters.new
|
139
|
+
params.types = [:PJ_TYPE_GEODETIC_CRS]
|
140
|
+
crs_infos = database.crs_info("EPSG", params)
|
141
|
+
|
142
|
+
expected = case
|
143
|
+
when proj9?
|
144
|
+
943
|
145
|
+
else
|
146
|
+
930
|
147
|
+
end
|
148
|
+
|
149
|
+
assert_equal(expected, crs_infos.count)
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_crs_info_geographic
|
153
|
+
database = Proj::Database.new(Proj::Context.current)
|
154
|
+
params = Proj::Parameters.new
|
155
|
+
params.types = [:PJ_TYPE_GEOGRAPHIC_2D_CRS, :PJ_TYPE_PROJECTED_CRS]
|
156
|
+
crs_infos = database.crs_info("EPSG", params)
|
157
|
+
|
158
|
+
expected = case
|
159
|
+
when proj9?
|
160
|
+
5689
|
161
|
+
else
|
162
|
+
5534
|
163
|
+
end
|
164
|
+
|
165
|
+
assert_equal(expected, crs_infos.count)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_crs_info_bounds_inclusive
|
169
|
+
database = Proj::Database.new(Proj::Context.current)
|
170
|
+
params = Proj::Parameters.new
|
171
|
+
params.types = [:PJ_TYPE_PROJECTED_CRS]
|
172
|
+
params.bbox_valid = 1
|
173
|
+
params.west_lon_degree = 2
|
174
|
+
params.south_lat_degree = 49
|
175
|
+
params.east_lon_degree = 2.1
|
176
|
+
params.north_lat_degree = 49.1
|
177
|
+
|
178
|
+
crs_infos = database.crs_info("EPSG", params)
|
179
|
+
assert_equal(35, crs_infos.count)
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_crs_info_bounds_exclusive
|
183
|
+
database = Proj::Database.new(Proj::Context.current)
|
184
|
+
params = Proj::Parameters.new
|
185
|
+
params.types = [:PJ_TYPE_PROJECTED_CRS]
|
186
|
+
params.bbox_valid = 1
|
187
|
+
params.west_lon_degree = 2
|
188
|
+
params.south_lat_degree = 49
|
189
|
+
params.east_lon_degree = 2.1
|
190
|
+
params.north_lat_degree = 49.1
|
191
|
+
params.crs_area_of_use_contains_bbox = 0
|
192
|
+
|
193
|
+
crs_infos = database.crs_info("EPSG", params)
|
194
|
+
assert_equal(38, crs_infos.count)
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_crs_info_celestial_body
|
198
|
+
database = Proj::Database.new(Proj::Context.current)
|
199
|
+
params = Proj::Parameters.new
|
200
|
+
params.celestial_body_name = "Earth"
|
201
|
+
crs_infos = database.crs_info("EPSG", params)
|
202
|
+
|
203
|
+
expected = case
|
204
|
+
when proj9?
|
205
|
+
6723
|
206
|
+
else
|
207
|
+
6532
|
208
|
+
end
|
209
|
+
|
210
|
+
assert_equal(expected, crs_infos.count)
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_unit
|
214
|
+
database = Proj::Database.new(Proj::Context.current)
|
215
|
+
unit = database.unit("EPSG", "9001")
|
216
|
+
assert_equal("EPSG", unit.auth_name)
|
217
|
+
assert_equal("9001", unit.code)
|
218
|
+
assert_equal("metre", unit.name)
|
219
|
+
assert_equal("linear", unit.category)
|
220
|
+
assert_equal(1.0, unit.conv_factor)
|
221
|
+
refute(unit.proj_short_name)
|
222
|
+
refute(unit.deprecated)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_geoid_models
|
226
|
+
database = Proj::Database.new(Proj::Context.current)
|
227
|
+
models = database.geoid_models("EPSG", "5703")
|
228
|
+
|
229
|
+
assert_equal(8, models.size)
|
230
|
+
|
231
|
+
expected = %w[GEOID03 GEOID06 GEOID09 GEOID12A GEOID12B GEOID18 GEOID99 GGM10]
|
232
|
+
assert_equal(expected, models.strings)
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_celestial_bodies
|
236
|
+
database = Proj::Database.new(Proj::Context.current)
|
237
|
+
bodies = database.celestial_bodies
|
238
|
+
|
239
|
+
expected = case
|
240
|
+
when proj9?
|
241
|
+
176
|
242
|
+
else
|
243
|
+
170
|
244
|
+
end
|
245
|
+
|
246
|
+
assert_equal(expected, bodies.size)
|
247
|
+
|
248
|
+
celestial_body = bodies[0]
|
249
|
+
assert_equal('ESRI', celestial_body.auth_name)
|
250
|
+
assert_equal('1_Ceres', celestial_body.name)
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_celestial_bodies_authority
|
254
|
+
database = Proj::Database.new(Proj::Context.current)
|
255
|
+
bodies = database.celestial_bodies('ESRI')
|
256
|
+
|
257
|
+
expected = case
|
258
|
+
when proj9?
|
259
|
+
78
|
260
|
+
else
|
261
|
+
72
|
262
|
+
end
|
263
|
+
|
264
|
+
assert_equal(expected, bodies.size)
|
265
|
+
|
266
|
+
celestial_body = bodies[0]
|
267
|
+
assert_equal('ESRI', celestial_body.auth_name)
|
268
|
+
assert_equal('1_Ceres', celestial_body.name)
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_suggest_code_for
|
272
|
+
crs = create_crs
|
273
|
+
database = Proj::Database.new(crs.context)
|
274
|
+
|
275
|
+
code = database.suggest_code_for(crs, "HOBU", false)
|
276
|
+
assert_equal("MYGDA2020", code)
|
277
|
+
|
278
|
+
code = database.suggest_code_for(crs, "HOBU", true)
|
279
|
+
assert_equal("1", code)
|
280
|
+
end
|
281
|
+
|
282
|
+
def test_celestial_body_name_geographic_crs
|
283
|
+
crs = Proj::Crs.create_from_database("EPSG", "4326", :PJ_CATEGORY_CRS)
|
284
|
+
database = Proj::Database.new(crs.context)
|
285
|
+
name = database.celestial_body_name(crs)
|
286
|
+
assert_equal("Earth", name)
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_celestial_body_name_geographic_projected_crs
|
290
|
+
crs = Proj::Crs.create_from_database("EPSG", "32631", :PJ_CATEGORY_CRS)
|
291
|
+
database = Proj::Database.new(crs.context)
|
292
|
+
name = database.celestial_body_name(crs)
|
293
|
+
assert_equal("Earth", name)
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_celestial_body_name_vertical_crs
|
297
|
+
crs = Proj::Crs.create_from_database("EPSG", "3855", :PJ_CATEGORY_CRS)
|
298
|
+
database = Proj::Database.new(crs.context)
|
299
|
+
name = database.celestial_body_name(crs)
|
300
|
+
assert_equal("Earth", name)
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_celestial_body_name_compound_crs
|
304
|
+
crs = Proj::Crs.create_from_database("EPSG", "9518", :PJ_CATEGORY_CRS)
|
305
|
+
database = Proj::Database.new(crs.context)
|
306
|
+
name = database.celestial_body_name(crs)
|
307
|
+
assert_equal("Earth", name)
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_celestial_body_name_geodetic_datum
|
311
|
+
crs = Proj::Crs.create_from_database("EPSG", "6267", :PJ_CATEGORY_DATUM)
|
312
|
+
database = Proj::Database.new(crs.context)
|
313
|
+
name = database.celestial_body_name(crs)
|
314
|
+
assert_equal("Earth", name)
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_celestial_body_name_datum_ensemble
|
318
|
+
crs = Proj::Crs.create_from_database("EPSG", "6326", :PJ_CATEGORY_DATUM_ENSEMBLE)
|
319
|
+
database = Proj::Database.new(crs.context)
|
320
|
+
name = database.celestial_body_name(crs)
|
321
|
+
assert_equal("Earth", name)
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_celestial_body_name_vertical_datum
|
325
|
+
crs = Proj::Crs.create_from_database("EPSG", "1027", :PJ_CATEGORY_DATUM)
|
326
|
+
database = Proj::Database.new(crs.context)
|
327
|
+
name = database.celestial_body_name(crs)
|
328
|
+
assert_equal("Earth", name)
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_celestial_body_name_ellipsoid
|
332
|
+
crs = Proj::Crs.create_from_database("EPSG", "7030", :PJ_CATEGORY_ELLIPSOID)
|
333
|
+
database = Proj::Database.new(crs.context)
|
334
|
+
name = database.celestial_body_name(crs)
|
335
|
+
assert_equal("Earth", name)
|
336
|
+
end
|
337
|
+
|
338
|
+
def test_celestial_body_name_ellipsoid_not_earth
|
339
|
+
crs = Proj::Crs.create_from_database("ESRI", "107903", :PJ_CATEGORY_ELLIPSOID)
|
340
|
+
database = Proj::Database.new(crs.context)
|
341
|
+
name = database.celestial_body_name(crs)
|
342
|
+
assert_equal("Moon", name)
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_celestial_body_name_error
|
346
|
+
crs = Proj::Crs.create_from_database("EPSG", "1591", :PJ_CATEGORY_COORDINATE_OPERATION)
|
347
|
+
database = Proj::Database.new(crs.context)
|
348
|
+
name = database.celestial_body_name(crs)
|
349
|
+
refute(name)
|
350
|
+
end
|
351
|
+
|
352
|
+
if proj7?
|
353
|
+
# This test causes a segmentation fault on proj6
|
354
|
+
def test_metadata_invalid
|
355
|
+
database = Proj::Database.new(Proj::Context.current)
|
356
|
+
metadata = database.metadata('foo')
|
357
|
+
refute(metadata)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class DatumEnsembleTest < AbstractTest
|
6
|
+
def get_datum_ensemble
|
7
|
+
wkt = <<~EOS
|
8
|
+
GEOGCRS["ETRS89",
|
9
|
+
ENSEMBLE["European Terrestrial Reference System 1989 ensemble",
|
10
|
+
MEMBER["European Terrestrial Reference Frame 1989"],
|
11
|
+
MEMBER["European Terrestrial Reference Frame 1990"],
|
12
|
+
MEMBER["European Terrestrial Reference Frame 1991"],
|
13
|
+
MEMBER["European Terrestrial Reference Frame 1992"],
|
14
|
+
MEMBER["European Terrestrial Reference Frame 1993"],
|
15
|
+
MEMBER["European Terrestrial Reference Frame 1994"],
|
16
|
+
MEMBER["European Terrestrial Reference Frame 1996"],
|
17
|
+
MEMBER["European Terrestrial Reference Frame 1997"],
|
18
|
+
MEMBER["European Terrestrial Reference Frame 2000"],
|
19
|
+
MEMBER["European Terrestrial Reference Frame 2005"],
|
20
|
+
MEMBER["European Terrestrial Reference Frame 2014"],
|
21
|
+
ELLIPSOID["GRS 1980",6378137,298.257222101,
|
22
|
+
LENGTHUNIT["metre",1]],
|
23
|
+
ENSEMBLEACCURACY[0.1]],
|
24
|
+
PRIMEM["Greenwich",0,
|
25
|
+
ANGLEUNIT["degree",0.0174532925199433]],
|
26
|
+
CS[ellipsoidal,2],
|
27
|
+
AXIS["geodetic latitude (Lat)",north,
|
28
|
+
ORDER[1],
|
29
|
+
ANGLEUNIT["degree",0.0174532925199433]],
|
30
|
+
AXIS["geodetic longitude (Lon)",east,
|
31
|
+
ORDER[2],
|
32
|
+
ANGLEUNIT["degree",0.0174532925199433]]]
|
33
|
+
EOS
|
34
|
+
|
35
|
+
crs = Proj::Crs.create(wkt)
|
36
|
+
crs.datum_ensemble
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_count
|
40
|
+
ensemble = get_datum_ensemble
|
41
|
+
assert_equal(11, ensemble.count)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_member
|
45
|
+
ensemble = get_datum_ensemble
|
46
|
+
|
47
|
+
member = ensemble[0]
|
48
|
+
assert_equal(:PJ_TYPE_GEODETIC_REFERENCE_FRAME, member.proj_type)
|
49
|
+
assert_equal("European Terrestrial Reference Frame 1989", member.name)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_member_invalid
|
53
|
+
ensemble = get_datum_ensemble
|
54
|
+
member = ensemble[-1]
|
55
|
+
refute(member)
|
56
|
+
|
57
|
+
member = ensemble[100]
|
58
|
+
refute(member)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_accuracy
|
62
|
+
ensemble = get_datum_ensemble
|
63
|
+
assert_equal(0.1, ensemble.accuracy)
|
64
|
+
end
|
65
|
+
end
|
data/test/datum_test.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class DatumTest < AbstractTest
|
6
|
+
def test_datum
|
7
|
+
datum = Proj::PjObject.create_from_database("EPSG", "1061", :PJ_CATEGORY_DATUM)
|
8
|
+
assert_equal(:PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME, datum.proj_type)
|
9
|
+
assert_equal("International Terrestrial Reference Frame 2008", datum.name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_frame_reference_epoch
|
13
|
+
datum = Proj::PjObject.create_from_database("EPSG", "1061", :PJ_CATEGORY_DATUM)
|
14
|
+
epoch = datum.frame_reference_epoch
|
15
|
+
assert_equal(2005.0, epoch)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_ellipsoid
|
19
|
+
wkt = <<~EOS
|
20
|
+
PROJCS["WGS 84 / UTM zone 31N",
|
21
|
+
GEOGCS["WGS 84",
|
22
|
+
DATUM["WGS_1984",
|
23
|
+
SPHEROID["WGS 84",6378137,298.257223563,
|
24
|
+
AUTHORITY["EPSG","7030"]],
|
25
|
+
AUTHORITY["EPSG","6326"]],
|
26
|
+
PRIMEM["Greenwich",0,
|
27
|
+
AUTHORITY["EPSG","8901"]],
|
28
|
+
UNIT["degree",0.0174532925199433,
|
29
|
+
AUTHORITY["EPSG","9122"]],
|
30
|
+
AUTHORITY["EPSG","4326"]],
|
31
|
+
PROJECTION["Transverse_Mercator"],
|
32
|
+
PARAMETER["latitude_of_origin",0],
|
33
|
+
PARAMETER["central_meridian",3],
|
34
|
+
PARAMETER["scale_factor",0.9996],
|
35
|
+
PARAMETER["false_easting",500000],
|
36
|
+
PARAMETER["false_northing",0],
|
37
|
+
UNIT["metre",1,
|
38
|
+
AUTHORITY["EPSG","9001"]],
|
39
|
+
AXIS["Easting",EAST],
|
40
|
+
AXIS["Northing",NORTH],
|
41
|
+
AUTHORITY["EPSG","32631"]]
|
42
|
+
EOS
|
43
|
+
|
44
|
+
crs = Proj::Crs.new(wkt)
|
45
|
+
ellipsoid = crs.ellipsoid
|
46
|
+
assert_equal("WGS 84", ellipsoid.name)
|
47
|
+
assert_equal(:PJ_TYPE_ELLIPSOID, ellipsoid.proj_type)
|
48
|
+
|
49
|
+
ellipsoid_from_datum = crs.datum.ellipsoid
|
50
|
+
assert_equal("WGS 84", ellipsoid_from_datum.name)
|
51
|
+
assert_equal(:PJ_TYPE_ELLIPSOID, ellipsoid_from_datum.proj_type)
|
52
|
+
|
53
|
+
assert(ellipsoid_from_datum.equivalent_to?(ellipsoid, :PJ_COMP_STRICT))
|
54
|
+
end
|
55
|
+
end
|
data/test/ellipsoid_test.rb
CHANGED
@@ -3,32 +3,78 @@
|
|
3
3
|
require_relative './abstract_test'
|
4
4
|
|
5
5
|
class EllipsoidTest < AbstractTest
|
6
|
-
def
|
7
|
-
|
6
|
+
def parameter_crs
|
7
|
+
wkt = <<~EOS
|
8
|
+
PROJCS["WGS 84 / UTM zone 31N",
|
9
|
+
GEOGCS["WGS 84",
|
10
|
+
DATUM["WGS_1984",
|
11
|
+
SPHEROID["WGS 84",6378137,298.257223563,
|
12
|
+
AUTHORITY["EPSG","7030"]],
|
13
|
+
AUTHORITY["EPSG","6326"]],
|
14
|
+
PRIMEM["Greenwich",0,
|
15
|
+
AUTHORITY["EPSG","8901"]],
|
16
|
+
UNIT["degree",0.0174532925199433,
|
17
|
+
AUTHORITY["EPSG","9122"]],
|
18
|
+
AUTHORITY["EPSG","4326"]],
|
19
|
+
PROJECTION["Transverse_Mercator"],
|
20
|
+
PARAMETER["latitude_of_origin",0],
|
21
|
+
PARAMETER["central_meridian",3],
|
22
|
+
PARAMETER["scale_factor",0.9996],
|
23
|
+
PARAMETER["false_easting",500000],
|
24
|
+
PARAMETER["false_northing",0],
|
25
|
+
UNIT["metre",1,
|
26
|
+
AUTHORITY["EPSG","9001"]],
|
27
|
+
AXIS["Easting",EAST],
|
28
|
+
AXIS["Northing",NORTH],
|
29
|
+
AUTHORITY["EPSG","32631"]]
|
30
|
+
EOS
|
31
|
+
Proj::Crs.new(wkt)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_built_in
|
35
|
+
ellipsoids = Proj::Ellipsoid.built_in.map {|ellipsoid| ellipsoid[:id] }
|
8
36
|
assert(ellipsoids.include?('WGS84'))
|
9
37
|
assert(ellipsoids.include?('bessel'))
|
10
38
|
assert(ellipsoids.include?('lerch'))
|
11
39
|
end
|
12
40
|
|
13
|
-
def
|
14
|
-
ellipsoid = Proj::Ellipsoid.
|
15
|
-
|
16
|
-
assert_equal(
|
17
|
-
assert_equal(
|
18
|
-
assert_equal(
|
19
|
-
assert_equal(
|
20
|
-
|
21
|
-
|
41
|
+
def test_from_database
|
42
|
+
ellipsoid = Proj::Ellipsoid.create_from_database("EPSG", "7030", :PJ_CATEGORY_ELLIPSOID)
|
43
|
+
assert_instance_of(Proj::Ellipsoid, ellipsoid)
|
44
|
+
assert_equal(:PJ_TYPE_ELLIPSOID, ellipsoid.proj_type)
|
45
|
+
assert_equal("EPSG", ellipsoid.auth_name)
|
46
|
+
assert_equal("WGS 84", ellipsoid.name)
|
47
|
+
assert_equal("7030", ellipsoid.id_code)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_parameters
|
51
|
+
ellipsoid = parameter_crs.ellipsoid
|
52
|
+
params = ellipsoid.parameters
|
53
|
+
|
54
|
+
expected = {semi_major_axis: 6378137.0,
|
55
|
+
semi_minor_axis: 6356752.314245179,
|
56
|
+
semi_minor_axis_computed: true,
|
57
|
+
inverse_flattening: 298.257223563}
|
58
|
+
assert_equal(expected, params)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_semi_major_axis
|
62
|
+
meridian = parameter_crs.ellipsoid
|
63
|
+
assert_equal(6378137.0, meridian.semi_major_axis)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_semi_minor_axis
|
67
|
+
meridian = parameter_crs.ellipsoid
|
68
|
+
assert_equal(6356752.314245179, meridian.semi_minor_axis)
|
22
69
|
end
|
23
70
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
assert e1 == e2
|
71
|
+
def test_semi_minor_axis_computed
|
72
|
+
meridian = parameter_crs.ellipsoid
|
73
|
+
assert(meridian.semi_minor_axis_computed)
|
28
74
|
end
|
29
75
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
76
|
+
def test_inverse_flattening
|
77
|
+
meridian = parameter_crs.ellipsoid
|
78
|
+
assert_equal(298.257223563, meridian.inverse_flattening)
|
33
79
|
end
|
34
80
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class FileApiTest < AbstractTest
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
# Make sure FileAPI callbacks are not GCed
|
9
|
+
#GC.stress = true
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
super
|
14
|
+
GC.stress = false
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def test_read
|
19
|
+
skip "This test causes a segfault due to the way Proj cleans up on shutdown"
|
20
|
+
context = Proj::Context.new
|
21
|
+
# Network needs to be on for grid delete to work
|
22
|
+
context.network_enabled = true
|
23
|
+
|
24
|
+
# Create a grid
|
25
|
+
grid = Proj::Grid.new("dk_sdfe_dvr90.tif", context)
|
26
|
+
grid.delete
|
27
|
+
|
28
|
+
grid.download
|
29
|
+
assert(grid.downloaded?)
|
30
|
+
context.network_enabled = false
|
31
|
+
|
32
|
+
# Hook up a custom FileApiImpl
|
33
|
+
context.set_file_api(Proj::FileApiImpl)
|
34
|
+
|
35
|
+
conversion = Proj::Conversion.new(<<~EOS, context)
|
36
|
+
+proj=pipeline
|
37
|
+
+step +proj=unitconvert +xy_in=deg +xy_out=rad
|
38
|
+
+step +proj=vgridshift +grids=dk_sdfe_dvr90.tif +multiplier=1
|
39
|
+
+step +proj=unitconvert +xy_in=rad +xy_out=deg
|
40
|
+
EOS
|
41
|
+
|
42
|
+
coord = Proj::Coordinate.new(lon: 12, lat: 56, z: 0)
|
43
|
+
new_coord = conversion.forward(coord)
|
44
|
+
assert_in_delta(12, new_coord.lon)
|
45
|
+
assert_in_delta(56, new_coord.lat)
|
46
|
+
assert_in_delta(36.5909996032715, new_coord.z, 1e-10)
|
47
|
+
|
48
|
+
context.destroy
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_write
|
52
|
+
skip "This test causes a segfault due to the way Proj cleans up on shutdown"
|
53
|
+
|
54
|
+
context = Proj::Context.new
|
55
|
+
context.network_enabled = true
|
56
|
+
|
57
|
+
# Create a grid
|
58
|
+
grid = Proj::Grid.new("dk_sdfe_dvr90.tif", context)
|
59
|
+
grid.delete
|
60
|
+
|
61
|
+
context.set_file_api(Proj::FileApiImpl)
|
62
|
+
grid.download
|
63
|
+
|
64
|
+
assert(grid.downloaded?)
|
65
|
+
end
|
66
|
+
end
|