forked from yocontra/node-gdal-next
-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
open_geojson.test.ts
45 lines (40 loc) · 1.19 KB
/
open_geojson.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
import * as gdal from 'gdal-async'
import * as path from 'path'
import { assert } from 'chai'
describe('Open', () => {
afterEach(global.gc!)
describe('GeoJSON', () => {
let filename, ds: gdal.Dataset
it('should not throw', () => {
filename = path.join(__dirname, 'data/park.geo.json')
ds = gdal.open(filename)
})
it('should be able to read layer count', () => {
assert.equal(ds.layers.count(), 1)
})
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', () => {
assert.equal(layer.fields.count(), 3)
assert.deepEqual(layer.fields.getNames(), [ 'kind', 'name', 'state' ])
})
describe('features', () => {
it('should be readable', () => {
assert.equal(layer.features.count(), 1)
const feature = layer.features.get(0)
const fields = feature.fields.toObject()
assert.deepEqual(fields, {
kind: 'county',
state: 'WY',
name: 'Park'
})
})
})
})
})
})