diff --git a/test/spec/ol/format/gpxformat.test.js b/test/spec/ol/format/gpxformat.test.js
index 311c719e3d..ff09580aca 100644
--- a/test/spec/ol/format/gpxformat.test.js
+++ b/test/spec/ol/format/gpxformat.test.js
@@ -19,544 +19,540 @@ describe('ol.format.GPX', function() {
});
});
- describe('readFeatures', function() {
-
- describe('rte', function() {
-
- it('can read an empty rte', function() {
- var text =
- '' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.LineString);
- expect(g.getCoordinates()).to.eql([]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- });
-
- it('can read and write various rte attributes', function() {
- var text =
- '' +
- ' ' +
- ' Name' +
- ' Comment' +
- ' Description' +
- ' Source' +
- ' ' +
- ' Link text' +
- ' Link type' +
- ' ' +
- ' 1' +
- ' Type' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- expect(f.get('name')).to.be('Name');
- expect(f.get('cmt')).to.be('Comment');
- expect(f.get('desc')).to.be('Description');
- expect(f.get('src')).to.be('Source');
- expect(f.get('link')).to.be('http://example.com/');
- expect(f.get('linkText')).to.be('Link text');
- 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.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can read and write a rte with multiple rtepts', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.LineString);
- expect(g.getCoordinates()).to.eql([[2, 1, 0, 0], [4, 3, 0, 0]]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can transform, read and write a rte', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text, {
- featureProjection: 'EPSG:3857'
- });
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.LineString);
- var p1 = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
- p1.push(0, 0);
- var p2 = ol.proj.transform([6, 5], 'EPSG:4326', 'EPSG:3857');
- p2.push(0, 0);
- expect(g.getCoordinates()).to.eql([p1, p2]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs, {
- featureProjection: 'EPSG:3857'
- });
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
+ describe('rte', function() {
+ it('can read an empty rte', function() {
+ var text =
+ '' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.LineString);
+ expect(g.getCoordinates()).to.eql([]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
});
- describe('trk', function() {
-
- it('can read an empty trk', function() {
- var text =
- '' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.MultiLineString);
- expect(g.getCoordinates()).to.eql([]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- });
-
- it('can read and write various trk attributes', function() {
- var text =
- '' +
- ' ' +
- ' Name' +
- ' Comment' +
- ' Description' +
- ' Source' +
- ' ' +
- ' Link text' +
- ' Link type' +
- ' ' +
- ' 1' +
- ' Type' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- expect(f.get('name')).to.be('Name');
- expect(f.get('cmt')).to.be('Comment');
- expect(f.get('desc')).to.be('Description');
- expect(f.get('src')).to.be('Source');
- expect(f.get('link')).to.be('http://example.com/');
- expect(f.get('linkText')).to.be('Link text');
- 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.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can read and write a trk with an empty trkseg', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- 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.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can read/write a trk with a trkseg with multiple trkpts', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- ' 3' +
- ' ' +
- ' ' +
- ' ' +
- ' 7' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.MultiLineString);
- expect(g.getCoordinates()).to.eql([
- [[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]]
- ]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can transform, read and write a trk with a trkseg', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- ' 3' +
- ' ' +
- ' ' +
- ' ' +
- ' 7' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text, {
- featureProjection: 'EPSG:3857'
- });
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.MultiLineString);
- var p1 = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
- p1.push(3, 1263115752);
- var p2 = ol.proj.transform([6, 5], 'EPSG:4326', 'EPSG:3857');
- p2.push(7, 1263115812);
- expect(g.getCoordinates()).to.eql([[p1, p2]]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs, {
- featureProjection: 'EPSG:3857'
- });
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can read and write a trk with multiple trksegs', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- ' 3' +
- ' ' +
- ' ' +
- ' ' +
- ' 7' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' 10' +
- ' ' +
- ' ' +
- ' ' +
- ' 13' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.MultiLineString);
- expect(g.getCoordinates()).to.eql([
- [[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]],
- [[9, 8, 10, 1263115872], [12, 11, 13, 1263115932]]
- ]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
+ it('can read and write various rte attributes', function() {
+ var text =
+ '' +
+ ' ' +
+ ' Name' +
+ ' Comment' +
+ ' Description' +
+ ' Source' +
+ ' ' +
+ ' Link text' +
+ ' Link type' +
+ ' ' +
+ ' 1' +
+ ' Type' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ expect(f.get('name')).to.be('Name');
+ expect(f.get('cmt')).to.be('Comment');
+ expect(f.get('desc')).to.be('Description');
+ expect(f.get('src')).to.be('Source');
+ expect(f.get('link')).to.be('http://example.com/');
+ expect(f.get('linkText')).to.be('Link text');
+ 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.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
});
- describe('wpt', function() {
-
- it('can read and write a wpt', function() {
- var text =
- '' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.Point);
- expect(g.getCoordinates()).to.eql([2, 1, 0, 0]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can transform, read and write a wpt', function() {
- var text =
- '' +
- ' ' +
- '';
- var fs = format.readFeatures(text, {
- featureProjection: 'EPSG:3857'
- });
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.Point);
- var expectedPoint = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
- expectedPoint.push(0, 0);
- expect(g.getCoordinates()).to.eql(expectedPoint);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs, {
- featureProjection: 'EPSG:3857'
- });
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can read and write a wpt with ele', function() {
- var text =
- '' +
- ' ' +
- ' 3' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.Point);
- expect(g.getCoordinates()).to.eql([2, 1, 3, 0]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can read and write a wpt with time', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.Point);
- expect(g.getCoordinates()).to.eql([2, 1, 0, 1263115752]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can read and write a wpt with ele and time', function() {
- var text =
- '' +
- ' ' +
- ' 3' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- var g = f.getGeometry();
- expect(g).to.be.an(ol.geom.Point);
- expect(g.getCoordinates()).to.eql([2, 1, 3, 1263115752]);
- expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
- var serialized = format.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
- it('can read and write various wpt attributes', function() {
- var text =
- '' +
- ' ' +
- ' 11' +
- ' 4' +
- ' Name' +
- ' Comment' +
- ' Description' +
- ' Source' +
- ' ' +
- ' Link text' +
- ' Link type' +
- ' ' +
- ' Symbol' +
- ' Type' +
- ' 2d' +
- ' 5' +
- ' 6' +
- ' 7' +
- ' 8' +
- ' 9' +
- ' 10' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var f = fs[0];
- expect(f).to.be.an(ol.Feature);
- expect(f.get('magvar')).to.be(11);
- expect(f.get('geoidheight')).to.be(4);
- expect(f.get('name')).to.be('Name');
- expect(f.get('cmt')).to.be('Comment');
- expect(f.get('desc')).to.be('Description');
- expect(f.get('src')).to.be('Source');
- expect(f.get('link')).to.be('http://example.com/');
- expect(f.get('linkText')).to.be('Link text');
- expect(f.get('linkType')).to.be('Link type');
- expect(f.get('sym')).to.be('Symbol');
- expect(f.get('type')).to.be('Type');
- expect(f.get('fix')).to.be('2d');
- expect(f.get('hdop')).to.be(6);
- expect(f.get('vdop')).to.be(7);
- expect(f.get('pdop')).to.be(8);
- expect(f.get('ageofdgpsdata')).to.be(9);
- expect(f.get('dgpsid')).to.be(10);
- var serialized = format.writeFeaturesNode(fs);
- expect(serialized).to.xmleql(ol.xml.parse(text));
- });
-
+ it('can read and write a rte with multiple rtepts', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.LineString);
+ expect(g.getCoordinates()).to.eql([[2, 1, 0, 0], [4, 3, 0, 0]]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
});
- describe('XML namespace support', function() {
-
- beforeEach(function() {
- format = new ol.format.GPX();
+ it('can transform, read and write a rte', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text, {
+ featureProjection: 'EPSG:3857'
});
-
- it('can read features with a version 1.0 namespace', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(3);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.LineString);
+ var p1 = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
+ p1.push(0, 0);
+ var p2 = ol.proj.transform([6, 5], 'EPSG:4326', 'EPSG:3857');
+ p2.push(0, 0);
+ expect(g.getCoordinates()).to.eql([p1, p2]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs, {
+ featureProjection: 'EPSG:3857'
});
-
- it('can read features with a version 1.1 namespace', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(3);
- });
-
- it('can read features with no namespace', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(3);
- });
-
+ expect(serialized).to.xmleql(ol.xml.parse(text));
});
- describe('extensions support', function() {
+ });
- beforeEach(function() {
- format = new ol.format.GPX({
- readExtensions: function(feature, extensionsNode) {
- var nodes = extensionsNode.getElementsByTagName('id');
- var id = nodes.item(0).textContent;
- feature.setId(id);
- }
- });
+ describe('trk', function() {
+
+ it('can read an empty trk', function() {
+ var text =
+ '' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.MultiLineString);
+ expect(g.getCoordinates()).to.eql([]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ });
+
+ it('can read and write various trk attributes', function() {
+ var text =
+ '' +
+ ' ' +
+ ' Name' +
+ ' Comment' +
+ ' Description' +
+ ' Source' +
+ ' ' +
+ ' Link text' +
+ ' Link type' +
+ ' ' +
+ ' 1' +
+ ' Type' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ expect(f.get('name')).to.be('Name');
+ expect(f.get('cmt')).to.be('Comment');
+ expect(f.get('desc')).to.be('Description');
+ expect(f.get('src')).to.be('Source');
+ expect(f.get('link')).to.be('http://example.com/');
+ expect(f.get('linkText')).to.be('Link text');
+ 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.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+
+ it('can read and write a trk with an empty trkseg', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ 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.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+
+ it('can read/write a trk with a trkseg with multiple trkpts', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 3' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 7' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.MultiLineString);
+ expect(g.getCoordinates()).to.eql([
+ [[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]]
+ ]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+
+ it('can transform, read and write a trk with a trkseg', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 3' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 7' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text, {
+ featureProjection: 'EPSG:3857'
});
-
- it('can process extensions from wpt', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' feature-id' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var feature = fs[0];
- expect(feature.getId()).to.be('feature-id');
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.MultiLineString);
+ var p1 = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
+ p1.push(3, 1263115752);
+ var p2 = ol.proj.transform([6, 5], 'EPSG:4326', 'EPSG:3857');
+ p2.push(7, 1263115812);
+ expect(g.getCoordinates()).to.eql([[p1, p2]]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs, {
+ featureProjection: 'EPSG:3857'
});
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
- it('can process extensions from rte', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' bar' +
- ' feature-id' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var feature = fs[0];
- expect(feature.getId()).to.be('feature-id');
+ it('can read and write a trk with multiple trksegs', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 3' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 7' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 10' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' 13' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.MultiLineString);
+ expect(g.getCoordinates()).to.eql([
+ [[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]],
+ [[9, 8, 10, 1263115872], [12, 11, 13, 1263115932]]
+ ]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+
+ });
+
+ describe('wpt', function() {
+
+ it('can read and write a wpt', function() {
+ var text =
+ '' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.Point);
+ expect(g.getCoordinates()).to.eql([2, 1, 0, 0]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+
+ it('can transform, read and write a wpt', function() {
+ var text =
+ '' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text, {
+ featureProjection: 'EPSG:3857'
});
-
- it('can process extensions from trk, not trkpt', function() {
- var text =
- '' +
- ' ' +
- ' ' +
- ' feature-id' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- ' another-feature-id' +
- ' ' +
- ' ' +
- ' ' +
- ' ' +
- '';
- var fs = format.readFeatures(text);
- expect(fs).to.have.length(1);
- var feature = fs[0];
- expect(feature.getId()).to.be('feature-id');
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.Point);
+ var expectedPoint = ol.proj.transform([2, 1], 'EPSG:4326', 'EPSG:3857');
+ expectedPoint.push(0, 0);
+ expect(g.getCoordinates()).to.eql(expectedPoint);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs, {
+ featureProjection: 'EPSG:3857'
});
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+ it('can read and write a wpt with ele', function() {
+ var text =
+ '' +
+ ' ' +
+ ' 3' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.Point);
+ expect(g.getCoordinates()).to.eql([2, 1, 3, 0]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+
+ it('can read and write a wpt with time', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.Point);
+ expect(g.getCoordinates()).to.eql([2, 1, 0, 1263115752]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+
+ it('can read and write a wpt with ele and time', function() {
+ var text =
+ '' +
+ ' ' +
+ ' 3' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ var g = f.getGeometry();
+ expect(g).to.be.an(ol.geom.Point);
+ expect(g.getCoordinates()).to.eql([2, 1, 3, 1263115752]);
+ expect(g.getLayout()).to.be(ol.geom.GeometryLayout.XYZM);
+ var serialized = format.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+
+ it('can read and write various wpt attributes', function() {
+ var text =
+ '' +
+ ' ' +
+ ' 11' +
+ ' 4' +
+ ' Name' +
+ ' Comment' +
+ ' Description' +
+ ' Source' +
+ ' ' +
+ ' Link text' +
+ ' Link type' +
+ ' ' +
+ ' Symbol' +
+ ' Type' +
+ ' 2d' +
+ ' 5' +
+ ' 6' +
+ ' 7' +
+ ' 8' +
+ ' 9' +
+ ' 10' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var f = fs[0];
+ expect(f).to.be.an(ol.Feature);
+ expect(f.get('magvar')).to.be(11);
+ expect(f.get('geoidheight')).to.be(4);
+ expect(f.get('name')).to.be('Name');
+ expect(f.get('cmt')).to.be('Comment');
+ expect(f.get('desc')).to.be('Description');
+ expect(f.get('src')).to.be('Source');
+ expect(f.get('link')).to.be('http://example.com/');
+ expect(f.get('linkText')).to.be('Link text');
+ expect(f.get('linkType')).to.be('Link type');
+ expect(f.get('sym')).to.be('Symbol');
+ expect(f.get('type')).to.be('Type');
+ expect(f.get('fix')).to.be('2d');
+ expect(f.get('hdop')).to.be(6);
+ expect(f.get('vdop')).to.be(7);
+ expect(f.get('pdop')).to.be(8);
+ expect(f.get('ageofdgpsdata')).to.be(9);
+ expect(f.get('dgpsid')).to.be(10);
+ var serialized = format.writeFeaturesNode(fs);
+ expect(serialized).to.xmleql(ol.xml.parse(text));
+ });
+
+ });
+
+ 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 =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(3);
+ });
+
+ it('can read features with a version 1.1 namespace', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(3);
+ });
+
+ it('can read features with no namespace', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(3);
+ });
+
+ });
+
+ describe('extensions support', function() {
+
+ beforeEach(function() {
+ format = new ol.format.GPX({
+ readExtensions: function(feature, extensionsNode) {
+ var nodes = extensionsNode.getElementsByTagName('id');
+ var id = nodes.item(0).textContent;
+ feature.setId(id);
+ }
+ });
+ });
+
+ it('can process extensions from wpt', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' feature-id' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var feature = fs[0];
+ expect(feature.getId()).to.be('feature-id');
+ });
+
+ it('can process extensions from rte', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' bar' +
+ ' feature-id' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var feature = fs[0];
+ expect(feature.getId()).to.be('feature-id');
+ });
+
+ it('can process extensions from trk, not trkpt', function() {
+ var text =
+ '' +
+ ' ' +
+ ' ' +
+ ' feature-id' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' another-feature-id' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ var fs = format.readFeatures(text);
+ expect(fs).to.have.length(1);
+ var feature = fs[0];
+ expect(feature.getId()).to.be('feature-id');
});
});