forked from yocontra/node-gdal-next
-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathopen_netcdf.test.ts
40 lines (33 loc) · 1.46 KB
/
open_netcdf.test.ts
1
2
3
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
import * as gdal from 'gdal-async'
import * as path from 'path'
import { assert } from 'chai'
describe('Open', () => {
afterEach(() => void global.gc!())
describe('NetCDF', () => {
let filename, ds: gdal.Dataset
it('should not throw', () => {
filename = path.join(__dirname, 'data/gfs.t00z.alnsf.nc')
ds = gdal.open(filename)
})
it('should be able to read raster size', () => {
assert.equal(ds.rasterSize.x, 90)
assert.equal(ds.rasterSize.y, 45)
assert.equal(ds.bands.count(), 1)
})
it('should be able to read geotransform', () => {
const expected_geotransform = [ -0.05859375, 4, 0, 89.9679127646579815, 0, -4 ]
const actual_geotransform = ds.geoTransform
const delta = 0.00001
if (actual_geotransform === null) throw new Error('No GeoTransform')
assert.closeTo(actual_geotransform[0], expected_geotransform[0], delta)
assert.closeTo(actual_geotransform[1], expected_geotransform[1], delta)
assert.closeTo(actual_geotransform[2], expected_geotransform[2], delta)
assert.closeTo(actual_geotransform[3], expected_geotransform[3], delta)
assert.closeTo(actual_geotransform[4], expected_geotransform[4], delta)
assert.closeTo(actual_geotransform[5], expected_geotransform[5], delta)
})
it('on Linux, with bundled GDAL, it should support should virtual IO', () => {
assert.equal(gdal.drivers.get('netcdf').getMetadata().DCAP_VIRTUALIO, 'YES')
})
})
})