Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier. Most formatting changes were automatically applied with this:
npm run lint -- --fix
A few manual changes were required:
* In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
* In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason. While editing this, I reworked `ExampleBuilder` to be a class.
* In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
+1137
-459
File diff suppressed because it is too large
Load Diff
+470
-306
File diff suppressed because it is too large
Load Diff
+1921
-1500
File diff suppressed because it is too large
Load Diff
+344
-343
@@ -7,32 +7,30 @@ import Polygon from '../../../../src/ol/geom/Polygon.js';
|
||||
import {get as getProjection, transform} from '../../../../src/ol/proj.js';
|
||||
import {parse} from '../../../../src/ol/xml.js';
|
||||
|
||||
describe('ol.format.GPX', function() {
|
||||
|
||||
describe('ol.format.GPX', function () {
|
||||
let format;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
format = new GPX();
|
||||
});
|
||||
|
||||
describe('#readProjection', function() {
|
||||
it('returns the default projection from document', function() {
|
||||
describe('#readProjection', function () {
|
||||
it('returns the default projection from document', function () {
|
||||
const projection = format.readProjectionFromDocument();
|
||||
expect(projection).to.eql(getProjection('EPSG:4326'));
|
||||
});
|
||||
|
||||
it('returns the default projection from node', function() {
|
||||
it('returns the default projection from node', function () {
|
||||
const projection = format.readProjectionFromNode();
|
||||
expect(projection).to.eql(getProjection('EPSG:4326'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('rte', function() {
|
||||
|
||||
it('can read an empty rte', function() {
|
||||
describe('rte', function () {
|
||||
it('can read an empty rte', function () {
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <rte/>' +
|
||||
'</gpx>';
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <rte/>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -43,25 +41,25 @@ describe('ol.format.GPX', function() {
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
});
|
||||
|
||||
it('can read and write various rte attributes', function() {
|
||||
it('can read and write various rte attributes', function () {
|
||||
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">' +
|
||||
' <rte>' +
|
||||
' <name>Name</name>' +
|
||||
' <cmt>Comment</cmt>' +
|
||||
' <desc>Description</desc>' +
|
||||
' <src>Source</src>' +
|
||||
' <link href="http://example.com/">' +
|
||||
' <text>Link text</text>' +
|
||||
' <type>Link type</type>' +
|
||||
' </link>' +
|
||||
' <number>1</number>' +
|
||||
' <type>Type</type>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <rte>' +
|
||||
' <name>Name</name>' +
|
||||
' <cmt>Comment</cmt>' +
|
||||
' <desc>Description</desc>' +
|
||||
' <src>Source</src>' +
|
||||
' <link href="http://example.com/">' +
|
||||
' <text>Link text</text>' +
|
||||
' <type>Link type</type>' +
|
||||
' </link>' +
|
||||
' <number>1</number>' +
|
||||
' <type>Type</type>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -79,42 +77,45 @@ describe('ol.format.GPX', function() {
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a rte with multiple rtepts', function() {
|
||||
it('can read and write a rte with multiple rtepts', function () {
|
||||
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">' +
|
||||
' <rte>' +
|
||||
' <rtept lat="1" lon="2"/>' +
|
||||
' <rtept lat="3" lon="4"/>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <rte>' +
|
||||
' <rtept lat="1" lon="2"/>' +
|
||||
' <rtept lat="3" lon="4"/>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
expect(f).to.be.an(Feature);
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(LineString);
|
||||
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[2, 1],
|
||||
[4, 3],
|
||||
]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can transform, read and write a rte', function() {
|
||||
it('can transform, read and write a rte', function () {
|
||||
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">' +
|
||||
' <rte>' +
|
||||
' <rtept lat="1" lon="2"/>' +
|
||||
' <rtept lat="5" lon="6"/>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <rte>' +
|
||||
' <rtept lat="1" lon="2"/>' +
|
||||
' <rtept lat="5" lon="6"/>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -126,37 +127,35 @@ describe('ol.format.GPX', function() {
|
||||
expect(g.getCoordinates()).to.eql([p1, p2]);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
const serialized = format.writeFeaturesNode(fs, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('does not write rte attributes in rtepts', function() {
|
||||
it('does not write rte attributes in rtepts', function () {
|
||||
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">' +
|
||||
' <rte>' +
|
||||
' <name>Name</name>' +
|
||||
' <rtept lat="1" lon="2"/>' +
|
||||
' <rtept lat="3" lon="4"/>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <rte>' +
|
||||
' <name>Name</name>' +
|
||||
' <rtept lat="1" lon="2"/>' +
|
||||
' <rtept lat="3" lon="4"/>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('trk', function() {
|
||||
|
||||
it('can read an empty trk', function() {
|
||||
describe('trk', function () {
|
||||
it('can read an empty trk', function () {
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -167,25 +166,25 @@ describe('ol.format.GPX', function() {
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
});
|
||||
|
||||
it('can read and write various trk attributes', function() {
|
||||
it('can read and write various trk attributes', function () {
|
||||
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">' +
|
||||
' <trk>' +
|
||||
' <name>Name</name>' +
|
||||
' <cmt>Comment</cmt>' +
|
||||
' <desc>Description</desc>' +
|
||||
' <src>Source</src>' +
|
||||
' <link href="http://example.com/">' +
|
||||
' <text>Link text</text>' +
|
||||
' <type>Link type</type>' +
|
||||
' </link>' +
|
||||
' <number>1</number>' +
|
||||
' <type>Type</type>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <trk>' +
|
||||
' <name>Name</name>' +
|
||||
' <cmt>Comment</cmt>' +
|
||||
' <desc>Description</desc>' +
|
||||
' <src>Source</src>' +
|
||||
' <link href="http://example.com/">' +
|
||||
' <text>Link text</text>' +
|
||||
' <type>Link type</type>' +
|
||||
' </link>' +
|
||||
' <number>1</number>' +
|
||||
' <type>Type</type>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -203,16 +202,16 @@ describe('ol.format.GPX', function() {
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a trk with an empty trkseg', function() {
|
||||
it('can read and write a trk with an empty trkseg', function () {
|
||||
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">' +
|
||||
' <trk>' +
|
||||
' <trkseg/>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <trk>' +
|
||||
' <trkseg/>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -225,25 +224,25 @@ describe('ol.format.GPX', function() {
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can read/write a trk with a trkseg with multiple trkpts', function() {
|
||||
it('can read/write a trk with a trkseg with multiple trkpts', function () {
|
||||
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">' +
|
||||
' <trk>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="1" lon="2">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="5" lon="6">' +
|
||||
' <ele>7</ele>' +
|
||||
' <time>2010-01-10T09:30:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <trk>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="1" lon="2">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="5" lon="6">' +
|
||||
' <ele>7</ele>' +
|
||||
' <time>2010-01-10T09:30:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -251,34 +250,37 @@ describe('ol.format.GPX', function() {
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(MultiLineString);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[[2, 1, 3, 1263115752], [6, 5, 7, 1263115812]]
|
||||
[
|
||||
[2, 1, 3, 1263115752],
|
||||
[6, 5, 7, 1263115812],
|
||||
],
|
||||
]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can transform, read and write a trk with a trkseg', function() {
|
||||
it('can transform, read and write a trk with a trkseg', function () {
|
||||
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">' +
|
||||
' <trk>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="1" lon="2">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="5" lon="6">' +
|
||||
' <ele>7</ele>' +
|
||||
' <time>2010-01-10T09:30:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <trk>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="1" lon="2">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="5" lon="6">' +
|
||||
' <ele>7</ele>' +
|
||||
' <time>2010-01-10T09:30:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -292,40 +294,40 @@ describe('ol.format.GPX', function() {
|
||||
expect(g.getCoordinates()).to.eql([[p1, p2]]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
const serialized = format.writeFeaturesNode(fs, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a trk with multiple trksegs', function() {
|
||||
it('can read and write a trk with multiple trksegs', function () {
|
||||
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">' +
|
||||
' <trk>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="1" lon="2">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="5" lon="6">' +
|
||||
' <ele>7</ele>' +
|
||||
' <time>2010-01-10T09:30:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="8" lon="9">' +
|
||||
' <ele>10</ele>' +
|
||||
' <time>2010-01-10T09:31:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="11" lon="12">' +
|
||||
' <ele>13</ele>' +
|
||||
' <time>2010-01-10T09:32:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <trk>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="1" lon="2">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="5" lon="6">' +
|
||||
' <ele>7</ele>' +
|
||||
' <time>2010-01-10T09:30:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="8" lon="9">' +
|
||||
' <ele>10</ele>' +
|
||||
' <time>2010-01-10T09:31:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="11" lon="12">' +
|
||||
' <ele>13</ele>' +
|
||||
' <time>2010-01-10T09:32:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -333,61 +335,65 @@ describe('ol.format.GPX', function() {
|
||||
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]]
|
||||
[
|
||||
[2, 1, 3, 1263115752],
|
||||
[6, 5, 7, 1263115812],
|
||||
],
|
||||
[
|
||||
[9, 8, 10, 1263115872],
|
||||
[12, 11, 13, 1263115932],
|
||||
],
|
||||
]);
|
||||
expect(g.getLayout()).to.be('XYZM');
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('does not write trk attributes in trkpts', function() {
|
||||
it('does not write trk attributes in trkpts', function () {
|
||||
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">' +
|
||||
' <trk>' +
|
||||
' <name>Name</name>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="1" lon="2">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="5" lon="6">' +
|
||||
' <ele>7</ele>' +
|
||||
' <time>2010-01-10T09:30:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="8" lon="9">' +
|
||||
' <ele>10</ele>' +
|
||||
' <time>2010-01-10T09:31:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="11" lon="12">' +
|
||||
' <ele>13</ele>' +
|
||||
' <time>2010-01-10T09:32:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <trk>' +
|
||||
' <name>Name</name>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="1" lon="2">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="5" lon="6">' +
|
||||
' <ele>7</ele>' +
|
||||
' <time>2010-01-10T09:30:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt lat="8" lon="9">' +
|
||||
' <ele>10</ele>' +
|
||||
' <time>2010-01-10T09:31:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' <trkpt lat="11" lon="12">' +
|
||||
' <ele>13</ele>' +
|
||||
' <time>2010-01-10T09:32:12Z</time>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('wpt', function() {
|
||||
|
||||
it('can read and write a wpt', function() {
|
||||
describe('wpt', function () {
|
||||
it('can read and write a wpt', function () {
|
||||
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>';
|
||||
'<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>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -400,16 +406,16 @@ describe('ol.format.GPX', function() {
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can transform, read and write a wpt', function() {
|
||||
it('can transform, read and write a wpt', function () {
|
||||
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>';
|
||||
'<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>';
|
||||
const fs = format.readFeatures(text, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -420,21 +426,21 @@ describe('ol.format.GPX', function() {
|
||||
expect(g.getCoordinates()).to.eql(expectedPoint);
|
||||
expect(g.getLayout()).to.be('XY');
|
||||
const serialized = format.writeFeaturesNode(fs, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a wpt with ele', function() {
|
||||
it('can read and write a wpt with ele', function () {
|
||||
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">' +
|
||||
' <ele>3</ele>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <ele>3</ele>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -447,16 +453,16 @@ describe('ol.format.GPX', function() {
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a wpt with time', function() {
|
||||
it('can read and write a wpt with time', function () {
|
||||
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">' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -469,17 +475,17 @@ describe('ol.format.GPX', function() {
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can read and write a wpt with ele and time', function() {
|
||||
it('can read and write a wpt with ele and time', function () {
|
||||
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">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <ele>3</ele>' +
|
||||
' <time>2010-01-10T09:29:12Z</time>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -492,34 +498,34 @@ describe('ol.format.GPX', function() {
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
it('can read and write various wpt attributes', function() {
|
||||
it('can read and write various wpt attributes', function () {
|
||||
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">' +
|
||||
' <magvar>11</magvar>' +
|
||||
' <geoidheight>4</geoidheight>' +
|
||||
' <name>Name</name>' +
|
||||
' <cmt>Comment</cmt>' +
|
||||
' <desc>Description</desc>' +
|
||||
' <src>Source</src>' +
|
||||
' <link href="http://example.com/">' +
|
||||
' <text>Link text</text>' +
|
||||
' <type>Link type</type>' +
|
||||
' </link>' +
|
||||
' <sym>Symbol</sym>' +
|
||||
' <type>Type</type>' +
|
||||
' <fix>2d</fix>' +
|
||||
' <sat>5</sat>' +
|
||||
' <hdop>6</hdop>' +
|
||||
' <vdop>7</vdop>' +
|
||||
' <pdop>8</pdop>' +
|
||||
' <ageofdgpsdata>9</ageofdgpsdata>' +
|
||||
' <dgpsid>10</dgpsid>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
'<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">' +
|
||||
' <magvar>11</magvar>' +
|
||||
' <geoidheight>4</geoidheight>' +
|
||||
' <name>Name</name>' +
|
||||
' <cmt>Comment</cmt>' +
|
||||
' <desc>Description</desc>' +
|
||||
' <src>Source</src>' +
|
||||
' <link href="http://example.com/">' +
|
||||
' <text>Link text</text>' +
|
||||
' <type>Link type</type>' +
|
||||
' </link>' +
|
||||
' <sym>Symbol</sym>' +
|
||||
' <type>Type</type>' +
|
||||
' <fix>2d</fix>' +
|
||||
' <sat>5</sat>' +
|
||||
' <hdop>6</hdop>' +
|
||||
' <vdop>7</vdop>' +
|
||||
' <pdop>8</pdop>' +
|
||||
' <ageofdgpsdata>9</ageofdgpsdata>' +
|
||||
' <dgpsid>10</dgpsid>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const f = fs[0];
|
||||
@@ -544,136 +550,131 @@ describe('ol.format.GPX', function() {
|
||||
const serialized = format.writeFeaturesNode(fs);
|
||||
expect(serialized).to.xmleql(parse(text));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('XML namespace support', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
describe('XML namespace support', function () {
|
||||
beforeEach(function () {
|
||||
format = new GPX();
|
||||
});
|
||||
|
||||
it('can read features with a version 1.0 namespace', function() {
|
||||
it('can read features with a version 1.0 namespace', function () {
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/0">' +
|
||||
' <wpt/>' +
|
||||
' <rte/>' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/0">' +
|
||||
' <wpt/>' +
|
||||
' <rte/>' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
});
|
||||
|
||||
it('can read features with a version 1.1 namespace', function() {
|
||||
it('can read features with a version 1.1 namespace', function () {
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <wpt/>' +
|
||||
' <rte/>' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <wpt/>' +
|
||||
' <rte/>' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
});
|
||||
|
||||
it('can read features with no namespace', function() {
|
||||
const text =
|
||||
'<gpx>' +
|
||||
' <wpt/>' +
|
||||
' <rte/>' +
|
||||
' <trk/>' +
|
||||
'</gpx>';
|
||||
it('can read features with no namespace', function () {
|
||||
const text = '<gpx>' + ' <wpt/>' + ' <rte/>' + ' <trk/>' + '</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('extensions support', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
describe('extensions support', function () {
|
||||
beforeEach(function () {
|
||||
format = new GPX({
|
||||
readExtensions: function(feature, extensionsNode) {
|
||||
readExtensions: function (feature, extensionsNode) {
|
||||
const nodes = extensionsNode.getElementsByTagName('id');
|
||||
const id = nodes.item(0).textContent;
|
||||
feature.setId(id);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('can process extensions from wpt', function() {
|
||||
it('can process extensions from wpt', function () {
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <wpt>' +
|
||||
' <extensions>' +
|
||||
' <id>feature-id</id>' +
|
||||
' </extensions>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <wpt>' +
|
||||
' <extensions>' +
|
||||
' <id>feature-id</id>' +
|
||||
' </extensions>' +
|
||||
' </wpt>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const feature = fs[0];
|
||||
expect(feature.getId()).to.be('feature-id');
|
||||
});
|
||||
|
||||
it('can process extensions from rte', function() {
|
||||
it('can process extensions from rte', function () {
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <rte>' +
|
||||
' <extensions>' +
|
||||
' <foo>bar</foo>' +
|
||||
' <id>feature-id</id>' +
|
||||
' </extensions>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <rte>' +
|
||||
' <extensions>' +
|
||||
' <foo>bar</foo>' +
|
||||
' <id>feature-id</id>' +
|
||||
' </extensions>' +
|
||||
' </rte>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const feature = fs[0];
|
||||
expect(feature.getId()).to.be('feature-id');
|
||||
});
|
||||
|
||||
it('can process extensions from trk, not trkpt', function() {
|
||||
it('can process extensions from trk, not trkpt', function () {
|
||||
const text =
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <trk>' +
|
||||
' <extensions>' +
|
||||
' <id>feature-id</id>' +
|
||||
' </extensions>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt>' +
|
||||
' <extensions>' +
|
||||
' <id>another-feature-id</id>' +
|
||||
' </extensions>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
'<gpx xmlns="http://www.topografix.com/GPX/1/1">' +
|
||||
' <trk>' +
|
||||
' <extensions>' +
|
||||
' <id>feature-id</id>' +
|
||||
' </extensions>' +
|
||||
' <trkseg>' +
|
||||
' <trkpt>' +
|
||||
' <extensions>' +
|
||||
' <id>another-feature-id</id>' +
|
||||
' </extensions>' +
|
||||
' </trkpt>' +
|
||||
' </trkseg>' +
|
||||
' </trk>' +
|
||||
'</gpx>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(1);
|
||||
const feature = fs[0];
|
||||
expect(feature.getId()).to.be('feature-id');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('write unsupported geometries', function() {
|
||||
beforeEach(function() {
|
||||
describe('write unsupported geometries', function () {
|
||||
beforeEach(function () {
|
||||
format = new GPX();
|
||||
});
|
||||
|
||||
it('does not fail', function() {
|
||||
const polygon = new Polygon(
|
||||
[[[0, 0], [2, 2], [4, 0], [0, 0]]]);
|
||||
it('does not fail', function () {
|
||||
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 ' +
|
||||
'http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" ' +
|
||||
'creator="OpenLayers"></gpx>';
|
||||
'<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"></gpx>';
|
||||
expect(gpx).to.xmleql(parse(expected));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,50 +1,48 @@
|
||||
import IGC from '../../../../src/ol/format/IGC.js';
|
||||
import Feature from '../../../../src/ol/Feature.js';
|
||||
import IGC from '../../../../src/ol/format/IGC.js';
|
||||
import {get as getProjection, transform} from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.format.IGC', function() {
|
||||
|
||||
describe('ol.format.IGC', function () {
|
||||
let format;
|
||||
const igc =
|
||||
'AFLY05094\n' +
|
||||
'HFDTE190411\n' +
|
||||
'HFFXA100\n' +
|
||||
'HFPLTPILOT:Tom Payne\n' +
|
||||
'HFGTYGLIDERTYPE:Axis Mercury\n' +
|
||||
'HFGIDGLIDERID:\n' +
|
||||
'HFDTM100GPSDATUM:WGS84\n' +
|
||||
'HFGPSGPS:FURUNO GH-80\n' +
|
||||
'HFRFWFIRMWAREVERSION:1.22\n' +
|
||||
'HFRHWHARDWAREVERSION:1.00\n' +
|
||||
'HFFTYFRTYPE:FLYTEC,5020\n' +
|
||||
'I013638TAS\n' +
|
||||
'B0848484556256N00651095EA0205102039000\n' +
|
||||
'B0855534556037N00651011EA0259302513000\n' +
|
||||
'B0903354554964N00648049EA0272402758000\n' +
|
||||
'B0848484556256N00651095EA0205102039000\n' +
|
||||
'GAB890A77AFE5CE63979AF6B1BED7F07D\n' +
|
||||
'G62BB282E44D63A1149EF2F5E8AF6F2F1\n' +
|
||||
'GEC14381987B15F81003EDE1E01A47843\n' +
|
||||
'G60189641B00B00800019000000000000';
|
||||
'AFLY05094\n' +
|
||||
'HFDTE190411\n' +
|
||||
'HFFXA100\n' +
|
||||
'HFPLTPILOT:Tom Payne\n' +
|
||||
'HFGTYGLIDERTYPE:Axis Mercury\n' +
|
||||
'HFGIDGLIDERID:\n' +
|
||||
'HFDTM100GPSDATUM:WGS84\n' +
|
||||
'HFGPSGPS:FURUNO GH-80\n' +
|
||||
'HFRFWFIRMWAREVERSION:1.22\n' +
|
||||
'HFRHWHARDWAREVERSION:1.00\n' +
|
||||
'HFFTYFRTYPE:FLYTEC,5020\n' +
|
||||
'I013638TAS\n' +
|
||||
'B0848484556256N00651095EA0205102039000\n' +
|
||||
'B0855534556037N00651011EA0259302513000\n' +
|
||||
'B0903354554964N00648049EA0272402758000\n' +
|
||||
'B0848484556256N00651095EA0205102039000\n' +
|
||||
'GAB890A77AFE5CE63979AF6B1BED7F07D\n' +
|
||||
'G62BB282E44D63A1149EF2F5E8AF6F2F1\n' +
|
||||
'GEC14381987B15F81003EDE1E01A47843\n' +
|
||||
'G60189641B00B00800019000000000000';
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
format = new IGC();
|
||||
});
|
||||
|
||||
describe('#readProjectionFromText', function() {
|
||||
it('returns the default projection', function() {
|
||||
describe('#readProjectionFromText', function () {
|
||||
it('returns the default projection', function () {
|
||||
const projection = format.readProjectionFromText(igc);
|
||||
expect(projection).to.eql(getProjection('EPSG:4326'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#readFeature', function() {
|
||||
it('does not read invalid features', function() {
|
||||
describe('#readFeature', function () {
|
||||
it('does not read invalid features', function () {
|
||||
expect(format.readFeature('invalid')).to.be(null);
|
||||
});
|
||||
|
||||
it('does read a feature', function() {
|
||||
it('does read a feature', function () {
|
||||
const feature = format.readFeature(igc);
|
||||
expect(feature).to.be.an(Feature);
|
||||
const geom = feature.getGeometry();
|
||||
@@ -53,43 +51,58 @@ describe('ol.format.IGC', function() {
|
||||
[6.851583333333333, 45.9376, 1303202928],
|
||||
[6.850183333333334, 45.93395, 1303203353],
|
||||
[6.800816666666667, 45.916066666666666, 1303203815],
|
||||
[6.851583333333333, 45.9376, 1303289328]]);
|
||||
[6.851583333333333, 45.9376, 1303289328],
|
||||
]);
|
||||
});
|
||||
|
||||
it('does transform and read a feature', function() {
|
||||
it('does transform and read a feature', function () {
|
||||
const feature = format.readFeature(igc, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(feature).to.be.an(Feature);
|
||||
const geom = feature.getGeometry();
|
||||
expect(geom.getType()).to.eql('LineString');
|
||||
|
||||
const expectedPoint1 = transform(
|
||||
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
|
||||
[6.851583333333333, 45.9376],
|
||||
'EPSG:4326',
|
||||
'EPSG:3857'
|
||||
);
|
||||
expectedPoint1.push(1303202928);
|
||||
const expectedPoint2 = transform(
|
||||
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
|
||||
[6.850183333333334, 45.93395],
|
||||
'EPSG:4326',
|
||||
'EPSG:3857'
|
||||
);
|
||||
expectedPoint2.push(1303203353);
|
||||
const expectedPoint3 = transform(
|
||||
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
|
||||
[6.800816666666667, 45.916066666666666],
|
||||
'EPSG:4326',
|
||||
'EPSG:3857'
|
||||
);
|
||||
expectedPoint3.push(1303203815);
|
||||
const expectedPoint4 = transform(
|
||||
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
|
||||
[6.851583333333333, 45.9376],
|
||||
'EPSG:4326',
|
||||
'EPSG:3857'
|
||||
);
|
||||
expectedPoint4.push(1303289328);
|
||||
|
||||
expect(geom.getCoordinates()).to.eql(
|
||||
[expectedPoint1, expectedPoint2, expectedPoint3, expectedPoint4]);
|
||||
expect(geom.getCoordinates()).to.eql([
|
||||
expectedPoint1,
|
||||
expectedPoint2,
|
||||
expectedPoint3,
|
||||
expectedPoint4,
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#readFeatures', function() {
|
||||
|
||||
it('does not read invalid features', function() {
|
||||
describe('#readFeatures', function () {
|
||||
it('does not read invalid features', function () {
|
||||
expect(format.readFeatures('invalid')).to.be.empty();
|
||||
});
|
||||
|
||||
it('does read features', function() {
|
||||
it('does read features', function () {
|
||||
const features = format.readFeatures(igc);
|
||||
expect(features.length).to.eql(1);
|
||||
const feature = features[0];
|
||||
@@ -100,12 +113,13 @@ describe('ol.format.IGC', function() {
|
||||
[6.851583333333333, 45.9376, 1303202928],
|
||||
[6.850183333333334, 45.93395, 1303203353],
|
||||
[6.800816666666667, 45.916066666666666, 1303203815],
|
||||
[6.851583333333333, 45.9376, 1303289328]]);
|
||||
[6.851583333333333, 45.9376, 1303289328],
|
||||
]);
|
||||
});
|
||||
|
||||
it('does transform and read features', function() {
|
||||
it('does transform and read features', function () {
|
||||
const features = format.readFeatures(igc, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(features.length).to.eql(1);
|
||||
const feature = features[0];
|
||||
@@ -114,21 +128,36 @@ describe('ol.format.IGC', function() {
|
||||
expect(geom.getType()).to.eql('LineString');
|
||||
|
||||
const expectedPoint1 = transform(
|
||||
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
|
||||
[6.851583333333333, 45.9376],
|
||||
'EPSG:4326',
|
||||
'EPSG:3857'
|
||||
);
|
||||
expectedPoint1.push(1303202928);
|
||||
const expectedPoint2 = transform(
|
||||
[6.850183333333334, 45.93395], 'EPSG:4326', 'EPSG:3857');
|
||||
[6.850183333333334, 45.93395],
|
||||
'EPSG:4326',
|
||||
'EPSG:3857'
|
||||
);
|
||||
expectedPoint2.push(1303203353);
|
||||
const expectedPoint3 = transform(
|
||||
[6.800816666666667, 45.916066666666666], 'EPSG:4326', 'EPSG:3857');
|
||||
[6.800816666666667, 45.916066666666666],
|
||||
'EPSG:4326',
|
||||
'EPSG:3857'
|
||||
);
|
||||
expectedPoint3.push(1303203815);
|
||||
const expectedPoint4 = transform(
|
||||
[6.851583333333333, 45.9376], 'EPSG:4326', 'EPSG:3857');
|
||||
[6.851583333333333, 45.9376],
|
||||
'EPSG:4326',
|
||||
'EPSG:3857'
|
||||
);
|
||||
expectedPoint4.push(1303289328);
|
||||
|
||||
expect(geom.getCoordinates()).to.eql(
|
||||
[expectedPoint1, expectedPoint2, expectedPoint3, expectedPoint4]);
|
||||
expect(geom.getCoordinates()).to.eql([
|
||||
expectedPoint1,
|
||||
expectedPoint2,
|
||||
expectedPoint3,
|
||||
expectedPoint4,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
+148
-151
@@ -1,169 +1,163 @@
|
||||
import IIIFInfo from '../../../../src/ol/format/IIIFInfo.js';
|
||||
import {Versions} from '../../../../src/ol/format/IIIFInfo.js';
|
||||
|
||||
describe('ol.format.IIIFInfo', function() {
|
||||
|
||||
describe('ol.format.IIIFInfo', function () {
|
||||
const iiifInfo = new IIIFInfo();
|
||||
|
||||
describe('setImageInfo', function() {
|
||||
|
||||
it('can handle image info JSON as object or as string serialization', function() {
|
||||
|
||||
describe('setImageInfo', function () {
|
||||
it('can handle image info JSON as object or as string serialization', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
'@id': 'http://iiif.test/id'
|
||||
'@id': 'http://iiif.test/id',
|
||||
});
|
||||
expect(iiifInfo.getImageApiVersion()).to.be(Versions.VERSION3);
|
||||
|
||||
iiifInfo.setImageInfo('{"@context": "http://iiif.io/api/image/2/context.json","@id":"http://iiif.test/id"}');
|
||||
iiifInfo.setImageInfo(
|
||||
'{"@context": "http://iiif.io/api/image/2/context.json","@id":"http://iiif.test/id"}'
|
||||
);
|
||||
expect(iiifInfo.getImageApiVersion()).to.be(Versions.VERSION2);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('getImageApiVersion', function() {
|
||||
|
||||
it('provides the correct Image API version', function() {
|
||||
|
||||
describe('getImageApiVersion', function () {
|
||||
it('provides the correct Image API version', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@id': 'http://iiif.test/id'
|
||||
'@id': 'http://iiif.test/id',
|
||||
});
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
iiifInfo.getImageApiVersion();
|
||||
}).to.throwException();
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
identifier: 'http://iiif.test/id',
|
||||
profile: 'this is no valid profile'
|
||||
profile: 'this is no valid profile',
|
||||
});
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
iiifInfo.getImageApiVersion();
|
||||
}).to.throwException();
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'this is no valid context',
|
||||
'@id': 'http://iiif.test/id'
|
||||
'@id': 'http://iiif.test/id',
|
||||
});
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
iiifInfo.getImageApiVersion();
|
||||
}).to.throwException();
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
identifier: 'http://iiif.test/id',
|
||||
profile: 'http://library.stanford.edu/iiif/image-api/compliance.html#level0'
|
||||
profile:
|
||||
'http://library.stanford.edu/iiif/image-api/compliance.html#level0',
|
||||
});
|
||||
expect(iiifInfo.getImageApiVersion()).to.be(Versions.VERSION1);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
'@id': 'http://iiif.test/id'
|
||||
'@context':
|
||||
'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
});
|
||||
expect(iiifInfo.getImageApiVersion()).to.be(Versions.VERSION1);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/1/context.json',
|
||||
identifier: 'http://iiif.test/id'
|
||||
identifier: 'http://iiif.test/id',
|
||||
});
|
||||
expect(iiifInfo.getImageApiVersion()).to.be(Versions.VERSION1);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
'@id': 'http://iiif.test/id'
|
||||
'@id': 'http://iiif.test/id',
|
||||
});
|
||||
expect(iiifInfo.getImageApiVersion()).to.be(Versions.VERSION2);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
id: 'http://iiif.test/id'
|
||||
id: 'http://iiif.test/id',
|
||||
});
|
||||
expect(iiifInfo.getImageApiVersion()).to.be(Versions.VERSION3);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('getComplianceLevelFromProfile', function() {
|
||||
|
||||
it('detects the correct compliance level', function() {
|
||||
|
||||
describe('getComplianceLevelFromProfile', function () {
|
||||
it('detects the correct compliance level', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
profile: 'level0'
|
||||
profile: 'level0',
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be(undefined);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
profile: 'http://iiif.io/api/image/level3.json'
|
||||
profile: 'http://iiif.io/api/image/level3.json',
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be(undefined);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
profile: 'level1'
|
||||
profile: 'level1',
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be(undefined);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
profile: 'http://iiif.io/api/image/2/level2.json'
|
||||
profile: 'http://iiif.io/api/image/2/level2.json',
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be('level2');
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
profile: ['http://iiif.io/api/image/2/level1.json']
|
||||
profile: ['http://iiif.io/api/image/2/level1.json'],
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be('level1');
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
profile: 'level4'
|
||||
profile: 'level4',
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be(undefined);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
profile: 'http://iiif.io/api/image/3/level3.json'
|
||||
profile: 'http://iiif.io/api/image/3/level3.json',
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be(undefined);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
profile: 'http://iiif.io/api/image/2/level1.json'
|
||||
profile: 'http://iiif.io/api/image/2/level1.json',
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be(undefined);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
profile: 'level2'
|
||||
profile: 'level2',
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be('level2');
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
profile: 'http://iiif.io/api/image/3/level1.json'
|
||||
profile: 'http://iiif.io/api/image/3/level1.json',
|
||||
});
|
||||
expect(iiifInfo.getComplianceLevelFromProfile()).to.be('level1');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('getComplianceLevelSupportedFeatures', function() {
|
||||
|
||||
it('provides the correct features for given versions and compliance levels', function() {
|
||||
|
||||
describe('getComplianceLevelSupportedFeatures', function () {
|
||||
it('provides the correct features for given versions and compliance levels', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
profile: 'http://library.stanford.edu/iiif/image-api/compliance.html#level0'
|
||||
'@context':
|
||||
'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
profile:
|
||||
'http://library.stanford.edu/iiif/image-api/compliance.html#level0',
|
||||
});
|
||||
let level = iiifInfo.getComplianceLevelSupportedFeatures();
|
||||
expect(level.supports).to.be.empty();
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
profile: 'http://library.stanford.edu/iiif/image-api/compliance.html#level1'
|
||||
'@context':
|
||||
'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
profile:
|
||||
'http://library.stanford.edu/iiif/image-api/compliance.html#level1',
|
||||
});
|
||||
level = iiifInfo.getComplianceLevelSupportedFeatures();
|
||||
expect(level.supports).to.have.length(4);
|
||||
@@ -173,8 +167,10 @@ describe('ol.format.IIIFInfo', function() {
|
||||
expect(level.supports).to.contain('sizeByPct');
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
profile: 'http://library.stanford.edu/iiif/image-api/compliance.html#level2'
|
||||
'@context':
|
||||
'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
profile:
|
||||
'http://library.stanford.edu/iiif/image-api/compliance.html#level2',
|
||||
});
|
||||
level = iiifInfo.getComplianceLevelSupportedFeatures();
|
||||
expect(level.supports).to.have.length(7);
|
||||
@@ -188,14 +184,14 @@ describe('ol.format.IIIFInfo', function() {
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
profile: 'http://iiif.io/api/image/2/level0.json'
|
||||
profile: 'http://iiif.io/api/image/2/level0.json',
|
||||
});
|
||||
level = iiifInfo.getComplianceLevelSupportedFeatures();
|
||||
expect(level.supports).to.be.empty();
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
profile: 'http://iiif.io/api/image/2/level1.json'
|
||||
profile: 'http://iiif.io/api/image/2/level1.json',
|
||||
});
|
||||
level = iiifInfo.getComplianceLevelSupportedFeatures();
|
||||
expect(level.supports).to.have.length(4);
|
||||
@@ -206,7 +202,7 @@ describe('ol.format.IIIFInfo', function() {
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
profile: 'http://iiif.io/api/image/2/level2.json'
|
||||
profile: 'http://iiif.io/api/image/2/level2.json',
|
||||
});
|
||||
level = iiifInfo.getComplianceLevelSupportedFeatures();
|
||||
expect(level.supports).to.have.length(8);
|
||||
@@ -221,14 +217,14 @@ describe('ol.format.IIIFInfo', function() {
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
profile: 'level0'
|
||||
profile: 'level0',
|
||||
});
|
||||
level = iiifInfo.getComplianceLevelSupportedFeatures();
|
||||
expect(level.supports).to.be.empty();
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
profile: 'level1'
|
||||
profile: 'level1',
|
||||
});
|
||||
level = iiifInfo.getComplianceLevelSupportedFeatures();
|
||||
expect(level.supports).to.have.length(5);
|
||||
@@ -240,7 +236,7 @@ describe('ol.format.IIIFInfo', function() {
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
profile: 'level2'
|
||||
profile: 'level2',
|
||||
});
|
||||
level = iiifInfo.getComplianceLevelSupportedFeatures();
|
||||
expect(level.supports).to.have.length(8);
|
||||
@@ -252,26 +248,23 @@ describe('ol.format.IIIFInfo', function() {
|
||||
expect(level.supports).to.contain('sizeByWh');
|
||||
expect(level.supports).to.contain('sizeByConfinedWh');
|
||||
expect(level.supports).to.contain('sizeByPct');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('getTileSourceOptions', function() {
|
||||
|
||||
it('produces options from minimal information responses', function() {
|
||||
|
||||
expect(function() {
|
||||
describe('getTileSourceOptions', function () {
|
||||
it('produces options from minimal information responses', function () {
|
||||
expect(function () {
|
||||
iiifInfo.setImageInfo({
|
||||
width: 2000,
|
||||
height: 1500
|
||||
height: 1500,
|
||||
});
|
||||
iiifInfo.getTileSourceOptions();
|
||||
}).to.throwException();
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
identifier: 'id',
|
||||
profile: 'http://library.stanford.edu/iiif/image-api/compliance.html#level0'
|
||||
profile:
|
||||
'http://library.stanford.edu/iiif/image-api/compliance.html#level0',
|
||||
});
|
||||
let options = iiifInfo.getTileSourceOptions();
|
||||
|
||||
@@ -282,7 +275,8 @@ describe('ol.format.IIIFInfo', function() {
|
||||
identifier: 'identifier-version-1.0',
|
||||
width: 2000,
|
||||
height: 1500,
|
||||
profile: 'http://library.stanford.edu/iiif/image-api/compliance.html#level0'
|
||||
profile:
|
||||
'http://library.stanford.edu/iiif/image-api/compliance.html#level0',
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
|
||||
@@ -303,7 +297,7 @@ describe('ol.format.IIIFInfo', function() {
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
'@id': 'http://iiif.test/version2/id'
|
||||
'@id': 'http://iiif.test/version2/id',
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
|
||||
@@ -311,21 +305,19 @@ describe('ol.format.IIIFInfo', function() {
|
||||
expect(options).to.have.property('version', Versions.VERSION2);
|
||||
expect(options).to.have.property('url', 'http://iiif.test/version2/id');
|
||||
expect(options).to.have.property('format', 'jpg');
|
||||
|
||||
});
|
||||
|
||||
it('uses preferred options if applicable', function() {
|
||||
|
||||
it('uses preferred options if applicable', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
'@id': 'http://iiif.test/version2/id',
|
||||
width: 2000,
|
||||
height: 1500,
|
||||
profile: ['http://iiif.io/api/image/2/level2.json']
|
||||
profile: ['http://iiif.io/api/image/2/level2.json'],
|
||||
});
|
||||
let options = iiifInfo.getTileSourceOptions({
|
||||
quality: 'bitonal',
|
||||
format: 'png'
|
||||
format: 'png',
|
||||
});
|
||||
expect(options).to.have.property('quality', 'bitonal');
|
||||
expect(options).to.have.property('format', 'png');
|
||||
@@ -336,29 +328,27 @@ describe('ol.format.IIIFInfo', function() {
|
||||
width: 2000,
|
||||
height: 1500,
|
||||
profile: 'level2',
|
||||
extraQualities: ['gray', 'bitonal']
|
||||
extraQualities: ['gray', 'bitonal'],
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions({
|
||||
quality: 'bitonal',
|
||||
format: 'png'
|
||||
format: 'png',
|
||||
});
|
||||
expect(options).to.have.property('quality', 'bitonal');
|
||||
expect(options).to.have.property('format', 'png');
|
||||
|
||||
});
|
||||
|
||||
it('ignores preferred options that are not supported', function() {
|
||||
|
||||
it('ignores preferred options that are not supported', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
'@id': 'http://iiif.test/version2/id',
|
||||
width: 2000,
|
||||
height: 1500,
|
||||
profile: ['http://iiif.io/api/image/2/level1.json']
|
||||
profile: ['http://iiif.io/api/image/2/level1.json'],
|
||||
});
|
||||
let options = iiifInfo.getTileSourceOptions({
|
||||
quality: 'bitonal',
|
||||
format: 'png'
|
||||
format: 'png',
|
||||
});
|
||||
expect(options).to.have.property('quality', 'default');
|
||||
expect(options).to.have.property('format', 'jpg');
|
||||
@@ -368,25 +358,26 @@ describe('ol.format.IIIFInfo', function() {
|
||||
'@id': 'http://iiif.test/version3/id',
|
||||
width: 2000,
|
||||
height: 1500,
|
||||
profile: 'level1'
|
||||
profile: 'level1',
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions({
|
||||
quality: 'bitonal',
|
||||
format: 'png'
|
||||
format: 'png',
|
||||
});
|
||||
expect(options).to.have.property('quality', 'default');
|
||||
expect(options).to.have.property('format', 'jpg');
|
||||
|
||||
});
|
||||
|
||||
it('combines supported features indicated by compliance level and explicitly stated in image info', function() {
|
||||
|
||||
it('combines supported features indicated by compliance level and explicitly stated in image info', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
profile: ['http://iiif.io/api/image/2/level1.json', {
|
||||
supports: ['regionByPct', 'sizeByWh']
|
||||
}]
|
||||
profile: [
|
||||
'http://iiif.io/api/image/2/level1.json',
|
||||
{
|
||||
supports: ['regionByPct', 'sizeByWh'],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
let options = iiifInfo.getTileSourceOptions();
|
||||
@@ -402,7 +393,7 @@ describe('ol.format.IIIFInfo', function() {
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
id: 'http://iiif.test/id',
|
||||
profile: 'level1',
|
||||
extraFeatures: ['regionByPct', 'sizeByPct']
|
||||
extraFeatures: ['regionByPct', 'sizeByPct'],
|
||||
});
|
||||
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
@@ -414,26 +405,28 @@ describe('ol.format.IIIFInfo', function() {
|
||||
expect(options.supports).to.contain('sizeByH');
|
||||
expect(options.supports).to.contain('sizeByWh');
|
||||
expect(options.supports).to.have.length(7);
|
||||
|
||||
});
|
||||
|
||||
it('uses the first available scale factors and tile sizes', function() {
|
||||
|
||||
it('uses the first available scale factors and tile sizes', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
'@context':
|
||||
'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
profile: 'http://library.stanford.edu/iiif/image-api/compliance.html#level0'
|
||||
profile:
|
||||
'http://library.stanford.edu/iiif/image-api/compliance.html#level0',
|
||||
});
|
||||
let options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.resolutions).to.be(undefined);
|
||||
expect(options.tileSize).to.be(undefined);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
'@context':
|
||||
'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
profile: 'http://library.stanford.edu/iiif/image-api/compliance.html#level0',
|
||||
profile:
|
||||
'http://library.stanford.edu/iiif/image-api/compliance.html#level0',
|
||||
scale_factors: [1, 2, 4],
|
||||
tile_width: 512
|
||||
tile_width: 512,
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.resolutions).to.have.length(3);
|
||||
@@ -445,12 +438,14 @@ describe('ol.format.IIIFInfo', function() {
|
||||
expect(options.tileSize[1]).to.be(512);
|
||||
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
'@context':
|
||||
'http://library.stanford.edu/iiif/image-api/1.1/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
profile: 'http://library.stanford.edu/iiif/image-api/compliance.html#level0',
|
||||
profile:
|
||||
'http://library.stanford.edu/iiif/image-api/compliance.html#level0',
|
||||
scale_factors: [1, 2, 4],
|
||||
tile_width: 512,
|
||||
tile_height: 1024
|
||||
tile_height: 1024,
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.resolutions).to.have.length(3);
|
||||
@@ -464,7 +459,7 @@ describe('ol.format.IIIFInfo', function() {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
profile: 'http://iiif.io/api/image/2/level0.json'
|
||||
profile: 'http://iiif.io/api/image/2/level0.json',
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.resolutions).to.be(undefined);
|
||||
@@ -474,14 +469,16 @@ describe('ol.format.IIIFInfo', function() {
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
profile: 'http://iiif.io/api/image/2/level0.json',
|
||||
tiles: [{
|
||||
scaleFactors: [1, 2, 4],
|
||||
width: 512
|
||||
},
|
||||
{
|
||||
scaleFactors: [1, 2, 4, 8, 16],
|
||||
width: 256
|
||||
}]
|
||||
tiles: [
|
||||
{
|
||||
scaleFactors: [1, 2, 4],
|
||||
width: 512,
|
||||
},
|
||||
{
|
||||
scaleFactors: [1, 2, 4, 8, 16],
|
||||
width: 256,
|
||||
},
|
||||
],
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.resolutions).to.have.length(3);
|
||||
@@ -496,11 +493,13 @@ describe('ol.format.IIIFInfo', function() {
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
profile: 'http://iiif.io/api/image/2/level0.json',
|
||||
tiles: [{
|
||||
scaleFactors: [1, 2, 4],
|
||||
width: 512,
|
||||
height: 1024
|
||||
}]
|
||||
tiles: [
|
||||
{
|
||||
scaleFactors: [1, 2, 4],
|
||||
width: 512,
|
||||
height: 1024,
|
||||
},
|
||||
],
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.resolutions).to.have.length(3);
|
||||
@@ -515,11 +514,13 @@ describe('ol.format.IIIFInfo', function() {
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
profile: 'level0',
|
||||
tiles: [{
|
||||
scaleFactors: [1, 2, 4, 8],
|
||||
width: 512,
|
||||
height: 256
|
||||
}]
|
||||
tiles: [
|
||||
{
|
||||
scaleFactors: [1, 2, 4, 8],
|
||||
width: 512,
|
||||
height: 256,
|
||||
},
|
||||
],
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.resolutions).to.have.length(4);
|
||||
@@ -530,28 +531,27 @@ describe('ol.format.IIIFInfo', function() {
|
||||
expect(options.tileSize).to.have.length(2);
|
||||
expect(options.tileSize[0]).to.be(512);
|
||||
expect(options.tileSize[1]).to.be(256);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('provides each given size in sizes as OpenLayers Size', function() {
|
||||
|
||||
it('provides each given size in sizes as OpenLayers Size', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/2/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
'sizes': [{
|
||||
width: 2000,
|
||||
height: 1000
|
||||
},
|
||||
{
|
||||
width: 1000,
|
||||
height: 500
|
||||
},
|
||||
{
|
||||
width: 500,
|
||||
height: 250
|
||||
}]
|
||||
'sizes': [
|
||||
{
|
||||
width: 2000,
|
||||
height: 1000,
|
||||
},
|
||||
{
|
||||
width: 1000,
|
||||
height: 500,
|
||||
},
|
||||
{
|
||||
width: 500,
|
||||
height: 250,
|
||||
},
|
||||
],
|
||||
});
|
||||
let options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.sizes).to.have.length(3);
|
||||
@@ -568,26 +568,26 @@ describe('ol.format.IIIFInfo', function() {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
'@id': 'http://iiif.test/id',
|
||||
'sizes': [{
|
||||
width: 1500,
|
||||
height: 800
|
||||
}]
|
||||
'sizes': [
|
||||
{
|
||||
width: 1500,
|
||||
height: 800,
|
||||
},
|
||||
],
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.sizes).to.have.length(1);
|
||||
expect(options.sizes[0]).to.have.length(2);
|
||||
expect(options.sizes[0][0]).to.be(1500);
|
||||
expect(options.sizes[0][1]).to.be(800);
|
||||
|
||||
});
|
||||
|
||||
it('respects the preferred image formats', function() {
|
||||
|
||||
it('respects the preferred image formats', function () {
|
||||
iiifInfo.setImageInfo({
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
'id': 'http://iiif.test/id',
|
||||
'profile': 'level0',
|
||||
'preferredFormats': ['png', 'gif']
|
||||
'preferredFormats': ['png', 'gif'],
|
||||
});
|
||||
let options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.format).to.be('jpg');
|
||||
@@ -596,7 +596,7 @@ describe('ol.format.IIIFInfo', function() {
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
'id': 'http://iiif.test/id',
|
||||
'profile': 'level1',
|
||||
'preferredFormats': ['png', 'gif']
|
||||
'preferredFormats': ['png', 'gif'],
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.format).to.be('jpg');
|
||||
@@ -606,7 +606,7 @@ describe('ol.format.IIIFInfo', function() {
|
||||
'id': 'http://iiif.test/id',
|
||||
'profile': 'level1',
|
||||
'extraFormats': ['webp', 'gif'],
|
||||
'preferredFormats': ['webp', 'png', 'gif']
|
||||
'preferredFormats': ['webp', 'png', 'gif'],
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.format).to.be('gif');
|
||||
@@ -615,12 +615,9 @@ describe('ol.format.IIIFInfo', function() {
|
||||
'@context': 'http://iiif.io/api/image/3/context.json',
|
||||
'id': 'http://iiif.test/id',
|
||||
'profile': 'level2',
|
||||
'preferredFormats': ['png', 'gif']
|
||||
'preferredFormats': ['png', 'gif'],
|
||||
});
|
||||
options = iiifInfo.getTileSourceOptions();
|
||||
expect(options.format).to.be('png');
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
+2453
-2116
File diff suppressed because it is too large
Load Diff
@@ -1,47 +1,50 @@
|
||||
import Feature from '../../../../src/ol/Feature.js';
|
||||
import MVT from '../../../../src/ol/format/MVT.js';
|
||||
import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import Point from '../../../../src/ol/geom/Point.js';
|
||||
import Polygon from '../../../../src/ol/geom/Polygon.js';
|
||||
import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import RenderFeature from '../../../../src/ol/render/Feature.js';
|
||||
|
||||
where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
|
||||
where('ArrayBuffer.isView').describe('ol.format.MVT', function () {
|
||||
let data;
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'spec/ol/data/14-8938-5680.vector.pbf');
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.onload = function() {
|
||||
xhr.onload = function () {
|
||||
data = xhr.response;
|
||||
done();
|
||||
};
|
||||
xhr.send();
|
||||
});
|
||||
|
||||
describe('#readFeatures', function() {
|
||||
|
||||
describe('#readFeatures', function () {
|
||||
const options = {
|
||||
featureProjection: 'EPSG:3857',
|
||||
extent: [1824704.739223726, 6141868.096770482, 1827150.7241288517, 6144314.081675608]
|
||||
extent: [
|
||||
1824704.739223726,
|
||||
6141868.096770482,
|
||||
1827150.7241288517,
|
||||
6144314.081675608,
|
||||
],
|
||||
};
|
||||
|
||||
it('uses ol.render.Feature as feature class by default', function() {
|
||||
it('uses ol.render.Feature as feature class by default', function () {
|
||||
const format = new MVT({layers: ['water']});
|
||||
const features = format.readFeatures(data, options);
|
||||
expect(features[0]).to.be.a(RenderFeature);
|
||||
});
|
||||
|
||||
it('parses only specified layers', function() {
|
||||
it('parses only specified layers', function () {
|
||||
const format = new MVT({layers: ['water']});
|
||||
const features = format.readFeatures(data, options);
|
||||
expect(features.length).to.be(10);
|
||||
});
|
||||
|
||||
it('parses geometries correctly', function() {
|
||||
it('parses geometries correctly', function () {
|
||||
const format = new MVT({
|
||||
featureClass: Feature,
|
||||
layers: ['poi_label']
|
||||
layers: ['poi_label'],
|
||||
});
|
||||
let geometry;
|
||||
|
||||
@@ -62,27 +65,27 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
expect(geometry.getCoordinates()[1][0]).to.eql([4160, 3489]);
|
||||
});
|
||||
|
||||
it('parses id property', function() {
|
||||
it('parses id property', function () {
|
||||
// ol.Feature
|
||||
let format = new MVT({
|
||||
featureClass: Feature,
|
||||
layers: ['building']
|
||||
layers: ['building'],
|
||||
});
|
||||
let features = format.readFeatures(data, options);
|
||||
expect(features[0].getId()).to.be(2);
|
||||
// ol.render.Feature
|
||||
format = new MVT({
|
||||
layers: ['building']
|
||||
layers: ['building'],
|
||||
});
|
||||
features = format.readFeatures(data, options);
|
||||
expect(features[0].getId()).to.be(2);
|
||||
});
|
||||
|
||||
it('accepts custom idProperty', function() {
|
||||
it('accepts custom idProperty', function () {
|
||||
const format = new MVT({
|
||||
featureClass: Feature,
|
||||
layers: ['poi_label'],
|
||||
idProperty: 'osm_id'
|
||||
idProperty: 'osm_id',
|
||||
});
|
||||
const features = format.readFeatures(data, options);
|
||||
|
||||
@@ -91,10 +94,10 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
expect(first.get('osm_id')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('accepts custom idProperty (render features)', function() {
|
||||
it('accepts custom idProperty (render features)', function () {
|
||||
const format = new MVT({
|
||||
layers: ['poi_label'],
|
||||
idProperty: 'osm_id'
|
||||
idProperty: 'osm_id',
|
||||
});
|
||||
|
||||
const features = format.readFeatures(data, options);
|
||||
@@ -104,10 +107,10 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
expect(first.get('osm_id')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('works if you provide a bogus idProperty', function() {
|
||||
it('works if you provide a bogus idProperty', function () {
|
||||
const format = new MVT({
|
||||
layers: ['poi_label'],
|
||||
idProperty: 'bogus'
|
||||
idProperty: 'bogus',
|
||||
});
|
||||
|
||||
const features = format.readFeatures(data, options);
|
||||
@@ -115,35 +118,42 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
|
||||
const first = features[0];
|
||||
expect(first.getId()).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ol.format.MVT', function() {
|
||||
|
||||
describe('ol.format.MVT', function () {
|
||||
const options = {
|
||||
featureProjection: 'EPSG:3857',
|
||||
extent: [1824704.739223726, 6141868.096770482, 1827150.7241288517, 6144314.081675608]
|
||||
extent: [
|
||||
1824704.739223726,
|
||||
6141868.096770482,
|
||||
1827150.7241288517,
|
||||
6144314.081675608,
|
||||
],
|
||||
};
|
||||
|
||||
describe('#createFeature_', function() {
|
||||
it('accepts a geometryName', function() {
|
||||
describe('#createFeature_', function () {
|
||||
it('accepts a geometryName', function () {
|
||||
const format = new MVT({
|
||||
featureClass: Feature,
|
||||
geometryName: 'myGeom'
|
||||
geometryName: 'myGeom',
|
||||
});
|
||||
const rawFeature = {
|
||||
id: 1,
|
||||
properties: {
|
||||
geometry: 'foo'
|
||||
geometry: 'foo',
|
||||
},
|
||||
type: 1,
|
||||
layer: {
|
||||
name: 'layer1'
|
||||
}
|
||||
name: 'layer1',
|
||||
},
|
||||
};
|
||||
format.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
format.readRawGeometry_ = function (
|
||||
{},
|
||||
rawFeature,
|
||||
flatCoordinates,
|
||||
ends
|
||||
) {
|
||||
flatCoordinates.push(0, 0);
|
||||
ends.push(2);
|
||||
};
|
||||
@@ -154,18 +164,23 @@ describe('ol.format.MVT', function() {
|
||||
expect(feature.get('geometry')).to.be('foo');
|
||||
});
|
||||
|
||||
it('detects a Polygon', function() {
|
||||
it('detects a Polygon', function () {
|
||||
const format = new MVT({
|
||||
featureClass: Feature
|
||||
featureClass: Feature,
|
||||
});
|
||||
const rawFeature = {
|
||||
type: 3,
|
||||
properties: {},
|
||||
layer: {
|
||||
name: 'layer1'
|
||||
}
|
||||
name: 'layer1',
|
||||
},
|
||||
};
|
||||
format.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
format.readRawGeometry_ = function (
|
||||
{},
|
||||
rawFeature,
|
||||
flatCoordinates,
|
||||
ends
|
||||
) {
|
||||
flatCoordinates.push(0, 0, 3, 0, 3, 3, 3, 0, 0, 0);
|
||||
flatCoordinates.push(1, 1, 1, 2, 2, 2, 2, 1, 1, 1);
|
||||
ends.push(10, 20);
|
||||
@@ -175,18 +190,23 @@ describe('ol.format.MVT', function() {
|
||||
expect(geometry).to.be.a(Polygon);
|
||||
});
|
||||
|
||||
it('detects a MultiPolygon', function() {
|
||||
it('detects a MultiPolygon', function () {
|
||||
const format = new MVT({
|
||||
featureClass: Feature
|
||||
featureClass: Feature,
|
||||
});
|
||||
const rawFeature = {
|
||||
type: 3,
|
||||
properties: {},
|
||||
layer: {
|
||||
name: 'layer1'
|
||||
}
|
||||
name: 'layer1',
|
||||
},
|
||||
};
|
||||
format.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
format.readRawGeometry_ = function (
|
||||
{},
|
||||
rawFeature,
|
||||
flatCoordinates,
|
||||
ends
|
||||
) {
|
||||
flatCoordinates.push(0, 0, 1, 0, 1, 1, 1, 0, 0, 0);
|
||||
flatCoordinates.push(1, 1, 2, 1, 2, 2, 2, 1, 1, 1);
|
||||
ends.push(10, 20);
|
||||
@@ -196,20 +216,25 @@ describe('ol.format.MVT', function() {
|
||||
expect(geometry).to.be.a(MultiPolygon);
|
||||
});
|
||||
|
||||
it('creates ol.render.Feature instances', function() {
|
||||
it('creates ol.render.Feature instances', function () {
|
||||
const format = new MVT();
|
||||
const rawFeature = {
|
||||
type: 3,
|
||||
properties: {
|
||||
foo: 'bar'
|
||||
foo: 'bar',
|
||||
},
|
||||
layer: {
|
||||
name: 'layer1'
|
||||
}
|
||||
name: 'layer1',
|
||||
},
|
||||
};
|
||||
let createdFlatCoordinates;
|
||||
let createdEnds;
|
||||
format.readRawGeometry_ = function({}, rawFeature, flatCoordinates, ends) {
|
||||
format.readRawGeometry_ = function (
|
||||
{},
|
||||
rawFeature,
|
||||
flatCoordinates,
|
||||
ends
|
||||
) {
|
||||
flatCoordinates.push(0, 0, 1, 0, 1, 1, 1, 0, 0, 0);
|
||||
flatCoordinates.push(1, 1, 2, 1, 2, 2, 2, 1, 1, 1);
|
||||
createdFlatCoordinates = flatCoordinates;
|
||||
@@ -218,14 +243,16 @@ describe('ol.format.MVT', function() {
|
||||
};
|
||||
format.dataProjection.setExtent([0, 0, 4096, 4096]);
|
||||
format.dataProjection.setWorldExtent(options.extent);
|
||||
const feature = format.createFeature_({}, rawFeature, format.adaptOptions(options));
|
||||
const feature = format.createFeature_(
|
||||
{},
|
||||
rawFeature,
|
||||
format.adaptOptions(options)
|
||||
);
|
||||
expect(feature).to.be.a(RenderFeature);
|
||||
expect(feature.getType()).to.be('Polygon');
|
||||
expect(feature.getFlatCoordinates()).to.equal(createdFlatCoordinates);
|
||||
expect(feature.getEnds()).to.equal(createdEnds);
|
||||
expect(feature.get('foo')).to.be('bar');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,51 +1,48 @@
|
||||
import Feature from '../../../../src/ol/Feature.js';
|
||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||
import OSMXML from '../../../../src/ol/format/OSMXML.js';
|
||||
import Point from '../../../../src/ol/geom/Point.js';
|
||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||
import {get as getProjection, transform} from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.format.OSMXML', function() {
|
||||
|
||||
describe('ol.format.OSMXML', function () {
|
||||
let format;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
format = new OSMXML();
|
||||
});
|
||||
|
||||
describe('#readProjection', function() {
|
||||
it('returns the default projection from document', function() {
|
||||
describe('#readProjection', function () {
|
||||
it('returns the default projection from document', function () {
|
||||
const projection = format.readProjectionFromDocument();
|
||||
expect(projection).to.eql(getProjection('EPSG:4326'));
|
||||
});
|
||||
|
||||
it('returns the default projection from node', function() {
|
||||
it('returns the default projection from node', function () {
|
||||
const projection = format.readProjectionFromNode();
|
||||
expect(projection).to.eql(getProjection('EPSG:4326'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#readFeatures', function() {
|
||||
|
||||
it('can read an empty document', function() {
|
||||
describe('#readFeatures', function () {
|
||||
it('can read an empty document', function () {
|
||||
const text =
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
'</osm>';
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
'</osm>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(0);
|
||||
});
|
||||
|
||||
it('can read nodes', function() {
|
||||
it('can read nodes', function () {
|
||||
const text =
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
' <node id="1" lat="1" lon="2">' +
|
||||
' <tag k="name" v="1"/>' +
|
||||
' </node>' +
|
||||
' <node id="2" lat="3" lon="4">' +
|
||||
' <tag k="name" v="2"/>' +
|
||||
' </node>' +
|
||||
'</osm>';
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
' <node id="1" lat="1" lon="2">' +
|
||||
' <tag k="name" v="1"/>' +
|
||||
' </node>' +
|
||||
' <node id="2" lat="3" lon="4">' +
|
||||
' <tag k="name" v="2"/>' +
|
||||
' </node>' +
|
||||
'</osm>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(2);
|
||||
const f = fs[0];
|
||||
@@ -55,22 +52,22 @@ describe('ol.format.OSMXML', function() {
|
||||
expect(g.getCoordinates()).to.eql([2, 1]);
|
||||
});
|
||||
|
||||
it('can read nodes and ways', function() {
|
||||
it('can read nodes and ways', function () {
|
||||
const text =
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
' <node id="1" lat="1" lon="2">' +
|
||||
' <tag k="name" v="1"/>' +
|
||||
' </node>' +
|
||||
' <node id="2" lat="3" lon="4">' +
|
||||
' <tag k="name" v="2"/>' +
|
||||
' </node>' +
|
||||
' <way id="3">' +
|
||||
' <tag k="name" v="3"/>' +
|
||||
' <nd ref="1" />' +
|
||||
' <nd ref="2" />' +
|
||||
' </way>' +
|
||||
'</osm>';
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
' <node id="1" lat="1" lon="2">' +
|
||||
' <tag k="name" v="1"/>' +
|
||||
' </node>' +
|
||||
' <node id="2" lat="3" lon="4">' +
|
||||
' <tag k="name" v="2"/>' +
|
||||
' </node>' +
|
||||
' <way id="3">' +
|
||||
' <tag k="name" v="3"/>' +
|
||||
' <nd ref="1" />' +
|
||||
' <nd ref="2" />' +
|
||||
' </way>' +
|
||||
'</osm>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
const point = fs[0];
|
||||
@@ -82,49 +79,53 @@ describe('ol.format.OSMXML', function() {
|
||||
expect(line).to.be.an(Feature);
|
||||
g = line.getGeometry();
|
||||
expect(g).to.be.an(LineString);
|
||||
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[2, 1],
|
||||
[4, 3],
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
it('can read ways before nodes', function() {
|
||||
it('can read ways before nodes', function () {
|
||||
const text =
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
' <way id="3">' +
|
||||
' <tag k="name" v="3"/>' +
|
||||
' <nd ref="1" />' +
|
||||
' <nd ref="2" />' +
|
||||
' </way>' +
|
||||
' <node id="1" lat="1" lon="2">' +
|
||||
' <tag k="name" v="1"/>' +
|
||||
' </node>' +
|
||||
' <node id="2" lat="3" lon="4">' +
|
||||
' <tag k="name" v="2"/>' +
|
||||
' </node>' +
|
||||
'</osm>';
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
' <way id="3">' +
|
||||
' <tag k="name" v="3"/>' +
|
||||
' <nd ref="1" />' +
|
||||
' <nd ref="2" />' +
|
||||
' </way>' +
|
||||
' <node id="1" lat="1" lon="2">' +
|
||||
' <tag k="name" v="1"/>' +
|
||||
' </node>' +
|
||||
' <node id="2" lat="3" lon="4">' +
|
||||
' <tag k="name" v="2"/>' +
|
||||
' </node>' +
|
||||
'</osm>';
|
||||
const fs = format.readFeatures(text);
|
||||
expect(fs).to.have.length(3);
|
||||
const line = fs[2];
|
||||
expect(line).to.be.an(Feature);
|
||||
const g = line.getGeometry();
|
||||
expect(g).to.be.an(LineString);
|
||||
expect(g.getCoordinates()).to.eql([[2, 1], [4, 3]]);
|
||||
expect(g.getCoordinates()).to.eql([
|
||||
[2, 1],
|
||||
[4, 3],
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
it('can transform and read nodes', function() {
|
||||
it('can transform and read nodes', function () {
|
||||
const text =
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
' <node id="1" lat="1" lon="2">' +
|
||||
' <tag k="name" v="1"/>' +
|
||||
' </node>' +
|
||||
' <node id="2" lat="3" lon="4">' +
|
||||
' <tag k="name" v="2"/>' +
|
||||
' </node>' +
|
||||
'</osm>';
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<osm version="0.6" generator="my hand">' +
|
||||
' <node id="1" lat="1" lon="2">' +
|
||||
' <tag k="name" v="1"/>' +
|
||||
' </node>' +
|
||||
' <node id="2" lat="3" lon="4">' +
|
||||
' <tag k="name" v="2"/>' +
|
||||
' </node>' +
|
||||
'</osm>';
|
||||
const fs = format.readFeatures(text, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(fs).to.have.length(2);
|
||||
const f = fs[0];
|
||||
@@ -132,9 +133,8 @@ describe('ol.format.OSMXML', function() {
|
||||
const g = f.getGeometry();
|
||||
expect(g).to.be.an(Point);
|
||||
expect(g.getCoordinates()).to.eql(
|
||||
transform([2, 1], 'EPSG:4326', 'EPSG:3857'));
|
||||
transform([2, 1], 'EPSG:4326', 'EPSG:3857')
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,45 +1,43 @@
|
||||
import OWS from '../../../../src/ol/format/OWS.js';
|
||||
import {parse} from '../../../../src/ol/xml.js';
|
||||
|
||||
|
||||
describe('ol.format.OWS 1.1', function() {
|
||||
|
||||
describe('ol.format.OWS 1.1', function () {
|
||||
const parser = new OWS();
|
||||
|
||||
it('should read ServiceProvider tag properly', function() {
|
||||
it('should read ServiceProvider tag properly', function () {
|
||||
const doc = parse(
|
||||
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
|
||||
'xmlns:xlink="http://www.w3.org/1999/xlink" >' +
|
||||
'<ows:ServiceProvider>' +
|
||||
'<ows:ProviderName>MiraMon</ows:ProviderName>' +
|
||||
'<ows:ProviderSite ' +
|
||||
'xlink:href="http://www.creaf.uab.es/miramon"/>' +
|
||||
'<ows:ServiceContact>' +
|
||||
'<ows:IndividualName>Joan Maso Pau' +
|
||||
'</ows:IndividualName>' +
|
||||
'<ows:PositionName>Senior Software Engineer' +
|
||||
'</ows:PositionName>' +
|
||||
'<ows:ContactInfo>' +
|
||||
'<ows:Phone>' +
|
||||
'<ows:Voice>+34 93 581 1312</ows:Voice>' +
|
||||
'<ows:Facsimile>+34 93 581 4151' +
|
||||
'</ows:Facsimile>' +
|
||||
'</ows:Phone>' +
|
||||
'<ows:Address>' +
|
||||
'<ows:DeliveryPoint>Fac Ciencies UAB' +
|
||||
'</ows:DeliveryPoint>' +
|
||||
'<ows:City>Bellaterra</ows:City>' +
|
||||
'<ows:AdministrativeArea>Barcelona' +
|
||||
'</ows:AdministrativeArea>' +
|
||||
'<ows:PostalCode>08193</ows:PostalCode>' +
|
||||
'<ows:Country>Spain</ows:Country>' +
|
||||
'<ows:ElectronicMailAddress>joan.maso@uab.es' +
|
||||
'</ows:ElectronicMailAddress>' +
|
||||
'</ows:Address>' +
|
||||
'</ows:ContactInfo>' +
|
||||
'</ows:ServiceContact>' +
|
||||
'</ows:ServiceProvider>' +
|
||||
'</ows:GetCapabilities>'
|
||||
'<ows:ProviderSite ' +
|
||||
'xlink:href="http://www.creaf.uab.es/miramon"/>' +
|
||||
'<ows:ServiceContact>' +
|
||||
'<ows:IndividualName>Joan Maso Pau' +
|
||||
'</ows:IndividualName>' +
|
||||
'<ows:PositionName>Senior Software Engineer' +
|
||||
'</ows:PositionName>' +
|
||||
'<ows:ContactInfo>' +
|
||||
'<ows:Phone>' +
|
||||
'<ows:Voice>+34 93 581 1312</ows:Voice>' +
|
||||
'<ows:Facsimile>+34 93 581 4151' +
|
||||
'</ows:Facsimile>' +
|
||||
'</ows:Phone>' +
|
||||
'<ows:Address>' +
|
||||
'<ows:DeliveryPoint>Fac Ciencies UAB' +
|
||||
'</ows:DeliveryPoint>' +
|
||||
'<ows:City>Bellaterra</ows:City>' +
|
||||
'<ows:AdministrativeArea>Barcelona' +
|
||||
'</ows:AdministrativeArea>' +
|
||||
'<ows:PostalCode>08193</ows:PostalCode>' +
|
||||
'<ows:Country>Spain</ows:Country>' +
|
||||
'<ows:ElectronicMailAddress>joan.maso@uab.es' +
|
||||
'</ows:ElectronicMailAddress>' +
|
||||
'</ows:Address>' +
|
||||
'</ows:ContactInfo>' +
|
||||
'</ows:ServiceContact>' +
|
||||
'</ows:ServiceProvider>' +
|
||||
'</ows:GetCapabilities>'
|
||||
);
|
||||
|
||||
const obj = parser.read(doc);
|
||||
@@ -55,23 +53,23 @@ describe('ol.format.OWS 1.1', function() {
|
||||
expect(serviceProvider.ServiceContact.PositionName).to.eql(position);
|
||||
});
|
||||
|
||||
it('should read ServiceIdentification tag properly', function() {
|
||||
it('should read ServiceIdentification tag properly', function () {
|
||||
const doc = parse(
|
||||
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
|
||||
'xmlns:xlink="http://www.w3.org/1999/xlink" >' +
|
||||
'<ows:ServiceIdentification>' +
|
||||
'<ows:Title>Web Map Tile Service</ows:Title>' +
|
||||
'<ows:Abstract>Service that contrains the map access interface ' +
|
||||
'to some TileMatrixSets</ows:Abstract>' +
|
||||
'<ows:Keywords>' +
|
||||
'<ows:Keyword>tile</ows:Keyword>' +
|
||||
'<ows:Keyword>tile matrix set</ows:Keyword>' +
|
||||
'<ows:Keyword>map</ows:Keyword>' +
|
||||
'</ows:Keywords>' +
|
||||
'<ows:ServiceType>OGC WMTS</ows:ServiceType>' +
|
||||
'<ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>' +
|
||||
'<ows:Fees>none</ows:Fees>' +
|
||||
'<ows:AccessConstraints>none</ows:AccessConstraints>' +
|
||||
'<ows:Title>Web Map Tile Service</ows:Title>' +
|
||||
'<ows:Abstract>Service that contrains the map access interface ' +
|
||||
'to some TileMatrixSets</ows:Abstract>' +
|
||||
'<ows:Keywords>' +
|
||||
'<ows:Keyword>tile</ows:Keyword>' +
|
||||
'<ows:Keyword>tile matrix set</ows:Keyword>' +
|
||||
'<ows:Keyword>map</ows:Keyword>' +
|
||||
'</ows:Keywords>' +
|
||||
'<ows:ServiceType>OGC WMTS</ows:ServiceType>' +
|
||||
'<ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>' +
|
||||
'<ows:Fees>none</ows:Fees>' +
|
||||
'<ows:AccessConstraints>none</ows:AccessConstraints>' +
|
||||
'</ows:ServiceIdentification>' +
|
||||
'</ows:GetCapabilities>'
|
||||
);
|
||||
@@ -90,46 +88,46 @@ describe('ol.format.OWS 1.1', function() {
|
||||
expect(serviceIdentification.ServiceType).to.eql('OGC WMTS');
|
||||
});
|
||||
|
||||
it('should read OperationsMetadata tag properly', function() {
|
||||
it('should read OperationsMetadata tag properly', function () {
|
||||
const doc = parse(
|
||||
'<ows:GetCapabilities xmlns:ows="http://www.opengis.net/ows/1.1" ' +
|
||||
'xmlns:xlink="http://www.w3.org/1999/xlink" >' +
|
||||
'<ows:OperationsMetadata>' +
|
||||
'<ows:Operation name="GetCapabilities">' +
|
||||
'<ows:DCP>' +
|
||||
'<ows:HTTP>' +
|
||||
'<ows:Get xlink:href=' +
|
||||
'"http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?">' +
|
||||
'<ows:Constraint name="GetEncoding">' +
|
||||
'<ows:AllowedValues>' +
|
||||
'<ows:Value>KVP</ows:Value>' +
|
||||
'<ows:Value>SOAP</ows:Value>' +
|
||||
'</ows:AllowedValues>' +
|
||||
'</ows:Constraint>' +
|
||||
'</ows:Get>' +
|
||||
'</ows:HTTP>' +
|
||||
'</ows:DCP>' +
|
||||
'</ows:Operation>' +
|
||||
'<ows:Operation name="GetTile">' +
|
||||
'<ows:DCP>' +
|
||||
'<ows:HTTP>' +
|
||||
'<ows:Get xlink:href="http://www.miramon.uab.es/cgi-' +
|
||||
'bin/MiraMon5_0.cgi?"/>' +
|
||||
'<ows:Get xlink:href="http://www.miramon.uab.es/cgi-' +
|
||||
'bin/MiraMon6_0.cgi?"/>' +
|
||||
'<ows:Post xlink:href="http://www.miramon.uab.es/cgi-' +
|
||||
'bin/MiraMon7_0.cgi?"/>' +
|
||||
'</ows:HTTP>' +
|
||||
'</ows:DCP>' +
|
||||
'</ows:Operation>' +
|
||||
'<ows:Operation name="GetFeatureInfo">' +
|
||||
'<ows:DCP>' +
|
||||
'<ows:HTTP>' +
|
||||
'<ows:Get xlink:href="http://www.miramon.uab.es/cgi-' +
|
||||
'bin/MiraMon5_0.cgi?"/>' +
|
||||
'</ows:HTTP>' +
|
||||
'</ows:DCP>' +
|
||||
'</ows:Operation>' +
|
||||
'<ows:Operation name="GetCapabilities">' +
|
||||
'<ows:DCP>' +
|
||||
'<ows:HTTP>' +
|
||||
'<ows:Get xlink:href=' +
|
||||
'"http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?">' +
|
||||
'<ows:Constraint name="GetEncoding">' +
|
||||
'<ows:AllowedValues>' +
|
||||
'<ows:Value>KVP</ows:Value>' +
|
||||
'<ows:Value>SOAP</ows:Value>' +
|
||||
'</ows:AllowedValues>' +
|
||||
'</ows:Constraint>' +
|
||||
'</ows:Get>' +
|
||||
'</ows:HTTP>' +
|
||||
'</ows:DCP>' +
|
||||
'</ows:Operation>' +
|
||||
'<ows:Operation name="GetTile">' +
|
||||
'<ows:DCP>' +
|
||||
'<ows:HTTP>' +
|
||||
'<ows:Get xlink:href="http://www.miramon.uab.es/cgi-' +
|
||||
'bin/MiraMon5_0.cgi?"/>' +
|
||||
'<ows:Get xlink:href="http://www.miramon.uab.es/cgi-' +
|
||||
'bin/MiraMon6_0.cgi?"/>' +
|
||||
'<ows:Post xlink:href="http://www.miramon.uab.es/cgi-' +
|
||||
'bin/MiraMon7_0.cgi?"/>' +
|
||||
'</ows:HTTP>' +
|
||||
'</ows:DCP>' +
|
||||
'</ows:Operation>' +
|
||||
'<ows:Operation name="GetFeatureInfo">' +
|
||||
'<ows:DCP>' +
|
||||
'<ows:HTTP>' +
|
||||
'<ows:Get xlink:href="http://www.miramon.uab.es/cgi-' +
|
||||
'bin/MiraMon5_0.cgi?"/>' +
|
||||
'</ows:HTTP>' +
|
||||
'</ows:DCP>' +
|
||||
'</ows:Operation>' +
|
||||
'</ows:OperationsMetadata>' +
|
||||
'</ows:GetCapabilities>'
|
||||
);
|
||||
@@ -155,5 +153,4 @@ describe('ol.format.OWS 1.1', function() {
|
||||
expect(dcp.HTTP.Get[0].href).to.eql(url);
|
||||
expect(dcp.HTTP.Get[0].Constraint).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import Feature from '../../../../src/ol/Feature.js';
|
||||
import Polyline, * as polyline from '../../../../src/ol/format/Polyline.js';
|
||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||
import Polyline, * as polyline from '../../../../src/ol/format/Polyline.js';
|
||||
import {get as getProjection, transform} from '../../../../src/ol/proj.js';
|
||||
|
||||
describe('ol.format.Polyline', function() {
|
||||
|
||||
describe('ol.format.Polyline', function () {
|
||||
let format;
|
||||
let points;
|
||||
let flatPoints, encodedFlatPoints, flippedFlatPoints;
|
||||
@@ -16,29 +15,21 @@ describe('ol.format.Polyline', function() {
|
||||
function resetTestingData() {
|
||||
format = new Polyline();
|
||||
points = [
|
||||
[-120.20000, 38.50000],
|
||||
[-120.95000, 40.70000],
|
||||
[-126.45300, 43.25200]
|
||||
];
|
||||
flatPoints = [
|
||||
-120.20000, 38.50000,
|
||||
-120.95000, 40.70000,
|
||||
-126.45300, 43.25200
|
||||
];
|
||||
flippedFlatPoints = [
|
||||
38.50000, -120.20000,
|
||||
40.70000, -120.95000,
|
||||
43.25200, -126.45300
|
||||
[-120.2, 38.5],
|
||||
[-120.95, 40.7],
|
||||
[-126.453, 43.252],
|
||||
];
|
||||
flatPoints = [-120.2, 38.5, -120.95, 40.7, -126.453, 43.252];
|
||||
flippedFlatPoints = [38.5, -120.2, 40.7, -120.95, 43.252, -126.453];
|
||||
encodedFlatPoints = '_p~iF~ps|U_ulLnnqC_mqNvxq`@';
|
||||
points3857 = [
|
||||
transform([-120.20000, 38.50000], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([-120.95000, 40.70000], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([-126.45300, 43.25200], 'EPSG:4326', 'EPSG:3857')
|
||||
transform([-120.2, 38.5], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([-120.95, 40.7], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([-126.453, 43.252], 'EPSG:4326', 'EPSG:3857'),
|
||||
];
|
||||
|
||||
floats = [0.00, 0.15, -0.01, -0.16, 0.16, 0.01];
|
||||
smallFloats = [0.00000, 0.00015, -0.00001, -0.00016, 0.00016, 0.00001];
|
||||
floats = [0.0, 0.15, -0.01, -0.16, 0.16, 0.01];
|
||||
smallFloats = [0.0, 0.00015, -0.00001, -0.00016, 0.00016, 0.00001];
|
||||
encodedFloats = '?]@^_@A';
|
||||
|
||||
signedIntegers = [0, 15, -1, -16, 16, 1];
|
||||
@@ -51,32 +42,31 @@ describe('ol.format.Polyline', function() {
|
||||
// Reset testing data
|
||||
beforeEach(resetTestingData);
|
||||
|
||||
describe('#readProjectionFromText', function() {
|
||||
it('returns the default projection', function() {
|
||||
describe('#readProjectionFromText', function () {
|
||||
it('returns the default projection', function () {
|
||||
const projection = format.readProjectionFromText(encodedFlatPoints);
|
||||
expect(projection).to.eql(getProjection('EPSG:4326'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('encodeDeltas', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('encodeDeltas', function () {
|
||||
it('returns expected value', function () {
|
||||
const encodeDeltas = polyline.encodeDeltas;
|
||||
|
||||
expect(encodeDeltas(flippedFlatPoints, 2)).to.eql(encodedFlatPoints);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decodeDeltas', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('decodeDeltas', function () {
|
||||
it('returns expected value', function () {
|
||||
const decodeDeltas = polyline.decodeDeltas;
|
||||
|
||||
expect(decodeDeltas(encodedFlatPoints, 2)).to.eql(flippedFlatPoints);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('encodeFloats', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('encodeFloats', function () {
|
||||
it('returns expected value', function () {
|
||||
const encodeFloats = polyline.encodeFloats;
|
||||
|
||||
expect(encodeFloats(smallFloats)).to.eql(encodedFloats);
|
||||
@@ -88,8 +78,8 @@ describe('ol.format.Polyline', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('decodeFloats', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('decodeFloats', function () {
|
||||
it('returns expected value', function () {
|
||||
const decodeFloats = polyline.decodeFloats;
|
||||
|
||||
expect(decodeFloats(encodedFloats)).to.eql(smallFloats);
|
||||
@@ -98,50 +88,51 @@ describe('ol.format.Polyline', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('encodeSignedIntegers', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('encodeSignedIntegers', function () {
|
||||
it('returns expected value', function () {
|
||||
const encodeSignedIntegers = polyline.encodeSignedIntegers;
|
||||
|
||||
expect(encodeSignedIntegers(
|
||||
signedIntegers)).to.eql(encodedSignedIntegers);
|
||||
expect(encodeSignedIntegers(signedIntegers)).to.eql(
|
||||
encodedSignedIntegers
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decodeSignedIntegers', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('decodeSignedIntegers', function () {
|
||||
it('returns expected value', function () {
|
||||
const decodeSignedIntegers = polyline.decodeSignedIntegers;
|
||||
|
||||
expect(decodeSignedIntegers(
|
||||
encodedSignedIntegers)).to.eql(signedIntegers);
|
||||
expect(decodeSignedIntegers(encodedSignedIntegers)).to.eql(
|
||||
signedIntegers
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('encodeUnsignedIntegers', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('encodeUnsignedIntegers', function () {
|
||||
it('returns expected value', function () {
|
||||
const encodeUnsignedIntegers = polyline.encodeUnsignedIntegers;
|
||||
|
||||
expect(encodeUnsignedIntegers(
|
||||
unsignedIntegers)).to.eql(encodedUnsignedIntegers);
|
||||
expect(encodeUnsignedIntegers(unsignedIntegers)).to.eql(
|
||||
encodedUnsignedIntegers
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decodeUnsignedIntegers', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('decodeUnsignedIntegers', function () {
|
||||
it('returns expected value', function () {
|
||||
const decodeUnsignedIntegers = polyline.decodeUnsignedIntegers;
|
||||
|
||||
expect(decodeUnsignedIntegers(
|
||||
encodedUnsignedIntegers)).to.eql(unsignedIntegers);
|
||||
expect(decodeUnsignedIntegers(encodedUnsignedIntegers)).to.eql(
|
||||
unsignedIntegers
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('encodeFloat', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('encodeFloat', function () {
|
||||
it('returns expected value', function () {
|
||||
const encodeFloats = polyline.encodeFloats;
|
||||
|
||||
expect(encodeFloats([0.00000])).to.eql('?');
|
||||
expect(encodeFloats([0.0])).to.eql('?');
|
||||
expect(encodeFloats([-0.00001])).to.eql('@');
|
||||
expect(encodeFloats([0.00001])).to.eql('A');
|
||||
expect(encodeFloats([-0.00002])).to.eql('B');
|
||||
@@ -152,19 +143,19 @@ describe('ol.format.Polyline', function() {
|
||||
expect(encodeFloats([-0.1], 10)).to.eql('@');
|
||||
expect(encodeFloats([0.1], 10)).to.eql('A');
|
||||
|
||||
expect(encodeFloats([16 * 32 / 1e5])).to.eql('__@');
|
||||
expect(encodeFloats([16 * 32 * 32 / 1e5])).to.eql('___@');
|
||||
expect(encodeFloats([(16 * 32) / 1e5])).to.eql('__@');
|
||||
expect(encodeFloats([(16 * 32 * 32) / 1e5])).to.eql('___@');
|
||||
|
||||
// from the "Encoded Polyline Algorithm Format" page at Google
|
||||
expect(encodeFloats([-179.9832104])).to.eql('`~oia@');
|
||||
});
|
||||
});
|
||||
|
||||
describe('decodeFloat', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('decodeFloat', function () {
|
||||
it('returns expected value', function () {
|
||||
const decodeFloats = polyline.decodeFloats;
|
||||
|
||||
expect(decodeFloats('?')).to.eql([0.00000]);
|
||||
expect(decodeFloats('?')).to.eql([0.0]);
|
||||
expect(decodeFloats('@')).to.eql([-0.00001]);
|
||||
expect(decodeFloats('A')).to.eql([0.00001]);
|
||||
expect(decodeFloats('B')).to.eql([-0.00002]);
|
||||
@@ -175,17 +166,16 @@ describe('ol.format.Polyline', function() {
|
||||
expect(decodeFloats('@', 10)).to.eql([-0.1]);
|
||||
expect(decodeFloats('A', 10)).to.eql([0.1]);
|
||||
|
||||
expect(decodeFloats('__@')).to.eql([16 * 32 / 1e5]);
|
||||
expect(decodeFloats('___@')).to.eql([16 * 32 * 32 / 1e5]);
|
||||
expect(decodeFloats('__@')).to.eql([(16 * 32) / 1e5]);
|
||||
expect(decodeFloats('___@')).to.eql([(16 * 32 * 32) / 1e5]);
|
||||
|
||||
// from the "Encoded Polyline Algorithm Format" page at Google
|
||||
expect(decodeFloats('`~oia@')).to.eql([-179.98321]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('encodeSignedInteger', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('encodeSignedInteger', function () {
|
||||
it('returns expected value', function () {
|
||||
const encodeSignedIntegers = polyline.encodeSignedIntegers;
|
||||
|
||||
expect(encodeSignedIntegers([0])).to.eql('?');
|
||||
@@ -202,8 +192,8 @@ describe('ol.format.Polyline', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('decodeSignedInteger', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('decodeSignedInteger', function () {
|
||||
it('returns expected value', function () {
|
||||
const decodeSignedIntegers = polyline.decodeSignedIntegers;
|
||||
|
||||
expect(decodeSignedIntegers('?')).to.eql([0]);
|
||||
@@ -220,9 +210,8 @@ describe('ol.format.Polyline', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('encodeUnsignedInteger', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('encodeUnsignedInteger', function () {
|
||||
it('returns expected value', function () {
|
||||
const encodeUnsignedInteger = polyline.encodeUnsignedInteger;
|
||||
|
||||
expect(encodeUnsignedInteger(0)).to.eql('?');
|
||||
@@ -241,8 +230,8 @@ describe('ol.format.Polyline', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('decodeUnsignedInteger', function() {
|
||||
it('returns expected value', function() {
|
||||
describe('decodeUnsignedInteger', function () {
|
||||
it('returns expected value', function () {
|
||||
const decodeUnsignedIntegers = polyline.decodeUnsignedIntegers;
|
||||
|
||||
expect(decodeUnsignedIntegers('?')).to.eql([0]);
|
||||
@@ -261,9 +250,8 @@ describe('ol.format.Polyline', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#readFeature', function() {
|
||||
|
||||
it('returns the expected feature', function() {
|
||||
describe('#readFeature', function () {
|
||||
it('returns the expected feature', function () {
|
||||
const feature = format.readFeature(encodedFlatPoints);
|
||||
expect(feature).to.be.an(Feature);
|
||||
const geometry = feature.getGeometry();
|
||||
@@ -271,21 +259,19 @@ describe('ol.format.Polyline', function() {
|
||||
expect(geometry.getFlatCoordinates()).to.eql(flatPoints);
|
||||
});
|
||||
|
||||
it('transforms and returns the expected feature', function() {
|
||||
it('transforms and returns the expected feature', function () {
|
||||
const feature = format.readFeature(encodedFlatPoints, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(feature).to.be.an(Feature);
|
||||
const geometry = feature.getGeometry();
|
||||
expect(geometry).to.be.an(LineString);
|
||||
expect(geometry.getCoordinates()).to.eql(points3857);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#readFeatures', function() {
|
||||
|
||||
it('returns the expected feature', function() {
|
||||
describe('#readFeatures', function () {
|
||||
it('returns the expected feature', function () {
|
||||
const features = format.readFeatures(encodedFlatPoints);
|
||||
expect(features).to.be.an(Array);
|
||||
expect(features).to.have.length(1);
|
||||
@@ -296,9 +282,9 @@ describe('ol.format.Polyline', function() {
|
||||
expect(geometry.getFlatCoordinates()).to.eql(flatPoints);
|
||||
});
|
||||
|
||||
it('transforms and returns the expected features', function() {
|
||||
it('transforms and returns the expected features', function () {
|
||||
const features = format.readFeatures(encodedFlatPoints, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(features).to.be.an(Array);
|
||||
expect(features).to.have.length(1);
|
||||
@@ -308,101 +294,94 @@ describe('ol.format.Polyline', function() {
|
||||
expect(geometry).to.be.an(LineString);
|
||||
expect(geometry.getCoordinates()).to.eql(points3857);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#readGeometry', function() {
|
||||
|
||||
it('returns the expected geometry', function() {
|
||||
describe('#readGeometry', function () {
|
||||
it('returns the expected geometry', function () {
|
||||
const geometry = format.readGeometry(encodedFlatPoints);
|
||||
expect(geometry).to.be.an(LineString);
|
||||
expect(geometry.getFlatCoordinates()).to.eql(flatPoints);
|
||||
});
|
||||
|
||||
it('parses XYZ linestring', function() {
|
||||
const xyz = polyline.encodeDeltas([
|
||||
38.500, -120.200, 100,
|
||||
40.700, -120.950, 200,
|
||||
43.252, -126.453, 20
|
||||
], 3);
|
||||
it('parses XYZ linestring', function () {
|
||||
const xyz = polyline.encodeDeltas(
|
||||
[38.5, -120.2, 100, 40.7, -120.95, 200, 43.252, -126.453, 20],
|
||||
3
|
||||
);
|
||||
const format = new Polyline({
|
||||
geometryLayout: 'XYZ'
|
||||
geometryLayout: 'XYZ',
|
||||
});
|
||||
|
||||
const geometry = format.readGeometry(xyz);
|
||||
expect(geometry.getLayout()).to.eql('XYZ');
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[-120.200, 38.500, 100],
|
||||
[-120.950, 40.700, 200],
|
||||
[-126.453, 43.252, 20]
|
||||
[-120.2, 38.5, 100],
|
||||
[-120.95, 40.7, 200],
|
||||
[-126.453, 43.252, 20],
|
||||
]);
|
||||
});
|
||||
|
||||
it('transforms and returns the expected geometry', function() {
|
||||
it('transforms and returns the expected geometry', function () {
|
||||
const geometry = format.readGeometry(encodedFlatPoints, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(geometry).to.be.an(LineString);
|
||||
expect(geometry.getCoordinates()).to.eql(points3857);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#readProjection', function() {
|
||||
|
||||
it('returns the expected projection', function() {
|
||||
describe('#readProjection', function () {
|
||||
it('returns the expected projection', function () {
|
||||
const projection = format.readProjection(encodedFlatPoints);
|
||||
expect(projection).to.be(getProjection('EPSG:4326'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#writeFeature', function() {
|
||||
|
||||
it('returns the expected text', function() {
|
||||
describe('#writeFeature', function () {
|
||||
it('returns the expected text', function () {
|
||||
const feature = new Feature(new LineString(points));
|
||||
expect(format.writeFeature(feature)).to.be(encodedFlatPoints);
|
||||
});
|
||||
|
||||
it('transforms and returns the expected text', function() {
|
||||
it('transforms and returns the expected text', function () {
|
||||
const feature = new Feature(new LineString(points3857));
|
||||
expect(format.writeFeature(feature, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
})).to.be(encodedFlatPoints);
|
||||
expect(
|
||||
format.writeFeature(feature, {
|
||||
featureProjection: 'EPSG:3857',
|
||||
})
|
||||
).to.be(encodedFlatPoints);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#writeFeature', function() {
|
||||
|
||||
it('returns the expected text', function() {
|
||||
describe('#writeFeature', function () {
|
||||
it('returns the expected text', function () {
|
||||
const features = [new Feature(new LineString(points))];
|
||||
expect(format.writeFeatures(features)).to.be(encodedFlatPoints);
|
||||
});
|
||||
|
||||
it('transforms and returns the expected text', function() {
|
||||
it('transforms and returns the expected text', function () {
|
||||
const features = [new Feature(new LineString(points3857))];
|
||||
expect(format.writeFeatures(features, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
})).to.be(encodedFlatPoints);
|
||||
expect(
|
||||
format.writeFeatures(features, {
|
||||
featureProjection: 'EPSG:3857',
|
||||
})
|
||||
).to.be(encodedFlatPoints);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#writeGeometry', function() {
|
||||
|
||||
it('returns the expected text', function() {
|
||||
describe('#writeGeometry', function () {
|
||||
it('returns the expected text', function () {
|
||||
const geometry = new LineString(points);
|
||||
expect(format.writeGeometry(geometry)).to.be(encodedFlatPoints);
|
||||
});
|
||||
|
||||
it('transforms and returns the expected text', function() {
|
||||
it('transforms and returns the expected text', function () {
|
||||
const geometry = new LineString(points3857);
|
||||
expect(format.writeGeometry(geometry, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
})).to.be(encodedFlatPoints);
|
||||
expect(
|
||||
format.writeGeometry(geometry, {
|
||||
featureProjection: 'EPSG:3857',
|
||||
})
|
||||
).to.be(encodedFlatPoints);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,30 +1,40 @@
|
||||
import Feature from '../../../../src/ol/Feature.js';
|
||||
import FeatureFormat from '../../../../src/ol/format/Feature.js';
|
||||
import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import Polygon from '../../../../src/ol/geom/Polygon.js';
|
||||
import FeatureFormat from '../../../../src/ol/format/Feature.js';
|
||||
import {transform} from '../../../../src/ol/proj.js';
|
||||
import TopoJSON from '../../../../src/ol/format/TopoJSON.js';
|
||||
import {transform} from '../../../../src/ol/proj.js';
|
||||
|
||||
const aruba = {
|
||||
type: 'Topology',
|
||||
transform: {
|
||||
scale: [0.036003600360036005, 0.017361589674592462],
|
||||
translate: [-180, -89.99892578124998]
|
||||
translate: [-180, -89.99892578124998],
|
||||
},
|
||||
objects: {
|
||||
aruba: {
|
||||
type: 'Polygon',
|
||||
properties: {
|
||||
prop0: 'value0'
|
||||
prop0: 'value0',
|
||||
},
|
||||
arcs: [[0]],
|
||||
id: 533
|
||||
}
|
||||
id: 533,
|
||||
},
|
||||
},
|
||||
arcs: [
|
||||
[[3058, 5901], [0, -2], [-2, 1], [-1, 3], [-2, 3], [0, 3], [1, 1], [1, -3],
|
||||
[2, -5], [1, -1]]
|
||||
]
|
||||
[
|
||||
[3058, 5901],
|
||||
[0, -2],
|
||||
[-2, 1],
|
||||
[-1, 3],
|
||||
[-2, 3],
|
||||
[0, 3],
|
||||
[1, 1],
|
||||
[1, -3],
|
||||
[2, -5],
|
||||
[1, -1],
|
||||
],
|
||||
],
|
||||
};
|
||||
|
||||
const zeroId = {
|
||||
@@ -33,28 +43,26 @@ const zeroId = {
|
||||
foobar: {
|
||||
type: 'Point',
|
||||
id: 0,
|
||||
coordinates: [0, 42]
|
||||
}
|
||||
}
|
||||
coordinates: [0, 42],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
describe('ol.format.TopoJSON', function() {
|
||||
|
||||
describe('ol.format.TopoJSON', function () {
|
||||
let format;
|
||||
before(function() {
|
||||
before(function () {
|
||||
format = new TopoJSON();
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates a new format', function() {
|
||||
describe('constructor', function () {
|
||||
it('creates a new format', function () {
|
||||
expect(format).to.be.a(FeatureFormat);
|
||||
expect(format).to.be.a(TopoJSON);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#readFeaturesFromTopology_()', function() {
|
||||
|
||||
it('creates an array of features from a topology', function() {
|
||||
describe('#readFeaturesFromTopology_()', function () {
|
||||
it('creates an array of features from a topology', function () {
|
||||
const features = format.readFeaturesFromObject(aruba);
|
||||
expect(features).to.have.length(1);
|
||||
|
||||
@@ -70,12 +78,14 @@ describe('ol.format.TopoJSON', function() {
|
||||
expect(feature.get('prop0')).to.be('value0');
|
||||
|
||||
expect(geometry.getExtent()).to.eql([
|
||||
-70.08100810081008, 12.417091709170947,
|
||||
-69.9009900990099, 12.608069195591469
|
||||
-70.08100810081008,
|
||||
12.417091709170947,
|
||||
-69.9009900990099,
|
||||
12.608069195591469,
|
||||
]);
|
||||
});
|
||||
|
||||
it('can read a feature with id equal to 0', function() {
|
||||
it('can read a feature with id equal to 0', function () {
|
||||
const features = format.readFeaturesFromObject(zeroId);
|
||||
expect(features).to.have.length(1);
|
||||
|
||||
@@ -83,13 +93,11 @@ describe('ol.format.TopoJSON', function() {
|
||||
expect(feature).to.be.a(Feature);
|
||||
expect(feature.getId()).to.be(0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#readFeatures()', function() {
|
||||
|
||||
it('parses simple.json', function(done) {
|
||||
afterLoadText('spec/ol/format/topojson/simple.json', function(text) {
|
||||
describe('#readFeatures()', function () {
|
||||
it('parses simple.json', function (done) {
|
||||
afterLoadText('spec/ol/format/topojson/simple.json', function (text) {
|
||||
const features = format.readFeatures(text);
|
||||
expect(features.length).to.be(3);
|
||||
|
||||
@@ -100,30 +108,47 @@ describe('ol.format.TopoJSON', function() {
|
||||
const line = features[1].getGeometry();
|
||||
expect(line.getType()).to.be('LineString');
|
||||
expect(line.getFlatCoordinates()).to.eql([
|
||||
102, 0, 103, 1, 104, 0, 105, 1
|
||||
102,
|
||||
0,
|
||||
103,
|
||||
1,
|
||||
104,
|
||||
0,
|
||||
105,
|
||||
1,
|
||||
]);
|
||||
|
||||
const polygon = features[2].getGeometry();
|
||||
expect(polygon.getType()).to.be('Polygon');
|
||||
expect(polygon.getFlatCoordinates()).to.eql([
|
||||
100, 0, 100, 1, 101, 1, 101, 0, 100, 0
|
||||
100,
|
||||
0,
|
||||
100,
|
||||
1,
|
||||
101,
|
||||
1,
|
||||
101,
|
||||
0,
|
||||
100,
|
||||
0,
|
||||
]);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('parses simple.json and transforms', function(done) {
|
||||
afterLoadText('spec/ol/format/topojson/simple.json', function(text) {
|
||||
it('parses simple.json and transforms', function (done) {
|
||||
afterLoadText('spec/ol/format/topojson/simple.json', function (text) {
|
||||
const features = format.readFeatures(text, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
featureProjection: 'EPSG:3857',
|
||||
});
|
||||
expect(features.length).to.be(3);
|
||||
|
||||
const point = features[0].getGeometry();
|
||||
expect(point.getType()).to.be('Point');
|
||||
expect(features[0].getGeometry().getCoordinates()).to.eql(
|
||||
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857')
|
||||
);
|
||||
|
||||
const line = features[1].getGeometry();
|
||||
expect(line.getType()).to.be('LineString');
|
||||
@@ -131,26 +156,27 @@ describe('ol.format.TopoJSON', function() {
|
||||
transform([102.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([103.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([104.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857')
|
||||
transform([105.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
]);
|
||||
|
||||
const polygon = features[2].getGeometry();
|
||||
expect(polygon.getType()).to.be('Polygon');
|
||||
expect(polygon.getCoordinates()).to.eql([[
|
||||
transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857')
|
||||
]]);
|
||||
expect(polygon.getCoordinates()).to.eql([
|
||||
[
|
||||
transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([100.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([101.0, 1.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([101.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
transform([100.0, 0.0], 'EPSG:4326', 'EPSG:3857'),
|
||||
],
|
||||
]);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('parses world-110m.json', function(done) {
|
||||
afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) {
|
||||
|
||||
it('parses world-110m.json', function (done) {
|
||||
afterLoadText('spec/ol/format/topojson/world-110m.json', function (text) {
|
||||
const features = format.readFeatures(text);
|
||||
expect(features.length).to.be(178);
|
||||
|
||||
@@ -158,26 +184,32 @@ describe('ol.format.TopoJSON', function() {
|
||||
expect(first).to.be.a(Feature);
|
||||
const firstGeom = first.getGeometry();
|
||||
expect(firstGeom).to.be.a(MultiPolygon);
|
||||
expect(firstGeom.getExtent()).to.eql(
|
||||
[-180, -85.60903777459777, 180, 83.64513000000002]);
|
||||
expect(firstGeom.getExtent()).to.eql([
|
||||
-180,
|
||||
-85.60903777459777,
|
||||
180,
|
||||
83.64513000000002,
|
||||
]);
|
||||
|
||||
const last = features[177];
|
||||
expect(last).to.be.a(Feature);
|
||||
const lastGeom = last.getGeometry();
|
||||
expect(lastGeom).to.be.a(Polygon);
|
||||
expect(lastGeom.getExtent()).to.eql([
|
||||
25.26325263252633, -22.271802279310577,
|
||||
32.848528485284874, -15.50833810039586
|
||||
25.26325263252633,
|
||||
-22.271802279310577,
|
||||
32.848528485284874,
|
||||
-15.50833810039586,
|
||||
]);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('sets the topology\'s child names as feature property', function(done) {
|
||||
afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) {
|
||||
it("sets the topology's child names as feature property", function (done) {
|
||||
afterLoadText('spec/ol/format/topojson/world-110m.json', function (text) {
|
||||
const format = new TopoJSON({
|
||||
layerName: 'layer'
|
||||
layerName: 'layer',
|
||||
});
|
||||
const features = format.readFeatures(text);
|
||||
expect(features[0].get('layer')).to.be('land');
|
||||
@@ -186,17 +218,15 @@ describe('ol.format.TopoJSON', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('only parses features from specified topology\'s children', function(done) {
|
||||
afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) {
|
||||
it("only parses features from specified topology's children", function (done) {
|
||||
afterLoadText('spec/ol/format/topojson/world-110m.json', function (text) {
|
||||
const format = new TopoJSON({
|
||||
layers: ['land']
|
||||
layers: ['land'],
|
||||
});
|
||||
const features = format.readFeatures(text);
|
||||
expect(features.length).to.be(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
+713
-656
File diff suppressed because it is too large
Load Diff
+529
-261
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,11 @@
|
||||
import WMSCapabilities from '../../../../src/ol/format/WMSCapabilities.js';
|
||||
|
||||
describe('ol.format.WMSCapabilities', function() {
|
||||
|
||||
describe('when parsing ogcsample.xml', function() {
|
||||
|
||||
describe('ol.format.WMSCapabilities', function () {
|
||||
describe('when parsing ogcsample.xml', function () {
|
||||
const parser = new WMSCapabilities();
|
||||
let capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wms/ogcsample.xml', function(xml) {
|
||||
before(function (done) {
|
||||
afterLoadText('spec/ol/format/wms/ogcsample.xml', function (xml) {
|
||||
try {
|
||||
capabilities = parser.read(xml);
|
||||
} catch (e) {
|
||||
@@ -17,11 +15,11 @@ describe('ol.format.WMSCapabilities', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('can read version', function() {
|
||||
it('can read version', function () {
|
||||
expect(capabilities.version).to.eql('1.3.0');
|
||||
});
|
||||
|
||||
it('can read Service section', function() {
|
||||
it('can read Service section', function () {
|
||||
// FIXME not all fields are tested
|
||||
const service = capabilities.Service;
|
||||
const contact = service.ContactInformation;
|
||||
@@ -39,17 +37,17 @@ describe('ol.format.WMSCapabilities', function() {
|
||||
expect(contact.ContactPosition).to.eql('Computer Scientist');
|
||||
expect(contact.ContactPersonPrimary).to.eql({
|
||||
ContactPerson: 'Jeff Smith',
|
||||
ContactOrganization: 'NASA'
|
||||
ContactOrganization: 'NASA',
|
||||
});
|
||||
});
|
||||
|
||||
it('can read Capability.Exception', function() {
|
||||
it('can read Capability.Exception', function () {
|
||||
const exception = capabilities.Capability.Exception;
|
||||
|
||||
expect(exception).to.eql(['XML', 'INIMAGE', 'BLANK']);
|
||||
});
|
||||
|
||||
it('can read Capability.Request.GetCapabilities', function() {
|
||||
it('can read Capability.Request.GetCapabilities', function () {
|
||||
const getCapabilities = capabilities.Capability.Request.GetCapabilities;
|
||||
|
||||
expect(getCapabilities.Format).to.eql(['text/xml']);
|
||||
@@ -59,17 +57,20 @@ describe('ol.format.WMSCapabilities', function() {
|
||||
expect(http.Post.OnlineResource).to.eql('http://hostname/path?');
|
||||
});
|
||||
|
||||
it('can read Capability.Request.GetFeatureInfo', function() {
|
||||
it('can read Capability.Request.GetFeatureInfo', function () {
|
||||
const getFeatureInfo = capabilities.Capability.Request.GetFeatureInfo;
|
||||
|
||||
expect(getFeatureInfo.Format).to.eql(
|
||||
['text/xml', 'text/plain', 'text/html']);
|
||||
expect(getFeatureInfo.Format).to.eql([
|
||||
'text/xml',
|
||||
'text/plain',
|
||||
'text/html',
|
||||
]);
|
||||
expect(getFeatureInfo.DCPType.length).to.eql(1);
|
||||
const http = getFeatureInfo.DCPType[0].HTTP;
|
||||
expect(http.Get.OnlineResource).to.eql('http://hostname/path?');
|
||||
});
|
||||
|
||||
it('can read Capability.Request.GetMap', function() {
|
||||
it('can read Capability.Request.GetMap', function () {
|
||||
const getMap = capabilities.Capability.Request.GetMap;
|
||||
|
||||
expect(getMap.Format).to.eql(['image/gif', 'image/png', 'image/jpeg']);
|
||||
@@ -78,69 +79,84 @@ describe('ol.format.WMSCapabilities', function() {
|
||||
expect(http.Get.OnlineResource).to.eql('http://hostname/path?');
|
||||
});
|
||||
|
||||
it('can read Capability.Layer', function() {
|
||||
it('can read Capability.Layer', function () {
|
||||
const layer = capabilities.Capability.Layer;
|
||||
|
||||
expect(layer.Title).to.eql('Acme Corp. Map Server');
|
||||
expect(layer.Name).to.be(undefined);
|
||||
expect(layer.CRS).to.eql(['CRS:84']);
|
||||
expect(layer.AuthorityURL).to.eql([{
|
||||
name: 'DIF_ID',
|
||||
OnlineResource: 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html'
|
||||
}]);
|
||||
expect(layer.BoundingBox).to.eql([{
|
||||
crs: 'CRS:84',
|
||||
extent: [-1, -1, 1, 1],
|
||||
res: [0, 0]
|
||||
}]);
|
||||
expect(layer.AuthorityURL).to.eql([
|
||||
{
|
||||
name: 'DIF_ID',
|
||||
OnlineResource: 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html',
|
||||
},
|
||||
]);
|
||||
expect(layer.BoundingBox).to.eql([
|
||||
{
|
||||
crs: 'CRS:84',
|
||||
extent: [-1, -1, 1, 1],
|
||||
res: [0, 0],
|
||||
},
|
||||
]);
|
||||
|
||||
expect(layer.Layer.length).to.eql(4);
|
||||
expect(layer.Layer[0].Name).to.eql('ROADS_RIVERS');
|
||||
expect(layer.Layer[0].Title).to.eql('Roads and Rivers');
|
||||
expect(layer.Layer[0].CRS).to.eql(['EPSG:26986', 'CRS:84']);
|
||||
expect(layer.Layer[0].Identifier).to.eql(['123456']);
|
||||
expect(layer.Layer[0].BoundingBox).to.eql([{
|
||||
crs: 'CRS:84',
|
||||
extent: [-71.63, 41.75, -70.78, 42.9],
|
||||
res: [0.01, 0.01]
|
||||
}, {
|
||||
crs: 'EPSG:26986',
|
||||
extent: [189000, 834000, 285000, 962000],
|
||||
res: [1, 1]
|
||||
}]);
|
||||
expect(layer.Layer[0].EX_GeographicBoundingBox).to.eql(
|
||||
[-71.63, 41.75, -70.78, 42.9]);
|
||||
expect(layer.Layer[0].Style).to.eql([{
|
||||
Name: 'USGS',
|
||||
Title: 'USGS Topo Map Style',
|
||||
Abstract: 'Features are shown in a style like that used in USGS ' +
|
||||
'topographic maps.',
|
||||
StyleSheetURL: {
|
||||
Format: 'text/xsl',
|
||||
OnlineResource: 'http://www.university.edu/stylesheets/usgs.xsl'
|
||||
expect(layer.Layer[0].BoundingBox).to.eql([
|
||||
{
|
||||
crs: 'CRS:84',
|
||||
extent: [-71.63, 41.75, -70.78, 42.9],
|
||||
res: [0.01, 0.01],
|
||||
},
|
||||
LegendURL: [{
|
||||
Format: 'image/gif',
|
||||
OnlineResource: 'http://www.university.edu/legends/usgs.gif',
|
||||
size: [72, 72]
|
||||
}]
|
||||
}]);
|
||||
expect(layer.Layer[0].FeatureListURL).to.eql([{
|
||||
Format: 'XML',
|
||||
OnlineResource: 'http://www.university.edu/data/roads_rivers.gml'
|
||||
}]);
|
||||
{
|
||||
crs: 'EPSG:26986',
|
||||
extent: [189000, 834000, 285000, 962000],
|
||||
res: [1, 1],
|
||||
},
|
||||
]);
|
||||
expect(layer.Layer[0].EX_GeographicBoundingBox).to.eql([
|
||||
-71.63,
|
||||
41.75,
|
||||
-70.78,
|
||||
42.9,
|
||||
]);
|
||||
expect(layer.Layer[0].Style).to.eql([
|
||||
{
|
||||
Name: 'USGS',
|
||||
Title: 'USGS Topo Map Style',
|
||||
Abstract:
|
||||
'Features are shown in a style like that used in USGS ' +
|
||||
'topographic maps.',
|
||||
StyleSheetURL: {
|
||||
Format: 'text/xsl',
|
||||
OnlineResource: 'http://www.university.edu/stylesheets/usgs.xsl',
|
||||
},
|
||||
LegendURL: [
|
||||
{
|
||||
Format: 'image/gif',
|
||||
OnlineResource: 'http://www.university.edu/legends/usgs.gif',
|
||||
size: [72, 72],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
expect(layer.Layer[0].FeatureListURL).to.eql([
|
||||
{
|
||||
Format: 'XML',
|
||||
OnlineResource: 'http://www.university.edu/data/roads_rivers.gml',
|
||||
},
|
||||
]);
|
||||
expect(layer.Layer[0].Attribution).to.eql({
|
||||
Title: 'State College University',
|
||||
OnlineResource: 'http://www.university.edu/',
|
||||
LogoURL: {
|
||||
Format: 'image/gif',
|
||||
OnlineResource: 'http://www.university.edu/icons/logo.gif',
|
||||
size: [100, 100]
|
||||
}
|
||||
size: [100, 100],
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,35 +2,29 @@ import WMSGetFeatureInfo from '../../../../src/ol/format/WMSGetFeatureInfo.js';
|
||||
import {addCommon, clearAllProjections} from '../../../../src/ol/proj.js';
|
||||
import {register} from '../../../../src/ol/proj/proj4.js';
|
||||
|
||||
|
||||
describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
|
||||
describe('#getLayers', function() {
|
||||
|
||||
it('returns null if layers is undefined', function() {
|
||||
describe('ol.format.WMSGetFeatureInfo', function () {
|
||||
describe('#getLayers', function () {
|
||||
it('returns null if layers is undefined', function () {
|
||||
const format = new WMSGetFeatureInfo();
|
||||
expect(format.getLayers()).to.be(null);
|
||||
});
|
||||
|
||||
it('returns the value provided in the layers option', function() {
|
||||
it('returns the value provided in the layers option', function () {
|
||||
const format = new WMSGetFeatureInfo({
|
||||
layers: ['a', 'z']
|
||||
layers: ['a', 'z'],
|
||||
});
|
||||
expect(format.getLayers()).to.eql(['a', 'z']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#readFormat', function() {
|
||||
|
||||
describe('read Features', function() {
|
||||
|
||||
describe('#readFormat', function () {
|
||||
describe('read Features', function () {
|
||||
let features;
|
||||
|
||||
before(function(done) {
|
||||
before(function (done) {
|
||||
proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326'));
|
||||
register(proj4);
|
||||
afterLoadText('spec/ol/format/wms/getfeatureinfo.xml', function(data) {
|
||||
afterLoadText('spec/ol/format/wms/getfeatureinfo.xml', function (data) {
|
||||
try {
|
||||
features = new WMSGetFeatureInfo().readFeatures(data);
|
||||
} catch (e) {
|
||||
@@ -40,64 +34,69 @@ describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
});
|
||||
});
|
||||
|
||||
after(function() {
|
||||
after(function () {
|
||||
delete proj4.defs['urn:x-ogc:def:crs:EPSG:4326'];
|
||||
clearAllProjections();
|
||||
addCommon();
|
||||
});
|
||||
|
||||
it('creates 3 features', function() {
|
||||
it('creates 3 features', function () {
|
||||
expect(features).to.have.length(3);
|
||||
});
|
||||
|
||||
it('creates a feature for 1071', function() {
|
||||
it('creates a feature for 1071', function () {
|
||||
const feature = features[0];
|
||||
expect(feature.getId()).to.be(undefined);
|
||||
expect(feature.get('FID')).to.equal('1071');
|
||||
expect(feature.get('NO_CAMPAGNE')).to.equal('1020050');
|
||||
});
|
||||
|
||||
it('read boundedBy but no geometry', function() {
|
||||
it('read boundedBy but no geometry', function () {
|
||||
const feature = features[0];
|
||||
expect(feature.getGeometry()).to.be(undefined);
|
||||
expect(feature.get('boundedBy')).to.eql(
|
||||
[-531138.686422, 5386348.414671, -117252.819653, 6144475.186022]);
|
||||
expect(feature.get('boundedBy')).to.eql([
|
||||
-531138.686422,
|
||||
5386348.414671,
|
||||
-117252.819653,
|
||||
6144475.186022,
|
||||
]);
|
||||
});
|
||||
|
||||
it('read empty response', function() {
|
||||
it('read empty response', function () {
|
||||
// read empty response
|
||||
const text = '<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
' <AAA64_layer>' +
|
||||
' </AAA64_layer>' +
|
||||
'</msGMLOutput>';
|
||||
const text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
' <AAA64_layer>' +
|
||||
' </AAA64_layer>' +
|
||||
'</msGMLOutput>';
|
||||
const features = new WMSGetFeatureInfo().readFeatures(text);
|
||||
expect(features.length).to.be(0);
|
||||
});
|
||||
|
||||
it('read empty attributes', function() {
|
||||
it('read empty attributes', function () {
|
||||
const text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>' +
|
||||
' 107397.266000,460681.063000 116568.188000,480609.250000' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <FOO>bar</FOO>' +
|
||||
' <EMPTY></EMPTY>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
'</msGMLOutput>';
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>' +
|
||||
' 107397.266000,460681.063000 116568.188000,480609.250000' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <FOO>bar</FOO>' +
|
||||
' <EMPTY></EMPTY>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
'</msGMLOutput>';
|
||||
const features = new WMSGetFeatureInfo().readFeatures(text);
|
||||
expect(features.length).to.be(1);
|
||||
expect(features[0].get('FOO')).to.be('bar');
|
||||
@@ -105,59 +104,59 @@ describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
expect(features[0].get('EMPTY')).to.be(undefined);
|
||||
});
|
||||
|
||||
it('read features from multiple layers', function() {
|
||||
it('read features from multiple layers', function () {
|
||||
const text =
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>' +
|
||||
' 129799.109000,467950.250000 133199.906000,468904.063000' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>287</OBJECTID>' +
|
||||
' <ROUTE>N403</ROUTE>' +
|
||||
' <ROUTE_CH>#N403</ROUTE_CH>' +
|
||||
' <COUNT>1</COUNT>' +
|
||||
' <BEHEERDER>P</BEHEERDER>' +
|
||||
' <LENGTH>4091.25</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
' <AAA62_layer>' +
|
||||
' <AAA62_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>' +
|
||||
' 129936.000000,468362.000000 131686.000000,473119.000000' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>1251</OBJECTID>' +
|
||||
' <VWK_ID>1515</VWK_ID>' +
|
||||
' <VWK_BEGDTM>00:00:00 01/01/1998</VWK_BEGDTM>' +
|
||||
' <VWJ_ID_BEG>1472</VWJ_ID_BEG>' +
|
||||
' <VWJ_ID_END>1309</VWJ_ID_END>' +
|
||||
' <VAKTYPE>D</VAKTYPE>' +
|
||||
' <VRT_CODE>227</VRT_CODE>' +
|
||||
' <VRT_NAAM>Vecht</VRT_NAAM>' +
|
||||
' <VWG_NR>2</VWG_NR>' +
|
||||
' <VWG_NAAM>Vecht</VWG_NAAM>' +
|
||||
' <BEGKM>18.25</BEGKM>' +
|
||||
' <ENDKM>23.995</ENDKM>' +
|
||||
' <LENGTH>5745.09</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA62_feature>' +
|
||||
' </AAA62_layer>' +
|
||||
'</msGMLOutput>';
|
||||
'<?xml version="1.0" encoding="ISO-8859-1"?>' +
|
||||
'<msGMLOutput ' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xlink="http://www.w3.org/1999/xlink"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
|
||||
' <AAA64_layer>' +
|
||||
' <AAA64_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>' +
|
||||
' 129799.109000,467950.250000 133199.906000,468904.063000' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>287</OBJECTID>' +
|
||||
' <ROUTE>N403</ROUTE>' +
|
||||
' <ROUTE_CH>#N403</ROUTE_CH>' +
|
||||
' <COUNT>1</COUNT>' +
|
||||
' <BEHEERDER>P</BEHEERDER>' +
|
||||
' <LENGTH>4091.25</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA64_feature>' +
|
||||
' </AAA64_layer>' +
|
||||
' <AAA62_layer>' +
|
||||
' <AAA62_feature>' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box srsName="EPSG:4326">' +
|
||||
' <gml:coordinates>' +
|
||||
' 129936.000000,468362.000000 131686.000000,473119.000000' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <OBJECTID>1251</OBJECTID>' +
|
||||
' <VWK_ID>1515</VWK_ID>' +
|
||||
' <VWK_BEGDTM>00:00:00 01/01/1998</VWK_BEGDTM>' +
|
||||
' <VWJ_ID_BEG>1472</VWJ_ID_BEG>' +
|
||||
' <VWJ_ID_END>1309</VWJ_ID_END>' +
|
||||
' <VAKTYPE>D</VAKTYPE>' +
|
||||
' <VRT_CODE>227</VRT_CODE>' +
|
||||
' <VRT_NAAM>Vecht</VRT_NAAM>' +
|
||||
' <VWG_NR>2</VWG_NR>' +
|
||||
' <VWG_NAAM>Vecht</VWG_NAAM>' +
|
||||
' <BEGKM>18.25</BEGKM>' +
|
||||
' <ENDKM>23.995</ENDKM>' +
|
||||
' <LENGTH>5745.09</LENGTH>' +
|
||||
' <SHAPE><shape></SHAPE>' +
|
||||
' <SE_ANNO_CAD_DATA><null></SE_ANNO_CAD_DATA>' +
|
||||
' </AAA62_feature>' +
|
||||
' </AAA62_layer>' +
|
||||
'</msGMLOutput>';
|
||||
const format = new WMSGetFeatureInfo();
|
||||
const features = format.readFeatures(text);
|
||||
expect(features.length).to.be(2);
|
||||
@@ -174,62 +173,61 @@ describe('ol.format.WMSGetFeatureInfo', function() {
|
||||
expect(dummyFeatures.length).to.be(0);
|
||||
});
|
||||
|
||||
it('read geoserver’s response', function() {
|
||||
it('read geoserver’s response', function () {
|
||||
const text =
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<wfs:FeatureCollection xmlns="http://www.opengis.net/wfs"' +
|
||||
' xmlns:wfs="http://www.opengis.net/wfs"' +
|
||||
' xmlns:opengeo="http://opengeo.org"' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
|
||||
' xsi:schemaLocation="http://opengeo.org ' +
|
||||
' http://demo.opengeo.org:80/geoserver/wfs?service=WFS&' +
|
||||
'version=1.0.0&request=DescribeFeatureType&' +
|
||||
'typeName=opengeo:roads http://www.opengis.net/wfs ' +
|
||||
' http://demo.opengeo.org:80/geoserver/schemas/wfs/1.0.0/' +
|
||||
'WFS-basic.xsd">' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box' +
|
||||
' srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">' +
|
||||
' <gml:coordinates xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' decimal="." cs="," ts=" ">' +
|
||||
'591943.9375,4925605 593045.625,4925845' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <gml:featureMember>' +
|
||||
' <opengeo:roads fid="roads.90">' +
|
||||
' <opengeo:cat>3</opengeo:cat>' +
|
||||
' <opengeo:label>secondary highway, hard surface' +
|
||||
' </opengeo:label>' +
|
||||
' <opengeo:the_geom>' +
|
||||
' <gml:MultiLineString' +
|
||||
' srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">' +
|
||||
' <gml:lineStringMember>' +
|
||||
' <gml:LineString>' +
|
||||
' <gml:coordinates xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' decimal="." cs="," ts=" ">' +
|
||||
'593045.60746465,4925605.0059156 593024.32382915,4925606.79305411' +
|
||||
' 592907.54863574,4925624.85647524 592687.35111096,' +
|
||||
'4925670.76834012 592430.76279218,4925678.79393165' +
|
||||
' 592285.97636109,4925715.70811767 592173.39165655,' +
|
||||
'4925761.83511156 592071.1753393,4925793.95523514' +
|
||||
' 591985.96972625,4925831.59842486' +
|
||||
' 591943.98769455,4925844.93220071' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:LineString>' +
|
||||
' </gml:lineStringMember>' +
|
||||
' </gml:MultiLineString>' +
|
||||
' </opengeo:the_geom>' +
|
||||
' </opengeo:roads>' +
|
||||
' </gml:featureMember>' +
|
||||
'</wfs:FeatureCollection>';
|
||||
'<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<wfs:FeatureCollection xmlns="http://www.opengis.net/wfs"' +
|
||||
' xmlns:wfs="http://www.opengis.net/wfs"' +
|
||||
' xmlns:opengeo="http://opengeo.org"' +
|
||||
' xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
|
||||
' xsi:schemaLocation="http://opengeo.org ' +
|
||||
' http://demo.opengeo.org:80/geoserver/wfs?service=WFS&' +
|
||||
'version=1.0.0&request=DescribeFeatureType&' +
|
||||
'typeName=opengeo:roads http://www.opengis.net/wfs ' +
|
||||
' http://demo.opengeo.org:80/geoserver/schemas/wfs/1.0.0/' +
|
||||
'WFS-basic.xsd">' +
|
||||
' <gml:boundedBy>' +
|
||||
' <gml:Box' +
|
||||
' srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">' +
|
||||
' <gml:coordinates xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' decimal="." cs="," ts=" ">' +
|
||||
'591943.9375,4925605 593045.625,4925845' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:Box>' +
|
||||
' </gml:boundedBy>' +
|
||||
' <gml:featureMember>' +
|
||||
' <opengeo:roads fid="roads.90">' +
|
||||
' <opengeo:cat>3</opengeo:cat>' +
|
||||
' <opengeo:label>secondary highway, hard surface' +
|
||||
' </opengeo:label>' +
|
||||
' <opengeo:the_geom>' +
|
||||
' <gml:MultiLineString' +
|
||||
' srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">' +
|
||||
' <gml:lineStringMember>' +
|
||||
' <gml:LineString>' +
|
||||
' <gml:coordinates xmlns:gml="http://www.opengis.net/gml"' +
|
||||
' decimal="." cs="," ts=" ">' +
|
||||
'593045.60746465,4925605.0059156 593024.32382915,4925606.79305411' +
|
||||
' 592907.54863574,4925624.85647524 592687.35111096,' +
|
||||
'4925670.76834012 592430.76279218,4925678.79393165' +
|
||||
' 592285.97636109,4925715.70811767 592173.39165655,' +
|
||||
'4925761.83511156 592071.1753393,4925793.95523514' +
|
||||
' 591985.96972625,4925831.59842486' +
|
||||
' 591943.98769455,4925844.93220071' +
|
||||
' </gml:coordinates>' +
|
||||
' </gml:LineString>' +
|
||||
' </gml:lineStringMember>' +
|
||||
' </gml:MultiLineString>' +
|
||||
' </opengeo:the_geom>' +
|
||||
' </opengeo:roads>' +
|
||||
' </gml:featureMember>' +
|
||||
'</wfs:FeatureCollection>';
|
||||
const features = new WMSGetFeatureInfo().readFeatures(text);
|
||||
expect(features.length).to.be(1);
|
||||
expect(features[0].get('cat')).to.be('3');
|
||||
expect(features[0].getGeometry().getType()).to.be('MultiLineString');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import WMTSCapabilities from '../../../../src/ol/format/WMTSCapabilities.js';
|
||||
|
||||
|
||||
describe('ol.format.WMTSCapabilities', function() {
|
||||
|
||||
describe('when parsing ogcsample.xml', function() {
|
||||
|
||||
describe('ol.format.WMTSCapabilities', function () {
|
||||
describe('when parsing ogcsample.xml', function () {
|
||||
const parser = new WMTSCapabilities();
|
||||
let capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function(xml) {
|
||||
before(function (done) {
|
||||
afterLoadText('spec/ol/format/wmts/ogcsample.xml', function (xml) {
|
||||
try {
|
||||
capabilities = parser.read(xml);
|
||||
} catch (e) {
|
||||
@@ -18,15 +15,14 @@ describe('ol.format.WMTSCapabilities', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('can read Capability.Contents.Layer', function() {
|
||||
|
||||
it('can read Capability.Contents.Layer', function () {
|
||||
expect(capabilities.Contents.Layer).to.be.an('array');
|
||||
expect(capabilities.Contents.Layer).to.have.length(1);
|
||||
|
||||
|
||||
const layer = capabilities.Contents.Layer[0];
|
||||
expect(layer.Abstract).to.be
|
||||
.eql('Blue Marble Next Generation NASA Product');
|
||||
expect(layer.Abstract).to.be.eql(
|
||||
'Blue Marble Next Generation NASA Product'
|
||||
);
|
||||
expect(layer.Identifier).to.be.eql('BlueMarbleNextGeneration');
|
||||
expect(layer.Title).to.be.eql('Blue Marble Next Generation');
|
||||
|
||||
@@ -48,19 +44,20 @@ describe('ol.format.WMTSCapabilities', function() {
|
||||
expect(layer.Style[0].Identifier).to.be.eql('DarkBlue');
|
||||
expect(layer.Style[0].isDefault).to.be(true);
|
||||
expect(layer.Style[0].Title).to.be.eql('Dark Blue');
|
||||
expect(layer.Style[0].LegendURL[0].href).to.be
|
||||
.eql('http://www.miramon.uab.es/wmts/Coastlines/' +
|
||||
'coastlines_darkBlue.png');
|
||||
expect(layer.Style[0].LegendURL[0].href).to.be.eql(
|
||||
'http://www.miramon.uab.es/wmts/Coastlines/' + 'coastlines_darkBlue.png'
|
||||
);
|
||||
expect(layer.Style[0].LegendURL[0].format).to.be.eql('image/png');
|
||||
|
||||
expect(layer.TileMatrixSetLink).to.be.an('array');
|
||||
expect(layer.TileMatrixSetLink).to.have.length(3);
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSet).to.be
|
||||
.eql('BigWorldPixel');
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSet).to.be
|
||||
.eql('google3857');
|
||||
expect(layer.TileMatrixSetLink[2].TileMatrixSet).to.be
|
||||
.eql('google3857subset');
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSet).to.be.eql(
|
||||
'BigWorldPixel'
|
||||
);
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSet).to.be.eql('google3857');
|
||||
expect(layer.TileMatrixSetLink[2].TileMatrixSet).to.be.eql(
|
||||
'google3857subset'
|
||||
);
|
||||
|
||||
const wgs84Bbox = layer.WGS84BoundingBox;
|
||||
expect(wgs84Bbox).to.be.an('array');
|
||||
@@ -72,13 +69,13 @@ describe('ol.format.WMTSCapabilities', function() {
|
||||
expect(layer.ResourceURL).to.be.an('array');
|
||||
expect(layer.ResourceURL).to.have.length(2);
|
||||
expect(layer.ResourceURL[0].format).to.be.eql('image/png');
|
||||
expect(layer.ResourceURL[0].template).to.be
|
||||
.eql('http://www.example.com/wmts/coastlines/{TileMatrix}' +
|
||||
'/{TileRow}/{TileCol}.png');
|
||||
|
||||
expect(layer.ResourceURL[0].template).to.be.eql(
|
||||
'http://www.example.com/wmts/coastlines/{TileMatrix}' +
|
||||
'/{TileRow}/{TileCol}.png'
|
||||
);
|
||||
});
|
||||
|
||||
it('Can read Capabilities.Content.TileMatrixSet', function() {
|
||||
it('Can read Capabilities.Content.TileMatrixSet', function () {
|
||||
expect(capabilities.Contents.TileMatrixSet).to.be.ok();
|
||||
|
||||
const bigWorld = capabilities.Contents.TileMatrixSet[2];
|
||||
@@ -104,24 +101,19 @@ describe('ol.format.WMTSCapabilities', function() {
|
||||
expect(bigWorld.TileMatrix[1].TopLeftCorner).to.be.a('array');
|
||||
expect(bigWorld.TileMatrix[1].TopLeftCorner[0]).to.be.eql(-180);
|
||||
expect(bigWorld.TileMatrix[1].TopLeftCorner[1]).to.be.eql(84);
|
||||
|
||||
|
||||
});
|
||||
|
||||
it('Can read OWS tags', function() {
|
||||
it('Can read OWS tags', function () {
|
||||
expect(capabilities.ServiceIdentification).to.be.ok();
|
||||
expect(capabilities.OperationsMetadata).to.be.ok();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when parsing ign.xml', function() {
|
||||
|
||||
describe('when parsing ign.xml', function () {
|
||||
const parser = new WMTSCapabilities();
|
||||
let capabilities;
|
||||
before(function(done) {
|
||||
afterLoadText('spec/ol/format/wmts/ign.xml', function(xml) {
|
||||
before(function (done) {
|
||||
afterLoadText('spec/ol/format/wmts/ign.xml', function (xml) {
|
||||
try {
|
||||
capabilities = parser.read(xml);
|
||||
} catch (e) {
|
||||
@@ -131,35 +123,53 @@ describe('ol.format.WMTSCapabilities', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('can read Capability.Contents.Layer', function() {
|
||||
it('can read Capability.Contents.Layer', function () {
|
||||
expect(capabilities.Contents.Layer).to.be.an('array');
|
||||
expect(capabilities.Contents.Layer).to.have.length(1);
|
||||
|
||||
|
||||
const layer = capabilities.Contents.Layer[0];
|
||||
expect(layer.TileMatrixSetLink).to.be.an('array');
|
||||
expect(layer.TileMatrixSetLink).to.have.length(2);
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSet).to.be.eql('PM');
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits).to.be.an('array');
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits).to.have.length(20);
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].TileMatrix).to.be.eql('0');
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileRow).to.be.eql(0);
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileRow).to.be.eql(1);
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileCol).to.be.eql(0);
|
||||
expect(layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileCol).to.be.eql(1);
|
||||
expect(
|
||||
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].TileMatrix
|
||||
).to.be.eql('0');
|
||||
expect(
|
||||
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileRow
|
||||
).to.be.eql(0);
|
||||
expect(
|
||||
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileRow
|
||||
).to.be.eql(1);
|
||||
expect(
|
||||
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MinTileCol
|
||||
).to.be.eql(0);
|
||||
expect(
|
||||
layer.TileMatrixSetLink[0].TileMatrixSetLimits[0].MaxTileCol
|
||||
).to.be.eql(1);
|
||||
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSet).to.be.eql('Prefixed');
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits).to.be.an('array');
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits).to.have.length(2);
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].TileMatrix).to.be.eql('Prefixed:0');
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MinTileRow).to.be.eql(0);
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MaxTileRow).to.be.eql(1);
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MinTileCol).to.be.eql(0);
|
||||
expect(layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MaxTileCol).to.be.eql(1);
|
||||
|
||||
expect(
|
||||
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].TileMatrix
|
||||
).to.be.eql('Prefixed:0');
|
||||
expect(
|
||||
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MinTileRow
|
||||
).to.be.eql(0);
|
||||
expect(
|
||||
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MaxTileRow
|
||||
).to.be.eql(1);
|
||||
expect(
|
||||
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MinTileCol
|
||||
).to.be.eql(0);
|
||||
expect(
|
||||
layer.TileMatrixSetLink[1].TileMatrixSetLimits[0].MaxTileCol
|
||||
).to.be.eql(1);
|
||||
});
|
||||
|
||||
it('Can read Capabilities.Content.TileMatrixSet', function() {
|
||||
it('Can read Capabilities.Content.TileMatrixSet', function () {
|
||||
expect(capabilities.Contents.TileMatrixSet).to.be.ok();
|
||||
|
||||
const pm = capabilities.Contents.TileMatrixSet[0];
|
||||
@@ -170,8 +180,9 @@ describe('ol.format.WMTSCapabilities', function() {
|
||||
expect(pm.TileMatrix[0].Identifier).to.be.eql('0');
|
||||
expect(pm.TileMatrix[0].MatrixHeight).to.be.eql(1);
|
||||
expect(pm.TileMatrix[0].MatrixWidth).to.be.eql(1);
|
||||
expect(pm.TileMatrix[0].ScaleDenominator)
|
||||
.to.be.eql(559082264.0287178958533332);
|
||||
expect(pm.TileMatrix[0].ScaleDenominator).to.be.eql(
|
||||
559082264.0287178958533332
|
||||
);
|
||||
expect(pm.TileMatrix[0].TileWidth).to.be.eql(256);
|
||||
expect(pm.TileMatrix[0].TileHeight).to.be.eql(256);
|
||||
expect(pm.TileMatrix[0].TopLeftCorner).to.be.a('array');
|
||||
@@ -180,16 +191,14 @@ describe('ol.format.WMTSCapabilities', function() {
|
||||
expect(pm.TileMatrix[1].Identifier).to.be.eql('1');
|
||||
expect(pm.TileMatrix[1].MatrixHeight).to.be.eql(2);
|
||||
expect(pm.TileMatrix[1].MatrixWidth).to.be.eql(2);
|
||||
expect(pm.TileMatrix[1].ScaleDenominator)
|
||||
.to.be.eql(279541132.0143588959472254);
|
||||
expect(pm.TileMatrix[1].ScaleDenominator).to.be.eql(
|
||||
279541132.0143588959472254
|
||||
);
|
||||
expect(pm.TileMatrix[1].TileWidth).to.be.eql(256);
|
||||
expect(pm.TileMatrix[1].TileHeight).to.be.eql(256);
|
||||
expect(pm.TileMatrix[1].TopLeftCorner).to.be.a('array');
|
||||
expect(pm.TileMatrix[1].TopLeftCorner[0]).to.be.eql(-20037508);
|
||||
expect(pm.TileMatrix[1].TopLeftCorner[1]).to.be.eql(20037508);
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import {readDateTime} from '../../../../src/ol/format/xsd.js';
|
||||
|
||||
describe('ol/format/xsd', function() {
|
||||
|
||||
describe('readDateTime', function() {
|
||||
it('can handle non-Zulu time zones', function() {
|
||||
describe('ol/format/xsd', function () {
|
||||
describe('readDateTime', function () {
|
||||
it('can handle non-Zulu time zones', function () {
|
||||
const node = document.createElement('time');
|
||||
node.textContent = '2016-07-12T15:00:00+03:00';
|
||||
expect(new Date(readDateTime(node) * 1000).toISOString()).to.eql('2016-07-12T12:00:00.000Z');
|
||||
expect(new Date(readDateTime(node) * 1000).toISOString()).to.eql(
|
||||
'2016-07-12T12:00:00.000Z'
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user