forked from yocontra/node-gdal-next
-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
open_gpx.test.ts
57 lines (52 loc) · 1.61 KB
/
open_gpx.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
import * as gdal from 'gdal-async'
import * as path from 'path'
import { assert } from 'chai'
describe('Open', () => {
afterEach(() => void global.gc!())
describe('GPX', () => {
let filename, ds: gdal.Dataset
it('should not throw', () => {
filename = path.join(__dirname, 'data/gpx/spiritmountain.gpx')
ds = gdal.open(filename, 'r', 'GPX')
})
it('should be able to read layer count', () => {
assert.equal(ds.layers.count(), 5)
})
describe('layer', () => {
let layer: gdal.Layer
it('should exist', () => {
layer = ds.layers.get(0)
assert.ok(layer)
assert.instanceOf(layer, gdal.Layer)
})
it('should have all fields defined', () => {
const names = layer.fields.getNames()
assert.include(names, 'ele')
assert.include(names, 'time')
assert.include(names, 'name')
assert.include(names, 'cmt')
assert.include(names, 'sym')
})
describe('features', () => {
it('should be readable', () => {
assert.equal(layer.features.count(), 2)
const feature = layer.features.get(0)
const fields = feature.fields.toObject()
assert.closeTo(fields.ele, 1975.311646, 0.000001)
assert.deepEqual(fields.time, {
year: 2014,
month: 5,
day: 27,
hour: 17,
minute: 25,
second: 13,
timezone: 100
})
assert.equal(fields.name, '005')
assert.equal(fields.cmt, 'PARK')
assert.equal(fields.sym, 'Flag, Blue')
})
})
})
})
})