This commit is contained in:
Amir Ashkan Baghdoust
2021-03-14 22:24:54 +01:00
11 changed files with 1023 additions and 951 deletions

1512
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -59,11 +59,11 @@
"buble": "^0.20.0",
"buble-loader": "^0.5.1",
"chaikin-smooth": "^1.0.4",
"clean-css-cli": "5.2.0",
"clean-css-cli": "5.2.1",
"copy-webpack-plugin": "^6.0.1",
"coveralls": "3.1.0",
"eslint": "^7.2.0",
"eslint-config-openlayers": "^14.0.0",
"eslint-config-openlayers": "^15.0.0",
"expect.js": "0.3.1",
"express": "^4.17.1",
"front-matter": "^4.0.0",
@@ -73,7 +73,7 @@
"handlebars": "4.7.7",
"istanbul": "0.4.5",
"istanbul-instrumenter-loader": "^3.0.1",
"jquery": "3.5.1",
"jquery": "3.6.0",
"jsdoc": "3.6.6",
"jsdoc-plugin-typescript": "^2.0.5",
"json-stringify-safe": "^5.0.1",
@@ -86,10 +86,10 @@
"karma-webpack": "^4.0.0-rc.2",
"loglevelnext": "^4.0.1",
"marked": "2.0.1",
"mocha": "8.3.0",
"mocha": "8.3.1",
"pixelmatch": "^5.1.0",
"pngjs": "^6.0.0",
"proj4": "2.7.0",
"proj4": "2.7.2",
"puppeteer": "8.0.0",
"rollup": "^2.1.0",
"rollup-plugin-babel": "^4.3.3",
@@ -116,13 +116,6 @@
"@openlayers"
],
"rules": {
"valid-jsdoc": "off",
"@openlayers/valid-tsdoc": [
"error",
{
"requireReturn": false
}
],
"@openlayers/no-exclusive-tests": [
"error",
{

View File

@@ -12,10 +12,10 @@ import {listen, unlistenByKey} from './events.js';
/**
* @typedef {Object} PointerEventData
* @property {string} type
* @property {number} clientX
* @property {number} clientY
* @property {EventTarget} target
* @property {string} type The type of the pointer event.
* @property {number} clientX ClientX.
* @property {number} clientY ClientY.
* @property {EventTarget} target The target of the event.
*/
class MapBrowserEventHandler extends Target {

View File

@@ -1473,19 +1473,20 @@ class Modify extends PointerInteraction {
* @private
*/
updateSegmentIndices_(geometry, index, depth, delta) {
this.rBush_.forEachInExtent(geometry.getExtent(), function (
segmentDataMatch
) {
if (
segmentDataMatch.geometry === geometry &&
(depth === undefined ||
segmentDataMatch.depth === undefined ||
equals(segmentDataMatch.depth, depth)) &&
segmentDataMatch.index > index
) {
segmentDataMatch.index += delta;
this.rBush_.forEachInExtent(
geometry.getExtent(),
function (segmentDataMatch) {
if (
segmentDataMatch.geometry === geometry &&
(depth === undefined ||
segmentDataMatch.depth === undefined ||
equals(segmentDataMatch.depth, depth)) &&
segmentDataMatch.index > index
) {
segmentDataMatch.index += delta;
}
}
});
);
}
}

View File

@@ -362,7 +362,7 @@ class TileGrid {
/**
* @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @param {number} z Integer zoom level.
* @param {import("../TileRange.js").default=} opt_tileRange Temporary import("../TileRange.js").default object.
* @param {import("../TileRange.js").default} [opt_tileRange] Temporary import("../TileRange.js").default object.
* @return {import("../TileRange.js").default} Tile range.
*/
getTileRangeForTileCoordAndZ(tileCoord, z, opt_tileRange) {

View File

@@ -342,43 +342,44 @@ describe('ol.format.GeoJSON', function () {
});
it('parses countries.geojson', function (done) {
afterLoadText('spec/ol/format/geojson/countries.geojson', function (
text
) {
const result = format.readFeatures(text);
expect(result.length).to.be(179);
afterLoadText(
'spec/ol/format/geojson/countries.geojson',
function (text) {
const result = format.readFeatures(text);
expect(result.length).to.be(179);
const first = result[0];
expect(first).to.be.a(Feature);
expect(first.get('name')).to.be('Afghanistan');
expect(first.getId()).to.be('AFG');
const firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(Polygon);
expect(
equals(firstGeom.getExtent(), [
60.52843,
29.318572,
75.158028,
38.486282,
])
).to.be(true);
const first = result[0];
expect(first).to.be.a(Feature);
expect(first.get('name')).to.be('Afghanistan');
expect(first.getId()).to.be('AFG');
const firstGeom = first.getGeometry();
expect(firstGeom).to.be.a(Polygon);
expect(
equals(firstGeom.getExtent(), [
60.52843,
29.318572,
75.158028,
38.486282,
])
).to.be(true);
const last = result[178];
expect(last).to.be.a(Feature);
expect(last.get('name')).to.be('Zimbabwe');
expect(last.getId()).to.be('ZWE');
const lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(Polygon);
expect(
equals(lastGeom.getExtent(), [
25.264226,
-22.271612,
32.849861,
-15.507787,
])
).to.be(true);
done();
});
const last = result[178];
expect(last).to.be.a(Feature);
expect(last.get('name')).to.be('Zimbabwe');
expect(last.getId()).to.be('ZWE');
const lastGeom = last.getGeometry();
expect(lastGeom).to.be.a(Polygon);
expect(
equals(lastGeom.getExtent(), [
25.264226,
-22.271612,
32.849861,
-15.507787,
])
).to.be(true);
done();
}
);
});
it('generates an array of features for Feature', function () {

View File

@@ -1663,19 +1663,20 @@ describe('ol.format.GML3', function () {
describe('when parsing multiple feature types', function () {
let features;
before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function (
xml
) {
try {
features = new GML({
featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_polygon', 'planet_osm_line'],
}).readFeatures(xml);
} catch (e) {
done(e);
afterLoadText(
'spec/ol/format/gml/multiple-typenames.xml',
function (xml) {
try {
features = new GML({
featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_polygon', 'planet_osm_line'],
}).readFeatures(xml);
} catch (e) {
done(e);
}
done();
}
done();
});
);
});
it('reads all features', function () {
@@ -1686,16 +1687,17 @@ describe('ol.format.GML3', function () {
describe('when parsing multiple feature types', function () {
let features;
before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function (
xml
) {
try {
features = new GML().readFeatures(xml);
} catch (e) {
done(e);
afterLoadText(
'spec/ol/format/gml/multiple-typenames.xml',
function (xml) {
try {
features = new GML().readFeatures(xml);
} catch (e) {
done(e);
}
done();
}
done();
});
);
});
it('reads all features with autoconfigure', function () {
@@ -1750,20 +1752,21 @@ describe('ol.format.GML3', function () {
describe('when parsing srsDimension from WFS (Geoserver)', function () {
let features, feature;
before(function (done) {
afterLoadText('spec/ol/format/gml/geoserver3DFeatures.xml', function (
xml
) {
try {
const config = {
'featureNS': 'http://www.opengeospatial.net/cite',
'featureType': 'geoserver_layer',
};
features = new GML(config).readFeatures(xml);
} catch (e) {
done(e);
afterLoadText(
'spec/ol/format/gml/geoserver3DFeatures.xml',
function (xml) {
try {
const config = {
'featureNS': 'http://www.opengeospatial.net/cite',
'featureType': 'geoserver_layer',
};
features = new GML(config).readFeatures(xml);
} catch (e) {
done(e);
}
done();
}
done();
});
);
});
it('creates 3 features', function () {

View File

@@ -152,12 +152,13 @@ describe('ol.format.WFS', function () {
describe('when parsing FeatureCollection', function () {
let xml;
before(function (done) {
afterLoadText('spec/ol/format/wfs/EmptyFeatureCollection.xml', function (
_xml
) {
xml = _xml;
done();
});
afterLoadText(
'spec/ol/format/wfs/EmptyFeatureCollection.xml',
function (_xml) {
xml = _xml;
done();
}
);
});
it('returns an empty array of features when none exist', function () {
const result = new WFS().readFeatures(xml);
@@ -215,16 +216,17 @@ describe('ol.format.WFS', function () {
describe('when parsing TransactionResponse', function () {
let response;
before(function (done) {
afterLoadText('spec/ol/format/wfs/TransactionResponse.xml', function (
xml
) {
try {
response = new WFS().readTransactionResponse(xml);
} catch (e) {
done(e);
afterLoadText(
'spec/ol/format/wfs/TransactionResponse.xml',
function (xml) {
try {
response = new WFS().readTransactionResponse(xml);
} catch (e) {
done(e);
}
done();
}
done();
});
);
});
it('returns the correct TransactionResponse object', function () {
expect(response.transactionSummary.totalDeleted).to.equal(0);
@@ -1241,12 +1243,13 @@ describe('ol.format.WFS', function () {
describe('when writing out a Transaction request', function () {
let text;
before(function (done) {
afterLoadText('spec/ol/format/wfs/TransactionMulti_3D.xml', function (
xml
) {
text = xml;
done();
});
afterLoadText(
'spec/ol/format/wfs/TransactionMulti_3D.xml',
function (xml) {
text = xml;
done();
}
);
});
it('handles 3D in WFS 1.1.0', function () {
@@ -1283,12 +1286,13 @@ describe('ol.format.WFS', function () {
describe('when writing out a GetFeature request', function () {
let text;
before(function (done) {
afterLoadText('spec/ol/format/wfs/GetFeatureMultiple.xml', function (
xml
) {
text = xml;
done();
});
afterLoadText(
'spec/ol/format/wfs/GetFeatureMultiple.xml',
function (xml) {
text = xml;
done();
}
);
});
it('handles writing multiple Query elements', function () {
@@ -1335,19 +1339,20 @@ describe('ol.format.WFS', function () {
describe('when parsing multiple feature types', function () {
let features;
before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function (
xml
) {
try {
features = new WFS({
featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_polygon', 'planet_osm_line'],
}).readFeatures(xml);
} catch (e) {
done(e);
afterLoadText(
'spec/ol/format/gml/multiple-typenames.xml',
function (xml) {
try {
features = new WFS({
featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_polygon', 'planet_osm_line'],
}).readFeatures(xml);
} catch (e) {
done(e);
}
done();
}
done();
});
);
});
it('reads all features', function () {
@@ -1358,23 +1363,24 @@ describe('ol.format.WFS', function () {
describe('when parsing multiple feature types separately', function () {
let lineFeatures, polygonFeatures;
before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function (
xml
) {
try {
lineFeatures = new WFS({
featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_line'],
}).readFeatures(xml);
polygonFeatures = new WFS({
featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_polygon'],
}).readFeatures(xml);
} catch (e) {
done(e);
afterLoadText(
'spec/ol/format/gml/multiple-typenames.xml',
function (xml) {
try {
lineFeatures = new WFS({
featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_line'],
}).readFeatures(xml);
polygonFeatures = new WFS({
featureNS: 'http://localhost:8080/official',
featureType: ['planet_osm_polygon'],
}).readFeatures(xml);
} catch (e) {
done(e);
}
done();
}
done();
});
);
});
it('reads all features', function () {
@@ -1386,16 +1392,17 @@ describe('ol.format.WFS', function () {
describe('when parsing multiple feature types', function () {
let features;
before(function (done) {
afterLoadText('spec/ol/format/gml/multiple-typenames.xml', function (
xml
) {
try {
features = new WFS().readFeatures(xml);
} catch (e) {
done(e);
afterLoadText(
'spec/ol/format/gml/multiple-typenames.xml',
function (xml) {
try {
features = new WFS().readFeatures(xml);
} catch (e) {
done(e);
}
done();
}
done();
});
);
});
it('reads all features with autoconfigure', function () {

View File

@@ -885,11 +885,12 @@ describe('ol.interaction.Modify', function () {
let firstSegmentData;
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function (
node
) {
return node;
});
firstSegmentData = modify.rBush_.forEachInExtent(
[0, 0, 5, 5],
function (node) {
return node;
}
);
expect(firstSegmentData.segment[0]).to.eql([10, 10]);
expect(firstSegmentData.segment[1]).to.eql([10, 10]);
@@ -898,11 +899,12 @@ describe('ol.interaction.Modify', function () {
center[1] = 1;
feature.getGeometry().setCenter(center);
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function (
node
) {
return node;
});
firstSegmentData = modify.rBush_.forEachInExtent(
[0, 0, 5, 5],
function (node) {
return node;
}
);
expect(firstSegmentData.segment[0]).to.eql([1, 1]);
expect(firstSegmentData.segment[1]).to.eql([1, 1]);
@@ -924,11 +926,12 @@ describe('ol.interaction.Modify', function () {
let firstSegmentData;
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function (
node
) {
return node;
});
firstSegmentData = modify.rBush_.forEachInExtent(
[0, 0, 5, 5],
function (node) {
return node;
}
);
expect(firstSegmentData.segment[0]).to.eql([0, 0]);
expect(firstSegmentData.segment[1]).to.eql([10, 20]);
@@ -938,11 +941,12 @@ describe('ol.interaction.Modify', function () {
firstVertex[1] = 1;
feature.getGeometry().setCoordinates(coordinates);
firstSegmentData = modify.rBush_.forEachInExtent([0, 0, 5, 5], function (
node
) {
return node;
});
firstSegmentData = modify.rBush_.forEachInExtent(
[0, 0, 5, 5],
function (node) {
return node;
}
);
expect(firstSegmentData.segment[0]).to.eql([1, 1]);
expect(firstSegmentData.segment[1]).to.eql([10, 20]);

View File

@@ -354,16 +354,17 @@ describe('ol.source.WMTS', function () {
const parser = new WMTSCapabilities();
let capabilities;
before(function (done) {
afterLoadText('spec/ol/format/wmts/capabilities_wgs84.xml', function (
xml
) {
try {
capabilities = parser.read(xml);
} catch (e) {
done(e);
afterLoadText(
'spec/ol/format/wmts/capabilities_wgs84.xml',
function (xml) {
try {
capabilities = parser.read(xml);
} catch (e) {
done(e);
}
done();
}
done();
});
);
});
it('returns correct bounding box', function () {

View File

@@ -616,21 +616,21 @@ describe('ol.tilegrid.TileGrid', function () {
const tileCoord = [5, 11, 21];
const zs = [];
const tileRanges = [];
tileGrid.forEachTileCoordParentTileRange(tileCoord, function (
z,
tileRange
) {
zs.push(z);
tileRanges.push(
new TileRange(
tileRange.minX,
tileRange.maxX,
tileRange.minY,
tileRange.maxY
)
);
return false;
});
tileGrid.forEachTileCoordParentTileRange(
tileCoord,
function (z, tileRange) {
zs.push(z);
tileRanges.push(
new TileRange(
tileRange.minX,
tileRange.maxX,
tileRange.minY,
tileRange.maxY
)
);
return false;
}
);
expect(zs.length).to.eql(5);
expect(tileRanges.length).to.eql(5);
@@ -1061,14 +1061,14 @@ describe('ol.tilegrid.TileGrid', function () {
const zs = [];
const tileRanges = [];
tileGrid.forEachTileCoordParentTileRange([3, 7, 3], function (
z,
tileRange
) {
zs.push(z);
tileRanges.push(tileRange);
return false;
});
tileGrid.forEachTileCoordParentTileRange(
[3, 7, 3],
function (z, tileRange) {
zs.push(z);
tileRanges.push(tileRange);
return false;
}
);
expect(zs.length).to.eql(3);
expect(tileRanges.length).to.eql(3);
@@ -1219,17 +1219,17 @@ describe('ol.tilegrid.TileGrid', function () {
});
const tileCoord = [15, 6239, 11751];
tileGrid.forEachTileCoordParentTileRange(tileCoord, function (
z,
tileRange
) {
it(`works for level ${z}`, function () {
const range = tileGrid.getTileRangeForTileCoordAndZ(tileCoord, z);
expect(range.minX).to.be(tileRange.minX);
expect(range.maxX).to.be(tileRange.maxX);
expect(range.minY).to.be(tileRange.minY);
expect(range.maxY).to.be(tileRange.maxY);
});
});
tileGrid.forEachTileCoordParentTileRange(
tileCoord,
function (z, tileRange) {
it(`works for level ${z}`, function () {
const range = tileGrid.getTileRangeForTileCoordAndZ(tileCoord, z);
expect(range.minX).to.be(tileRange.minX);
expect(range.maxX).to.be(tileRange.maxX);
expect(range.minY).to.be(tileRange.minY);
expect(range.maxY).to.be(tileRange.maxY);
});
}
);
});
});