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/crs_test.rb
CHANGED
@@ -1,373 +1,373 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require_relative './abstract_test'
|
4
|
-
|
5
|
-
class CrsTest < AbstractTest
|
6
|
-
def test_create_from_epsg
|
7
|
-
crs = Proj::Crs.new('EPSG:4326')
|
8
|
-
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, crs.proj_type)
|
9
|
-
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', crs.to_proj_string)
|
10
|
-
|
11
|
-
assert_nil(crs.id)
|
12
|
-
assert_equal('WGS 84', crs.description)
|
13
|
-
assert_empty(crs.definition)
|
14
|
-
refute(crs.has_inverse?)
|
15
|
-
assert_equal(-1.0, crs.accuracy)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_create_from_urn
|
19
|
-
crs = Proj::Crs.new('urn:ogc:def:crs:EPSG::4326')
|
20
|
-
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, crs.proj_type)
|
21
|
-
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', crs.to_proj_string)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_create_from_wkt
|
25
|
-
crs = Proj::Crs.new(<<~EOS)
|
26
|
-
GEOGCRS["WGS 84",
|
27
|
-
DATUM["World Geodetic System 1984",
|
28
|
-
ELLIPSOID["WGS 84",6378137,298.257223563,
|
29
|
-
LENGTHUNIT["metre",1]]],
|
30
|
-
PRIMEM["Greenwich",0,
|
31
|
-
ANGLEUNIT["degree",0.0174532925199433]],
|
32
|
-
CS[ellipsoidal,2],
|
33
|
-
AXIS["geodetic latitude (Lat)",north,
|
34
|
-
ORDER[1],
|
35
|
-
ANGLEUNIT["degree",0.0174532925199433]],
|
36
|
-
AXIS["geodetic longitude (Lon)",east,
|
37
|
-
ORDER[2],
|
38
|
-
ANGLEUNIT["degree",0.0174532925199433]],
|
39
|
-
USAGE[
|
40
|
-
SCOPE["unknown"],
|
41
|
-
AREA["World"],
|
42
|
-
BBOX[-90,-180,90,180]],
|
43
|
-
ID["EPSG",4326]]
|
44
|
-
EOS
|
45
|
-
|
46
|
-
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, crs.proj_type)
|
47
|
-
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', crs.to_proj_string)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_create_from_proj4
|
51
|
-
crs = Proj::Crs.new('+proj=longlat +datum=WGS84 +no_defs +type=crs')
|
52
|
-
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, crs.proj_type)
|
53
|
-
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', crs.to_proj_string)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_compound
|
57
|
-
crs = Proj::Crs.new('EPSG:2393+5717')
|
58
|
-
assert_equal(:PJ_TYPE_COMPOUND_CRS, crs.proj_type)
|
59
|
-
assert_equal('+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl +units=m +vunits=m +no_defs +type=crs', crs.to_proj_string)
|
60
|
-
|
61
|
-
crs = Proj::Crs.new('urn:ogc:def:crs,crs:EPSG::2393,crs:EPSG::5717')
|
62
|
-
assert_equal(:PJ_TYPE_COMPOUND_CRS, crs.proj_type)
|
63
|
-
assert_equal('+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl +units=m +vunits=m +no_defs +type=crs', crs.to_proj_string)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_not_crs
|
67
|
-
error = assert_raises(Proj::Error) do
|
68
|
-
Proj::Crs.new('+proj=utm +zone=32 +datum=WGS84')
|
69
|
-
end
|
70
|
-
assert_equal('Invalid crs definition. Proj created an instance of: PJ_TYPE_OTHER_COORDINATE_OPERATION.', error.message)
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_finalize
|
74
|
-
500.times do
|
75
|
-
crs = Proj::Crs.new('EPSG:4326')
|
76
|
-
assert(crs.to_ptr)
|
77
|
-
GC.start
|
78
|
-
end
|
79
|
-
assert(true)
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_geodetic_crs
|
83
|
-
crs = Proj::Crs.new('EPSG:4326')
|
84
|
-
geodetic = crs.geodetic_crs
|
85
|
-
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, geodetic.proj_type)
|
86
|
-
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', geodetic.to_proj_string)
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_datum
|
90
|
-
crs = Proj::Crs.new('EPSG:4326')
|
91
|
-
datum = crs.datum
|
92
|
-
assert_equal(:PJ_TYPE_GEODETIC_REFERENCE_FRAME, datum.proj_type)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_horizontal_datum
|
96
|
-
crs = Proj::Crs.new('EPSG:4326')
|
97
|
-
datum = crs.horizontal_datum
|
98
|
-
assert_equal(:PJ_TYPE_GEODETIC_REFERENCE_FRAME, datum.proj_type)
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_coordinate_system
|
102
|
-
crs = Proj::Crs.new('EPSG:4326')
|
103
|
-
cs = crs.coordinate_system
|
104
|
-
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_axis_count
|
108
|
-
crs = Proj::Crs.new('EPSG:4326')
|
109
|
-
count = crs.axis_count
|
110
|
-
assert_equal(2, count)
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_axis_info
|
114
|
-
crs = Proj::Crs.new('EPSG:4326')
|
115
|
-
info = crs.axis_info
|
116
|
-
expected = [{:name=>"Geodetic latitude",
|
117
|
-
:abbreviation=>"Lat",
|
118
|
-
:direction=>"north",
|
119
|
-
:unit_conv_factor=>0.017453292519943295,
|
120
|
-
:unit_name=>"degree",
|
121
|
-
:unit_auth_name=>"EPSG",
|
122
|
-
:unit_code=>"9122"},
|
123
|
-
{:name=>"Geodetic longitude",
|
124
|
-
:abbreviation=>"Lon",
|
125
|
-
:direction=>"east",
|
126
|
-
:unit_conv_factor=>0.017453292519943295,
|
127
|
-
:unit_name=>"degree",
|
128
|
-
:unit_auth_name=>"EPSG",
|
129
|
-
:unit_code=>"9122"}]
|
130
|
-
|
131
|
-
assert_equal(expected, info)
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_crs_type
|
135
|
-
crs = Proj::Crs.new('EPSG:4326')
|
136
|
-
crs_type = crs.crs_type
|
137
|
-
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, crs_type)
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_ellipsoid
|
141
|
-
crs = Proj::Crs.new('EPSG:4326')
|
142
|
-
ellipsoid = crs.ellipsoid
|
143
|
-
assert_equal(:PJ_TYPE_ELLIPSOID, ellipsoid.proj_type)
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_prime_meridian
|
147
|
-
crs = Proj::Crs.new('EPSG:4326')
|
148
|
-
prime_meridian = crs.prime_meridian
|
149
|
-
assert_equal('Greenwich', prime_meridian.name)
|
150
|
-
end
|
151
|
-
|
152
|
-
#def test_operation
|
153
|
-
# crs = Proj::Crs.new('EPSG:4326')
|
154
|
-
# operation = crs.operation
|
155
|
-
# assert_equal('Greenwich', operation.name)
|
156
|
-
#end
|
157
|
-
|
158
|
-
def test_area
|
159
|
-
crs = Proj::Crs.new('EPSG:4326')
|
160
|
-
assert_kind_of(Proj::Area, crs.area)
|
161
|
-
assert_equal('World', crs.area.name)
|
162
|
-
assert_in_delta(-180.0, crs.area.west_lon_degree, 0.1)
|
163
|
-
assert_in_delta(-90.0, crs.area.south_lat_degree, 0.1)
|
164
|
-
assert_in_delta(180.0, crs.area.east_lon_degree, 0.1)
|
165
|
-
assert_in_delta(90.0, crs.area.north_lat_degree, 0.1)
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_to_proj_string
|
169
|
-
crs = Proj::Crs.new('EPSG:26915')
|
170
|
-
assert_equal('+proj=utm +zone=15 +datum=NAD83 +units=m +no_defs +type=crs', crs.to_proj_string)
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_to_wkt
|
174
|
-
crs = Proj::Crs.new('EPSG:26915')
|
175
|
-
|
176
|
-
expected = <<~EOS
|
177
|
-
PROJCRS["NAD83 / UTM zone 15N",
|
178
|
-
BASEGEOGCRS["NAD83",
|
179
|
-
DATUM["North American Datum 1983",
|
180
|
-
ELLIPSOID["GRS 1980",6378137,298.257222101,
|
181
|
-
LENGTHUNIT["metre",1]]],
|
182
|
-
PRIMEM["Greenwich",0,
|
183
|
-
ANGLEUNIT["degree",0.0174532925199433]],
|
184
|
-
ID["EPSG",4269]],
|
185
|
-
CONVERSION["UTM zone 15N",
|
186
|
-
METHOD["Transverse Mercator",
|
187
|
-
ID["EPSG",9807]],
|
188
|
-
PARAMETER["Latitude of natural origin",0,
|
189
|
-
ANGLEUNIT["degree",0.0174532925199433],
|
190
|
-
ID["EPSG",8801]],
|
191
|
-
PARAMETER["Longitude of natural origin",-93,
|
192
|
-
ANGLEUNIT["degree",0.0174532925199433],
|
193
|
-
ID["EPSG",8802]],
|
194
|
-
PARAMETER["Scale factor at natural origin",0.9996,
|
195
|
-
SCALEUNIT["unity",1],
|
196
|
-
ID["EPSG",8805]],
|
197
|
-
PARAMETER["False easting",500000,
|
198
|
-
LENGTHUNIT["metre",1],
|
199
|
-
ID["EPSG",8806]],
|
200
|
-
PARAMETER["False northing",0,
|
201
|
-
LENGTHUNIT["metre",1],
|
202
|
-
ID["EPSG",8807]]],
|
203
|
-
CS[Cartesian,2],
|
204
|
-
AXIS["(E)",east,
|
205
|
-
ORDER[1],
|
206
|
-
LENGTHUNIT["metre",1]],
|
207
|
-
AXIS["(N)",north,
|
208
|
-
ORDER[2],
|
209
|
-
LENGTHUNIT["metre",1]],
|
210
|
-
USAGE[
|
211
|
-
SCOPE["unknown"],
|
212
|
-
AREA["North America - 96\xC2\xB0W to 90\xC2\xB0W and NAD83 by country"],
|
213
|
-
BBOX[25.61,-96,84,-90]],
|
214
|
-
ID["EPSG",26915]]
|
215
|
-
EOS
|
216
|
-
|
217
|
-
assert_equal(expected.strip, crs.to_wkt)
|
218
|
-
end
|
219
|
-
|
220
|
-
def test_to_json
|
221
|
-
crs = Proj::Crs.new('EPSG:26915')
|
222
|
-
expected = <<~EOS
|
223
|
-
{
|
224
|
-
"$schema": "https://proj.org/schemas/v0.
|
225
|
-
"type": "ProjectedCRS",
|
226
|
-
"name": "NAD83 / UTM zone 15N",
|
227
|
-
"base_crs": {
|
228
|
-
"name": "NAD83",
|
229
|
-
"datum": {
|
230
|
-
"type": "GeodeticReferenceFrame",
|
231
|
-
"name": "North American Datum 1983",
|
232
|
-
"ellipsoid": {
|
233
|
-
"name": "GRS 1980",
|
234
|
-
"semi_major_axis": 6378137,
|
235
|
-
"inverse_flattening": 298.257222101
|
236
|
-
}
|
237
|
-
},
|
238
|
-
"coordinate_system": {
|
239
|
-
"subtype": "ellipsoidal",
|
240
|
-
"axis": [
|
241
|
-
{
|
242
|
-
"name": "Geodetic latitude",
|
243
|
-
"abbreviation": "Lat",
|
244
|
-
"direction": "north",
|
245
|
-
"unit": "degree"
|
246
|
-
},
|
247
|
-
{
|
248
|
-
"name": "Geodetic longitude",
|
249
|
-
"abbreviation": "Lon",
|
250
|
-
"direction": "east",
|
251
|
-
"unit": "degree"
|
252
|
-
}
|
253
|
-
]
|
254
|
-
},
|
255
|
-
"id": {
|
256
|
-
"authority": "EPSG",
|
257
|
-
"code": 4269
|
258
|
-
}
|
259
|
-
},
|
260
|
-
"conversion": {
|
261
|
-
"name": "UTM zone 15N",
|
262
|
-
"method": {
|
263
|
-
"name": "Transverse Mercator",
|
264
|
-
"id": {
|
265
|
-
"authority": "EPSG",
|
266
|
-
"code": 9807
|
267
|
-
}
|
268
|
-
},
|
269
|
-
"parameters": [
|
270
|
-
{
|
271
|
-
"name": "Latitude of natural origin",
|
272
|
-
"value": 0,
|
273
|
-
"unit": "degree",
|
274
|
-
"id": {
|
275
|
-
"authority": "EPSG",
|
276
|
-
"code": 8801
|
277
|
-
}
|
278
|
-
},
|
279
|
-
{
|
280
|
-
"name": "Longitude of natural origin",
|
281
|
-
"value": -93,
|
282
|
-
"unit": "degree",
|
283
|
-
"id": {
|
284
|
-
"authority": "EPSG",
|
285
|
-
"code": 8802
|
286
|
-
}
|
287
|
-
},
|
288
|
-
{
|
289
|
-
"name": "Scale factor at natural origin",
|
290
|
-
"value": 0.9996,
|
291
|
-
"unit": "unity",
|
292
|
-
"id": {
|
293
|
-
"authority": "EPSG",
|
294
|
-
"code": 8805
|
295
|
-
}
|
296
|
-
},
|
297
|
-
{
|
298
|
-
"name": "False easting",
|
299
|
-
"value": 500000,
|
300
|
-
"unit": "metre",
|
301
|
-
"id": {
|
302
|
-
"authority": "EPSG",
|
303
|
-
"code": 8806
|
304
|
-
}
|
305
|
-
},
|
306
|
-
{
|
307
|
-
"name": "False northing",
|
308
|
-
"value": 0,
|
309
|
-
"unit": "metre",
|
310
|
-
"id": {
|
311
|
-
"authority": "EPSG",
|
312
|
-
"code": 8807
|
313
|
-
}
|
314
|
-
}
|
315
|
-
]
|
316
|
-
},
|
317
|
-
"coordinate_system": {
|
318
|
-
"subtype": "Cartesian",
|
319
|
-
"axis": [
|
320
|
-
{
|
321
|
-
"name": "Easting",
|
322
|
-
"abbreviation": "E",
|
323
|
-
"direction": "east",
|
324
|
-
"unit": "metre"
|
325
|
-
},
|
326
|
-
{
|
327
|
-
"name": "Northing",
|
328
|
-
"abbreviation": "N",
|
329
|
-
"direction": "north",
|
330
|
-
"unit": "metre"
|
331
|
-
}
|
332
|
-
]
|
333
|
-
},
|
334
|
-
"area": "North America - 96°W to 90°W and NAD83 by country",
|
335
|
-
"bbox": {
|
336
|
-
"south_latitude": 25.61,
|
337
|
-
"west_longitude": -96,
|
338
|
-
"north_latitude": 84,
|
339
|
-
"east_longitude": -90
|
340
|
-
},
|
341
|
-
"id": {
|
342
|
-
"authority": "EPSG",
|
343
|
-
"code": 26915
|
344
|
-
}
|
345
|
-
}
|
346
|
-
EOS
|
347
|
-
|
348
|
-
assert_equal(expected.strip, crs.to_json)
|
349
|
-
end
|
350
|
-
|
351
|
-
def test_inspect
|
352
|
-
crs = Proj::Crs.new('EPSG:26915')
|
353
|
-
|
354
|
-
expected = <<~EOS
|
355
|
-
<Proj::Crs>: EPSG:26915
|
356
|
-
NAD83 / UTM zone 15N
|
357
|
-
Axis Info [PJ_CS_TYPE_CARTESIAN]:
|
358
|
-
- E[east]: Easting (metre)
|
359
|
-
- N[north]: Northing (metre)
|
360
|
-
Area of Use:
|
361
|
-
- name: North America - 96°W to 90°W and NAD83 by country
|
362
|
-
- bounds: (-96.0, 25.61, -90.0, 84.0)
|
363
|
-
Coordinate operation:
|
364
|
-
- name: ?
|
365
|
-
- method: ?
|
366
|
-
Datum: North American Datum 1983
|
367
|
-
- Ellipsoid: GRS 1980
|
368
|
-
- Prime Meridian: Greenwich
|
369
|
-
EOS
|
370
|
-
|
371
|
-
assert_equal(expected, crs.inspect)
|
372
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class CrsTest < AbstractTest
|
6
|
+
def test_create_from_epsg
|
7
|
+
crs = Proj::Crs.new('EPSG:4326')
|
8
|
+
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, crs.proj_type)
|
9
|
+
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', crs.to_proj_string)
|
10
|
+
|
11
|
+
assert_nil(crs.id)
|
12
|
+
assert_equal('WGS 84', crs.description)
|
13
|
+
assert_empty(crs.definition)
|
14
|
+
refute(crs.has_inverse?)
|
15
|
+
assert_equal(-1.0, crs.accuracy)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create_from_urn
|
19
|
+
crs = Proj::Crs.new('urn:ogc:def:crs:EPSG::4326')
|
20
|
+
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, crs.proj_type)
|
21
|
+
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', crs.to_proj_string)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_create_from_wkt
|
25
|
+
crs = Proj::Crs.new(<<~EOS)
|
26
|
+
GEOGCRS["WGS 84",
|
27
|
+
DATUM["World Geodetic System 1984",
|
28
|
+
ELLIPSOID["WGS 84",6378137,298.257223563,
|
29
|
+
LENGTHUNIT["metre",1]]],
|
30
|
+
PRIMEM["Greenwich",0,
|
31
|
+
ANGLEUNIT["degree",0.0174532925199433]],
|
32
|
+
CS[ellipsoidal,2],
|
33
|
+
AXIS["geodetic latitude (Lat)",north,
|
34
|
+
ORDER[1],
|
35
|
+
ANGLEUNIT["degree",0.0174532925199433]],
|
36
|
+
AXIS["geodetic longitude (Lon)",east,
|
37
|
+
ORDER[2],
|
38
|
+
ANGLEUNIT["degree",0.0174532925199433]],
|
39
|
+
USAGE[
|
40
|
+
SCOPE["unknown"],
|
41
|
+
AREA["World"],
|
42
|
+
BBOX[-90,-180,90,180]],
|
43
|
+
ID["EPSG",4326]]
|
44
|
+
EOS
|
45
|
+
|
46
|
+
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, crs.proj_type)
|
47
|
+
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', crs.to_proj_string)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_create_from_proj4
|
51
|
+
crs = Proj::Crs.new('+proj=longlat +datum=WGS84 +no_defs +type=crs')
|
52
|
+
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, crs.proj_type)
|
53
|
+
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', crs.to_proj_string)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_compound
|
57
|
+
crs = Proj::Crs.new('EPSG:2393+5717')
|
58
|
+
assert_equal(:PJ_TYPE_COMPOUND_CRS, crs.proj_type)
|
59
|
+
assert_equal('+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl +units=m +vunits=m +no_defs +type=crs', crs.to_proj_string)
|
60
|
+
|
61
|
+
crs = Proj::Crs.new('urn:ogc:def:crs,crs:EPSG::2393,crs:EPSG::5717')
|
62
|
+
assert_equal(:PJ_TYPE_COMPOUND_CRS, crs.proj_type)
|
63
|
+
assert_equal('+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl +units=m +vunits=m +no_defs +type=crs', crs.to_proj_string)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_not_crs
|
67
|
+
error = assert_raises(Proj::Error) do
|
68
|
+
Proj::Crs.new('+proj=utm +zone=32 +datum=WGS84')
|
69
|
+
end
|
70
|
+
assert_equal('Invalid crs definition. Proj created an instance of: PJ_TYPE_OTHER_COORDINATE_OPERATION.', error.message)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_finalize
|
74
|
+
500.times do
|
75
|
+
crs = Proj::Crs.new('EPSG:4326')
|
76
|
+
assert(crs.to_ptr)
|
77
|
+
GC.start
|
78
|
+
end
|
79
|
+
assert(true)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_geodetic_crs
|
83
|
+
crs = Proj::Crs.new('EPSG:4326')
|
84
|
+
geodetic = crs.geodetic_crs
|
85
|
+
assert_equal(:PJ_TYPE_GEOGRAPHIC_2D_CRS, geodetic.proj_type)
|
86
|
+
assert_equal('+proj=longlat +datum=WGS84 +no_defs +type=crs', geodetic.to_proj_string)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_datum
|
90
|
+
crs = Proj::Crs.new('EPSG:4326')
|
91
|
+
datum = crs.datum
|
92
|
+
assert_equal(:PJ_TYPE_GEODETIC_REFERENCE_FRAME, datum.proj_type)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_horizontal_datum
|
96
|
+
crs = Proj::Crs.new('EPSG:4326')
|
97
|
+
datum = crs.horizontal_datum
|
98
|
+
assert_equal(:PJ_TYPE_GEODETIC_REFERENCE_FRAME, datum.proj_type)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_coordinate_system
|
102
|
+
crs = Proj::Crs.new('EPSG:4326')
|
103
|
+
cs = crs.coordinate_system
|
104
|
+
assert_equal(:PJ_TYPE_UNKNOWN, cs.proj_type)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_axis_count
|
108
|
+
crs = Proj::Crs.new('EPSG:4326')
|
109
|
+
count = crs.axis_count
|
110
|
+
assert_equal(2, count)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_axis_info
|
114
|
+
crs = Proj::Crs.new('EPSG:4326')
|
115
|
+
info = crs.axis_info
|
116
|
+
expected = [{:name=>"Geodetic latitude",
|
117
|
+
:abbreviation=>"Lat",
|
118
|
+
:direction=>"north",
|
119
|
+
:unit_conv_factor=>0.017453292519943295,
|
120
|
+
:unit_name=>"degree",
|
121
|
+
:unit_auth_name=>"EPSG",
|
122
|
+
:unit_code=>"9122"},
|
123
|
+
{:name=>"Geodetic longitude",
|
124
|
+
:abbreviation=>"Lon",
|
125
|
+
:direction=>"east",
|
126
|
+
:unit_conv_factor=>0.017453292519943295,
|
127
|
+
:unit_name=>"degree",
|
128
|
+
:unit_auth_name=>"EPSG",
|
129
|
+
:unit_code=>"9122"}]
|
130
|
+
|
131
|
+
assert_equal(expected, info)
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_crs_type
|
135
|
+
crs = Proj::Crs.new('EPSG:4326')
|
136
|
+
crs_type = crs.crs_type
|
137
|
+
assert_equal(:PJ_CS_TYPE_ELLIPSOIDAL, crs_type)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_ellipsoid
|
141
|
+
crs = Proj::Crs.new('EPSG:4326')
|
142
|
+
ellipsoid = crs.ellipsoid
|
143
|
+
assert_equal(:PJ_TYPE_ELLIPSOID, ellipsoid.proj_type)
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_prime_meridian
|
147
|
+
crs = Proj::Crs.new('EPSG:4326')
|
148
|
+
prime_meridian = crs.prime_meridian
|
149
|
+
assert_equal('Greenwich', prime_meridian.name)
|
150
|
+
end
|
151
|
+
|
152
|
+
#def test_operation
|
153
|
+
# crs = Proj::Crs.new('EPSG:4326')
|
154
|
+
# operation = crs.operation
|
155
|
+
# assert_equal('Greenwich', operation.name)
|
156
|
+
#end
|
157
|
+
|
158
|
+
def test_area
|
159
|
+
crs = Proj::Crs.new('EPSG:4326')
|
160
|
+
assert_kind_of(Proj::Area, crs.area)
|
161
|
+
assert_equal('World', crs.area.name)
|
162
|
+
assert_in_delta(-180.0, crs.area.west_lon_degree, 0.1)
|
163
|
+
assert_in_delta(-90.0, crs.area.south_lat_degree, 0.1)
|
164
|
+
assert_in_delta(180.0, crs.area.east_lon_degree, 0.1)
|
165
|
+
assert_in_delta(90.0, crs.area.north_lat_degree, 0.1)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_to_proj_string
|
169
|
+
crs = Proj::Crs.new('EPSG:26915')
|
170
|
+
assert_equal('+proj=utm +zone=15 +datum=NAD83 +units=m +no_defs +type=crs', crs.to_proj_string)
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_to_wkt
|
174
|
+
crs = Proj::Crs.new('EPSG:26915')
|
175
|
+
|
176
|
+
expected = <<~EOS
|
177
|
+
PROJCRS["NAD83 / UTM zone 15N",
|
178
|
+
BASEGEOGCRS["NAD83",
|
179
|
+
DATUM["North American Datum 1983",
|
180
|
+
ELLIPSOID["GRS 1980",6378137,298.257222101,
|
181
|
+
LENGTHUNIT["metre",1]]],
|
182
|
+
PRIMEM["Greenwich",0,
|
183
|
+
ANGLEUNIT["degree",0.0174532925199433]],
|
184
|
+
ID["EPSG",4269]],
|
185
|
+
CONVERSION["UTM zone 15N",
|
186
|
+
METHOD["Transverse Mercator",
|
187
|
+
ID["EPSG",9807]],
|
188
|
+
PARAMETER["Latitude of natural origin",0,
|
189
|
+
ANGLEUNIT["degree",0.0174532925199433],
|
190
|
+
ID["EPSG",8801]],
|
191
|
+
PARAMETER["Longitude of natural origin",-93,
|
192
|
+
ANGLEUNIT["degree",0.0174532925199433],
|
193
|
+
ID["EPSG",8802]],
|
194
|
+
PARAMETER["Scale factor at natural origin",0.9996,
|
195
|
+
SCALEUNIT["unity",1],
|
196
|
+
ID["EPSG",8805]],
|
197
|
+
PARAMETER["False easting",500000,
|
198
|
+
LENGTHUNIT["metre",1],
|
199
|
+
ID["EPSG",8806]],
|
200
|
+
PARAMETER["False northing",0,
|
201
|
+
LENGTHUNIT["metre",1],
|
202
|
+
ID["EPSG",8807]]],
|
203
|
+
CS[Cartesian,2],
|
204
|
+
AXIS["(E)",east,
|
205
|
+
ORDER[1],
|
206
|
+
LENGTHUNIT["metre",1]],
|
207
|
+
AXIS["(N)",north,
|
208
|
+
ORDER[2],
|
209
|
+
LENGTHUNIT["metre",1]],
|
210
|
+
USAGE[
|
211
|
+
SCOPE["unknown"],
|
212
|
+
AREA["North America - 96\xC2\xB0W to 90\xC2\xB0W and NAD83 by country"],
|
213
|
+
BBOX[25.61,-96,84,-90]],
|
214
|
+
ID["EPSG",26915]]
|
215
|
+
EOS
|
216
|
+
|
217
|
+
assert_equal(expected.strip, crs.to_wkt)
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_to_json
|
221
|
+
crs = Proj::Crs.new('EPSG:26915')
|
222
|
+
expected = <<~EOS
|
223
|
+
{
|
224
|
+
"$schema": "https://proj.org/schemas/v0.2/projjson.schema.json",
|
225
|
+
"type": "ProjectedCRS",
|
226
|
+
"name": "NAD83 / UTM zone 15N",
|
227
|
+
"base_crs": {
|
228
|
+
"name": "NAD83",
|
229
|
+
"datum": {
|
230
|
+
"type": "GeodeticReferenceFrame",
|
231
|
+
"name": "North American Datum 1983",
|
232
|
+
"ellipsoid": {
|
233
|
+
"name": "GRS 1980",
|
234
|
+
"semi_major_axis": 6378137,
|
235
|
+
"inverse_flattening": 298.257222101
|
236
|
+
}
|
237
|
+
},
|
238
|
+
"coordinate_system": {
|
239
|
+
"subtype": "ellipsoidal",
|
240
|
+
"axis": [
|
241
|
+
{
|
242
|
+
"name": "Geodetic latitude",
|
243
|
+
"abbreviation": "Lat",
|
244
|
+
"direction": "north",
|
245
|
+
"unit": "degree"
|
246
|
+
},
|
247
|
+
{
|
248
|
+
"name": "Geodetic longitude",
|
249
|
+
"abbreviation": "Lon",
|
250
|
+
"direction": "east",
|
251
|
+
"unit": "degree"
|
252
|
+
}
|
253
|
+
]
|
254
|
+
},
|
255
|
+
"id": {
|
256
|
+
"authority": "EPSG",
|
257
|
+
"code": 4269
|
258
|
+
}
|
259
|
+
},
|
260
|
+
"conversion": {
|
261
|
+
"name": "UTM zone 15N",
|
262
|
+
"method": {
|
263
|
+
"name": "Transverse Mercator",
|
264
|
+
"id": {
|
265
|
+
"authority": "EPSG",
|
266
|
+
"code": 9807
|
267
|
+
}
|
268
|
+
},
|
269
|
+
"parameters": [
|
270
|
+
{
|
271
|
+
"name": "Latitude of natural origin",
|
272
|
+
"value": 0,
|
273
|
+
"unit": "degree",
|
274
|
+
"id": {
|
275
|
+
"authority": "EPSG",
|
276
|
+
"code": 8801
|
277
|
+
}
|
278
|
+
},
|
279
|
+
{
|
280
|
+
"name": "Longitude of natural origin",
|
281
|
+
"value": -93,
|
282
|
+
"unit": "degree",
|
283
|
+
"id": {
|
284
|
+
"authority": "EPSG",
|
285
|
+
"code": 8802
|
286
|
+
}
|
287
|
+
},
|
288
|
+
{
|
289
|
+
"name": "Scale factor at natural origin",
|
290
|
+
"value": 0.9996,
|
291
|
+
"unit": "unity",
|
292
|
+
"id": {
|
293
|
+
"authority": "EPSG",
|
294
|
+
"code": 8805
|
295
|
+
}
|
296
|
+
},
|
297
|
+
{
|
298
|
+
"name": "False easting",
|
299
|
+
"value": 500000,
|
300
|
+
"unit": "metre",
|
301
|
+
"id": {
|
302
|
+
"authority": "EPSG",
|
303
|
+
"code": 8806
|
304
|
+
}
|
305
|
+
},
|
306
|
+
{
|
307
|
+
"name": "False northing",
|
308
|
+
"value": 0,
|
309
|
+
"unit": "metre",
|
310
|
+
"id": {
|
311
|
+
"authority": "EPSG",
|
312
|
+
"code": 8807
|
313
|
+
}
|
314
|
+
}
|
315
|
+
]
|
316
|
+
},
|
317
|
+
"coordinate_system": {
|
318
|
+
"subtype": "Cartesian",
|
319
|
+
"axis": [
|
320
|
+
{
|
321
|
+
"name": "Easting",
|
322
|
+
"abbreviation": "E",
|
323
|
+
"direction": "east",
|
324
|
+
"unit": "metre"
|
325
|
+
},
|
326
|
+
{
|
327
|
+
"name": "Northing",
|
328
|
+
"abbreviation": "N",
|
329
|
+
"direction": "north",
|
330
|
+
"unit": "metre"
|
331
|
+
}
|
332
|
+
]
|
333
|
+
},
|
334
|
+
"area": "North America - 96°W to 90°W and NAD83 by country",
|
335
|
+
"bbox": {
|
336
|
+
"south_latitude": 25.61,
|
337
|
+
"west_longitude": -96,
|
338
|
+
"north_latitude": 84,
|
339
|
+
"east_longitude": -90
|
340
|
+
},
|
341
|
+
"id": {
|
342
|
+
"authority": "EPSG",
|
343
|
+
"code": 26915
|
344
|
+
}
|
345
|
+
}
|
346
|
+
EOS
|
347
|
+
|
348
|
+
assert_equal(expected.strip, crs.to_json)
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_inspect
|
352
|
+
crs = Proj::Crs.new('EPSG:26915')
|
353
|
+
|
354
|
+
expected = <<~EOS
|
355
|
+
<Proj::Crs>: EPSG:26915
|
356
|
+
NAD83 / UTM zone 15N
|
357
|
+
Axis Info [PJ_CS_TYPE_CARTESIAN]:
|
358
|
+
- E[east]: Easting (metre)
|
359
|
+
- N[north]: Northing (metre)
|
360
|
+
Area of Use:
|
361
|
+
- name: North America - 96°W to 90°W and NAD83 by country
|
362
|
+
- bounds: (-96.0, 25.61, -90.0, 84.0)
|
363
|
+
Coordinate operation:
|
364
|
+
- name: ?
|
365
|
+
- method: ?
|
366
|
+
Datum: North American Datum 1983
|
367
|
+
- Ellipsoid: GRS 1980
|
368
|
+
- Prime Meridian: Greenwich
|
369
|
+
EOS
|
370
|
+
|
371
|
+
assert_equal(expected, crs.inspect)
|
372
|
+
end
|
373
373
|
end
|