Add trk serialization for ol.format.GPX

This commit is contained in:
ahocevar
2014-02-21 20:27:04 +01:00
parent 791cb2415b
commit 480a6a85ba
2 changed files with 113 additions and 15 deletions

View File

@@ -5,17 +5,13 @@ describe('ol.format.GPX', function() {
var format;
beforeEach(function() {
format = new ol.format.GPX();
format = new ol.format.GPX.V1_1();
});
describe('readFeatures', function() {
describe('rte', function() {
beforeEach(function() {
format = new ol.format.GPX.V1_1();
});
it('can read an empty rte', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
@@ -103,7 +99,7 @@ describe('ol.format.GPX', function() {
expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
});
it('can read various trk attributes', function() {
it('can read and write various trk attributes', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <trk>' +
@@ -132,9 +128,11 @@ describe('ol.format.GPX', function() {
expect(f.get('linkType')).to.be('Link type');
expect(f.get('number')).to.be(1);
expect(f.get('type')).to.be('Type');
var serialized = format.writeFeatures(fs);
expect(serialized).to.xmleql(ol.xml.load(text));
});
it('can read a trk with an empty trkseg', function() {
it('can read and write a trk with an empty trkseg', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <trk>' +
@@ -149,9 +147,11 @@ describe('ol.format.GPX', function() {
expect(g).to.be.an(ol.geom.MultiLineString);
expect(g.getCoordinates()).to.eql([[]]);
expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
var serialized = format.writeFeatures(fs);
expect(serialized).to.xmleql(ol.xml.load(text));
});
it('can read a trk with a trkseg with multiple trkpts', function() {
it('can read/write a trk with a trkseg with multiple trkpts', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <trk>' +
@@ -177,9 +177,11 @@ describe('ol.format.GPX', function() {
[[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]]
]);
expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
var serialized = format.writeFeatures(fs);
expect(serialized).to.xmleql(ol.xml.load(text));
});
it('can read a trk with multiple trksegs', function() {
it('can read and write a trk with multiple trksegs', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
' <trk>' +
@@ -216,16 +218,14 @@ describe('ol.format.GPX', function() {
[[9, 8, 10, 1263115872], [12, 11, 13, 1263115932]]
]);
expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
var serialized = format.writeFeatures(fs);
expect(serialized).to.xmleql(ol.xml.load(text));
});
});
describe('wpt', function() {
beforeEach(function() {
format = new ol.format.GPX.V1_1();
});
it('can read and write a wpt', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
@@ -355,6 +355,10 @@ describe('ol.format.GPX', function() {
describe('XML namespace support', function() {
beforeEach(function() {
format = new ol.format.GPX();
});
it('can read features with a version 1.0 namespace', function() {
var text =
'<gpx xmlns="http://www.topografix.com/GPX/1/0">' +