-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy pathopen_gpx.test.js
57 lines (52 loc) · 1.47 KB
/
open_gpx.test.js
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
var gdal = require('../lib/gdal.js');
var path = require('path');
var assert = require('chai').assert;
describe('Open', function() {
afterEach(gc);
describe('GPX', function() {
var filename, ds;
it('should not throw', function() {
filename = path.join(__dirname, 'data/gpx/spiritmountain.gpx');
ds = gdal.open(filename, 'r', 'GPX');
});
it('should be able to read layer count', function() {
assert.equal(ds.layers.count(), 5);
});
describe('layer', function() {
var layer;
it('should exist', function() {
layer = ds.layers.get(0);
assert.ok(layer);
assert.instanceOf(layer, gdal.Layer);
});
it('should have all fields defined', function() {
var 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', function() {
it('should be readable', function() {
assert.equal(layer.features.count(), 2);
var feature = layer.features.get(0);
var 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');
});
});
});
});
});