Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
+112
-112
@@ -9,19 +9,19 @@ import _ol_xml_ from '../../../../src/ol/xml.js';
|
||||
|
||||
describe('ol.format.GPX', function() {
|
||||
|
||||
var format;
|
||||
let format;
|
||||
beforeEach(function() {
|
||||
format = new GPX();
|
||||
});
|
||||
|
||||
describe('#readProjection', function() {
|
||||
it('returns the default projection from document', function() {
|
||||
var projection = format.readProjectionFromDocument();
|
||||
const projection = format.readProjectionFromDocument();
|
||||
expect(projection).to.eql(getProjection('EPSG:4326'));
|
||||
});
|
||||
|
||||
it('returns the default projection from node', function() {
|
||||
var projection = format.readProjectionFromNode();
|
||||
const projection = format.readProjectionFromNode();
|
||||
expect(projection).to.eql(getProjection('EPSG:4326'));
|
||||
});
|
||||
});
|
||||
@@ -29,22 +29,22 @@ describe('ol.format.GPX', function() {
|
||||
describe('rte', function() {
|
||||
|
||||
it('can read an empty rte', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <rte/>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(LineString);
|
||||
expect(g.getCoordinates()).to.eql([]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
});
|
||||
|
||||
it('can read and write various rte attributes', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -62,9 +62,9 @@ describe('ol.format.GPX', function() {
|
||||
' <type>Type</type>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
expect(f.get('name')).to.be('Name');
|
||||
expect(f.get('cmt')).to.be('Comment');
|
||||
@@ -75,12 +75,12 @@ 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.writeFeaturesNode(fs);
|
||||
const 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 =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -90,20 +90,20 @@ describe('ol.format.GPX', function() {
|
||||
' <rtept lat="3" lon="4"/>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(LineString);
|
||||
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can transform, read and write a rte', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -113,26 +113,26 @@ describe('ol.format.GPX', function() {
|
||||
' <rtept lat="5" lon="6"/>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text, {
|
||||
const fs = format.readFeatures(text, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(LineString);
|
||||
var p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
var p2 = transform([6, 5], 'EPSG:4326', 'EPSG:3857');
|
||||
const p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
const p2 = transform([6, 5], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(g.getCoordinates()).to.eql([p1, p2]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs, {
|
||||
const serialized = format.writeFeaturesNode(fs, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('does not write rte attributes in rtepts', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -143,8 +143,8 @@ describe('ol.format.GPX', function() {
|
||||
' <rtept lat="3" lon="4"/>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const fs = format.readFeatures(text);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
@@ -153,22 +153,22 @@ describe('ol.format.GPX', function() {
|
||||
describe('trk', function() {
|
||||
|
||||
it('can read an empty trk', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(MultiLineString);
|
||||
expect(g.getCoordinates()).to.eql([]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
});
|
||||
|
||||
it('can read and write various trk attributes', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -186,9 +186,9 @@ describe('ol.format.GPX', function() {
|
||||
' <type>Type</type>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
expect(f.get('name')).to.be('Name');
|
||||
expect(f.get('cmt')).to.be('Comment');
|
||||
@@ -199,12 +199,12 @@ 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.writeFeaturesNode(fs);
|
||||
const 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 =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -213,20 +213,20 @@ describe('ol.format.GPX', function() {
|
||||
' <trkseg/>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(MultiLineString);
|
||||
expect(g.getCoordinates()).to.eql([[]]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const 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 =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -244,22 +244,22 @@ describe('ol.format.GPX', function() {
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(MultiLineString);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]]
|
||||
]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const 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 =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -277,28 +277,28 @@ describe('ol.format.GPX', function() {
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text, {
|
||||
const fs = format.readFeatures(text, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(MultiLineString);
|
||||
var p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
const p1 = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
p1.push(3, 1263115752);
|
||||
var p2 = transform([6, 5], 'EPSG:4326', 'EPSG:3857');
|
||||
const p2 = transform([6, 5], 'EPSG:4326', 'EPSG:3857');
|
||||
p2.push(7, 1263115812);
|
||||
expect(g.getCoordinates()).to.eql([[p1, p2]]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
var serialized = format.writeFeaturesNode(fs, {
|
||||
const 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 =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -326,23 +326,23 @@ describe('ol.format.GPX', function() {
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(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('XYZM');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('does not write trk attributes in trkpts', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -371,8 +371,8 @@ describe('ol.format.GPX', function() {
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const fs = format.readFeatures(text);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
@@ -381,52 +381,52 @@ describe('ol.format.GPX', function() {
|
||||
describe('wpt', function() {
|
||||
|
||||
it('can read and write a wpt', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
'http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="OpenLayers">' +
|
||||
' <wpt lat="1" lon="2"/>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(Point);
|
||||
expect(g.getCoordinates()).to.eql([2, 1]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can transform, read and write a wpt', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
'http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="OpenLayers">' +
|
||||
' <wpt lat="1" lon="2"/>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text, {
|
||||
const fs = format.readFeatures(text, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(Point);
|
||||
var expectedPoint = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
const expectedPoint = transform([2, 1], 'EPSG:4326', 'EPSG:3857');
|
||||
expect(g.getCoordinates()).to.eql(expectedPoint);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
var serialized = format.writeFeaturesNode(fs, {
|
||||
const 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 =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -435,20 +435,20 @@ describe('ol.format.GPX', function() {
|
||||
' <ele>3</ele>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(Point);
|
||||
expect(g.getCoordinates()).to.eql([2, 1, 3]);
|
||||
expect(g.getLayout()).to.be('XYZ');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a wpt with time', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -457,20 +457,20 @@ describe('ol.format.GPX', function() {
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(Point);
|
||||
expect(g.getCoordinates()).to.eql([2, 1, 1263115752]);
|
||||
expect(g.getLayout()).to.be('XYM');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const 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 =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -480,20 +480,20 @@ describe('ol.format.GPX', function() {
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
var g = f.getGeometry();
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(Point);
|
||||
expect(g.getCoordinates()).to.eql([2, 1, 3, 1263115752]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
var serialized = format.writeFeaturesNode(fs);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
it('can read and write various wpt attributes', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
@@ -520,9 +520,9 @@ describe('ol.format.GPX', function() {
|
||||
' <dgpsid>10</dgpsid>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var f = fs[0];
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
expect(f.get('magvar')).to.be(11);
|
||||
expect(f.get('geoidheight')).to.be(4);
|
||||
@@ -541,7 +541,7 @@ describe('ol.format.GPX', function() {
|
||||
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);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(_ol_xml_.parse(text));
|
||||
});
|
||||
|
||||
@@ -554,35 +554,35 @@ describe('ol.format.GPX', function() {
|
||||
});
|
||||
|
||||
it('can read features with a version 1.0 namespace', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/0">' +
|
||||
' <wpt/>' +
|
||||
' <rte/>' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
});
|
||||
|
||||
it('can read features with a version 1.1 namespace', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <wpt/>' +
|
||||
' <rte/>' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
});
|
||||
|
||||
it('can read features with no namespace', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx>' +
|
||||
' <wpt/>' +
|
||||
' <rte/>' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
});
|
||||
|
||||
@@ -593,15 +593,15 @@ describe('ol.format.GPX', function() {
|
||||
beforeEach(function() {
|
||||
format = new GPX({
|
||||
readExtensions: function(feature, extensionsNode) {
|
||||
var nodes = extensionsNode.getElementsByTagName('id');
|
||||
var id = nodes.item(0).textContent;
|
||||
const nodes = extensionsNode.getElementsByTagName('id');
|
||||
const id = nodes.item(0).textContent;
|
||||
feature.setId(id);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('can process extensions from wpt', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <wpt>' +
|
||||
' <extensions>' +
|
||||
@@ -609,14 +609,14 @@ describe('ol.format.GPX', function() {
|
||||
' </extensions>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var feature = fs[0];
|
||||
const feature = fs[0];
|
||||
expect(feature.getId()).to.be('feature-id');
|
||||
});
|
||||
|
||||
it('can process extensions from rte', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <rte>' +
|
||||
' <extensions>' +
|
||||
@@ -625,14 +625,14 @@ describe('ol.format.GPX', function() {
|
||||
' </extensions>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var feature = fs[0];
|
||||
const feature = fs[0];
|
||||
expect(feature.getId()).to.be('feature-id');
|
||||
});
|
||||
|
||||
it('can process extensions from trk, not trkpt', function() {
|
||||
var text =
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <trk>' +
|
||||
' <extensions>' +
|
||||
@@ -647,9 +647,9 @@ describe('ol.format.GPX', function() {
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
var fs = format.readFeatures(text);
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
var feature = fs[0];
|
||||
const feature = fs[0];
|
||||
expect(feature.getId()).to.be('feature-id');
|
||||
});
|
||||
|
||||
@@ -661,12 +661,12 @@ describe('ol.format.GPX', function() {
|
||||
});
|
||||
|
||||
it('does not fail', function() {
|
||||
var polygon = new Polygon(
|
||||
[[[0, 0], [2, 2], [4, 0], [0, 0]]]);
|
||||
var feature = new Feature(polygon);
|
||||
var features = [feature];
|
||||
var gpx = format.writeFeaturesNode(features);
|
||||
var expected =
|
||||
const polygon = new Polygon(
|
||||
[[[0, 0], [2, 2], [4, 0], [0, 0]]]);
|
||||
const feature = new Feature(polygon);
|
||||
const features = [feature];
|
||||
const gpx = format.writeFeaturesNode(features);
|
||||
const expected =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1" ' +
|
||||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
|
||||
'xsi:schemaLocation="http://www.topografix.com/GPX/1/1 ' +
|
||||
|
||||
Reference in New Issue
Block a user