forked from yocontra/node-gdal-next
-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathopen_vsigzip.test.ts
98 lines (90 loc) · 2.88 KB
/
open_vsigzip.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
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
import * as gdal from 'gdal-async'
import * as path from 'path'
import * as chai from 'chai'
const assert: Chai.Assert = chai.assert
import * as chaiAsPromised from 'chai-as-promised'
chai.use(chaiAsPromised)
describe('Open', () => {
afterEach(() => void global.gc!())
describe('vsigzip', () => {
let filename, ds: gdal.Dataset
it('should not throw', () => {
filename = path.join(__dirname, 'data/vsigzip/hp40ne.gz')
ds = gdal.open(filename)
})
it('should be able to read layer count', () => {
assert.equal(ds.layers.count(), 4)
})
describe('layer', () => {
let layer: gdal.Layer
before(() => {
layer = ds.layers.get(0)
})
it('should have all fields defined', () => {
assert.equal(layer.fields.count(), 8)
assert.deepEqual(layer.fields.getNames(), [
'fid',
'featureCode',
'featureDescription',
'anchorPosition',
'font',
'height',
'orientation',
'textString'
])
})
let layer2: gdal.Layer
before(() => {
layer2 = ds.layers.get(1)
})
describe('field properties', () => {
it('should evaluate datatypes', () => {
assert.equal('string', layer2.fields.get(0).type)
assert.equal('integer', layer2.fields.get(1).type)
assert.equal('string', layer2.fields.get(2).type)
})
})
describe('features', () => {
it('should be readable', () => {
assert.equal(layer2.features.count(), 381)
// layer2.features.get(0); doesn't work, as there is no 'id', but 'fid' instead
const feature = layer2.features.next()
const fields = feature.fields.toObject()
assert.deepEqual(fields, {
fid: 'ID_105',
featureCode: 15600,
featureDescription: 'Water Feature'
})
})
})
})
})
describe('vsigzip/Async', () => {
let filename, dsq: Promise<gdal.Dataset>
it('should not throw', () => {
filename = path.join(__dirname, 'data/vsigzip/hp40ne.gz')
dsq = gdal.openAsync(filename)
return assert.isFulfilled(dsq)
})
it('should be able to read layer count', () =>
assert.eventually.equal(dsq.then((ds) => ds.layers.count()), 4)
)
describe('layer', () => {
it('should have all fields defined', () => {
const layerq = dsq.then((ds) => ds.layers.get(0))
return assert.isFulfilled(Promise.all([ assert.eventually.equal(layerq.then((layer) => layer.fields.count()), 8),
assert.eventually.deepEqual(layerq.then((layer) => layer.fields.getNames()), [
'fid',
'featureCode',
'featureDescription',
'anchorPosition',
'font',
'height',
'orientation',
'textString'
])
]))
})
})
})
})