proj4rb 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ChangeLog +46 -0
- data/Gemfile +4 -0
- data/README.rdoc +158 -148
- data/Rakefile +26 -41
- data/lib/area.rb +32 -0
- data/lib/config.rb +70 -0
- data/lib/context.rb +103 -0
- data/lib/coordinate.rb +197 -0
- data/lib/crs.rb +206 -0
- data/lib/ellipsoid.rb +42 -0
- data/lib/error.rb +18 -0
- data/lib/operation.rb +43 -0
- data/lib/pj_object.rb +82 -0
- data/lib/point.rb +72 -0
- data/lib/prime_meridian.rb +40 -0
- data/lib/proj.rb +31 -0
- data/lib/proj4.rb +3 -469
- data/lib/projection.rb +207 -0
- data/lib/transformation.rb +61 -0
- data/lib/unit.rb +54 -0
- data/proj4rb.gemspec +31 -0
- data/test/abstract_test.rb +7 -0
- data/test/context_test.rb +82 -0
- data/test/coordinate_test.rb +35 -0
- data/test/crs_test.rb +373 -0
- data/test/ellipsoid_test.rb +34 -0
- data/test/operation_test.rb +29 -0
- data/test/prime_meridians_test.rb +33 -0
- data/test/proj_test.rb +17 -0
- data/test/projection_test.rb +224 -0
- data/test/transformation_test.rb +68 -0
- data/test/unit_test.rb +47 -0
- metadata +82 -77
- data/data/GL27 +0 -22
- data/data/MD +0 -0
- data/data/TN +0 -0
- data/data/WI +0 -0
- data/data/WO +0 -0
- data/data/conus +0 -0
- data/data/epsg +0 -5443
- data/data/epsg-deprecated +0 -2
- data/data/esri +0 -5937
- data/data/esri.extra +0 -948
- data/data/hawaii +0 -0
- data/data/nad.lst +0 -142
- data/data/nad27 +0 -809
- data/data/nad83 +0 -744
- data/data/ntv1_can.dat +0 -0
- data/data/null +0 -0
- data/data/other.extra +0 -49
- data/data/proj_def.dat +0 -17
- data/data/prvi +0 -0
- data/data/stgeorge +0 -0
- data/data/stlrnc +0 -0
- data/data/stpaul +0 -0
- data/data/world +0 -212
- data/example/basic.rb +0 -18
- data/example/list-datums.rb +0 -17
- data/example/list-ellipsoids.rb +0 -17
- data/example/list-errors.rb +0 -11
- data/example/list-prime-meridians.rb +0 -17
- data/example/list-projection-types.rb +0 -17
- data/example/list-units.rb +0 -17
- data/example/version.rb +0 -8
- data/ext/Makefile +0 -238
- data/ext/extconf.rb +0 -16
- data/ext/mkmf.log +0 -103
- data/ext/out.log +0 -0
- data/ext/proj4_ruby-x64-mingw32.def +0 -2
- data/ext/proj4_ruby.so +0 -0
- data/ext/projrb.c +0 -566
- data/ext/projrb.o +0 -0
- data/ext/vc/proj4_ruby.sln +0 -19
- data/ext/vc/proj4_ruby.vcproj +0 -208
- data/test/test_constants.rb +0 -18
- data/test/test_create_projection.rb +0 -63
- data/test/test_datums.rb +0 -45
- data/test/test_ellipsoids.rb +0 -46
- data/test/test_errors.rb +0 -66
- data/test/test_init_projection.rb +0 -109
- data/test/test_prime_meridians.rb +0 -45
- data/test/test_projection_type.rb +0 -44
- data/test/test_simple_projection.rb +0 -58
- data/test/test_suite.rb +0 -14
- data/test/test_transform.rb +0 -115
- data/test/test_units.rb +0 -46
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class CoordinateTest < AbstractTest
|
6
|
+
def test_create_xyzt
|
7
|
+
coord = Proj::Coordinate.new(:x => 1, :y => 2, :z => 3, :t => 4)
|
8
|
+
assert_equal('v0: 1.0, v1: 2.0, v2: 3.0, v3: 4.0', coord.to_s)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_create_uvwt
|
12
|
+
coord = Proj::Coordinate.new(:u => 5, :v => 6, :w => 7, :t => 8)
|
13
|
+
assert_equal('v0: 5.0, v1: 6.0, v2: 7.0, v3: 8.0', coord.to_s)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_create_lpzt
|
17
|
+
coord = Proj::Coordinate.new(:lam => 9, :phi => 10, :z => 11, :t => 12)
|
18
|
+
assert_equal('v0: 9.0, v1: 10.0, v2: 11.0, v3: 12.0', coord.to_s)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_create_geod
|
22
|
+
coord = Proj::Coordinate.new(:s => 13, :a1 => 14, :a2 => 15)
|
23
|
+
assert_equal('v0: 13.0, v1: 14.0, v2: 15.0, v3: 0.0', coord.to_s)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_opk
|
27
|
+
coord = Proj::Coordinate.new(:o => 16, :p => 17, :k => 18)
|
28
|
+
assert_equal('v0: 16.0, v1: 17.0, v2: 18.0, v3: 0.0', coord.to_s)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_create_enu
|
32
|
+
coord = Proj::Coordinate.new(:e => 19, :n => 20, :u => 21)
|
33
|
+
assert_equal('v0: 19.0, v1: 20.0, v2: 21.0, v3: 0.0', coord.to_s)
|
34
|
+
end
|
35
|
+
end
|
data/test/crs_test.rb
ADDED
@@ -0,0 +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.1/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
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class EllipsoidTest < AbstractTest
|
6
|
+
def test_get_all
|
7
|
+
ellipsoids = Proj::Ellipsoid.list.map {|ellipsoid| ellipsoid.id }
|
8
|
+
assert(ellipsoids.include?('WGS84'))
|
9
|
+
assert(ellipsoids.include?('bessel'))
|
10
|
+
assert(ellipsoids.include?('lerch'))
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_one
|
14
|
+
ellipsoid = Proj::Ellipsoid.get('bessel')
|
15
|
+
assert_kind_of Proj::Ellipsoid, ellipsoid
|
16
|
+
assert_equal('bessel', ellipsoid.id)
|
17
|
+
assert_equal('a=6377397.155', ellipsoid.major)
|
18
|
+
assert_equal('rf=299.1528128', ellipsoid.ell)
|
19
|
+
assert_equal('Bessel 1841', ellipsoid.name)
|
20
|
+
assert_equal('bessel', ellipsoid.to_s)
|
21
|
+
assert_equal('#<Proj::Ellipsoid id="bessel", major="a=6377397.155", ell="rf=299.1528128", name="Bessel 1841">', ellipsoid.inspect)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_equal
|
25
|
+
e1 = Proj::Ellipsoid.get('bessel')
|
26
|
+
e2 = Proj::Ellipsoid.get('bessel')
|
27
|
+
assert e1 == e2
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_failed_get
|
31
|
+
ellipsoid = Proj::Ellipsoid.get('foo')
|
32
|
+
assert_nil ellipsoid
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './abstract_test'
|
4
|
+
|
5
|
+
class OperationTest < AbstractTest
|
6
|
+
def test_get_all
|
7
|
+
operations = Proj::Operation.list.map {|operation| operation.id}
|
8
|
+
assert(operations.include?('aea'))
|
9
|
+
assert(operations.include?('wintri'))
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_one
|
13
|
+
operation = Proj::Operation.get('rouss')
|
14
|
+
assert_kind_of(Proj::Operation, operation)
|
15
|
+
assert_equal('rouss', operation.id)
|
16
|
+
assert_equal("Roussilhe Stereographic\n\tAzi, Ell", operation.description)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_equal
|
20
|
+
e1 = Proj::Operation.get('rouss')
|
21
|
+
e2 = Proj::Operation.get('rouss')
|
22
|
+
assert(e1 == e2)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_failed_get
|
26
|
+
operation = Proj::Operation.get('foo')
|
27
|
+
assert_nil(operation)
|
28
|
+
end
|
29
|
+
end
|