Merge pull request #13884 from tschaub/use-includes
Remove workaround for Array.prototype.includes
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
### Next version
|
### Next version
|
||||||
|
|
||||||
|
#### Internet Explorer is no longer supported
|
||||||
|
|
||||||
|
Please see https://docs.microsoft.com/en-us/lifecycle/announcements/internet-explorer-11-end-of-support.
|
||||||
|
|
||||||
### 6.15.0
|
### 6.15.0
|
||||||
|
|
||||||
#### Deprecated `tilePixelRatio` option for data tile sources.
|
#### Deprecated `tilePixelRatio` option for data tile sources.
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import {
|
|||||||
pushSerializeAndPop,
|
pushSerializeAndPop,
|
||||||
} from '../xml.js';
|
} from '../xml.js';
|
||||||
import {get as getProjection} from '../proj.js';
|
import {get as getProjection} from '../proj.js';
|
||||||
import {includes} from '../array.js';
|
|
||||||
import {
|
import {
|
||||||
readDateTime,
|
readDateTime,
|
||||||
readDecimal,
|
readDecimal,
|
||||||
@@ -172,7 +171,7 @@ class GPX extends XMLFeature {
|
|||||||
* @return {import("../Feature.js").default} Feature.
|
* @return {import("../Feature.js").default} Feature.
|
||||||
*/
|
*/
|
||||||
readFeatureFromNode(node, opt_options) {
|
readFeatureFromNode(node, opt_options) {
|
||||||
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
|
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const featureReader = FEATURE_READER[node.localName];
|
const featureReader = FEATURE_READER[node.localName];
|
||||||
@@ -195,7 +194,7 @@ class GPX extends XMLFeature {
|
|||||||
* @return {Array<import("../Feature.js").default>} Features.
|
* @return {Array<import("../Feature.js").default>} Features.
|
||||||
*/
|
*/
|
||||||
readFeaturesFromNode(node, opt_options) {
|
readFeaturesFromNode(node, opt_options) {
|
||||||
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
|
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (node.localName == 'gpx') {
|
if (node.localName == 'gpx') {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {assert} from '../asserts.js';
|
import {assert} from '../asserts.js';
|
||||||
import {includes} from '../array.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PreferredOptions
|
* @typedef {Object} PreferredOptions
|
||||||
@@ -249,10 +248,10 @@ function generateVersion3Options(iiifInfo) {
|
|||||||
iiifInfo.imageInfo.preferredFormats.length > 0
|
iiifInfo.imageInfo.preferredFormats.length > 0
|
||||||
? iiifInfo.imageInfo.preferredFormats
|
? iiifInfo.imageInfo.preferredFormats
|
||||||
.filter(function (format) {
|
.filter(function (format) {
|
||||||
return includes(['jpg', 'png', 'gif'], format);
|
return ['jpg', 'png', 'gif'].includes(format);
|
||||||
})
|
})
|
||||||
.reduce(function (acc, format) {
|
.reduce(function (acc, format) {
|
||||||
return acc === undefined && includes(formats, format)
|
return acc === undefined && formats.includes(format)
|
||||||
? format
|
? format
|
||||||
: acc;
|
: acc;
|
||||||
}, undefined)
|
}, undefined)
|
||||||
@@ -460,16 +459,16 @@ class IIIFInfo {
|
|||||||
sizes: imageOptions.sizes,
|
sizes: imageOptions.sizes,
|
||||||
format:
|
format:
|
||||||
options.format !== undefined &&
|
options.format !== undefined &&
|
||||||
includes(imageOptions.formats, options.format)
|
imageOptions.formats.includes(options.format)
|
||||||
? options.format
|
? options.format
|
||||||
: imageOptions.preferredFormat !== undefined
|
: imageOptions.preferredFormat !== undefined
|
||||||
? imageOptions.preferredFormat
|
? imageOptions.preferredFormat
|
||||||
: 'jpg',
|
: 'jpg',
|
||||||
supports: imageOptions.supports,
|
supports: imageOptions.supports,
|
||||||
quality:
|
quality:
|
||||||
options.quality && includes(imageOptions.qualities, options.quality)
|
options.quality && imageOptions.qualities.includes(options.quality)
|
||||||
? options.quality
|
? options.quality
|
||||||
: includes(imageOptions.qualities, 'native')
|
: imageOptions.qualities.includes('native')
|
||||||
? 'native'
|
? 'native'
|
||||||
: 'default',
|
: 'default',
|
||||||
resolutions: Array.isArray(imageOptions.resolutions)
|
resolutions: Array.isArray(imageOptions.resolutions)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import {
|
|||||||
} from '../xml.js';
|
} from '../xml.js';
|
||||||
import {asArray} from '../color.js';
|
import {asArray} from '../color.js';
|
||||||
import {assert} from '../asserts.js';
|
import {assert} from '../asserts.js';
|
||||||
import {extend, includes} from '../array.js';
|
import {extend} from '../array.js';
|
||||||
import {get as getProjection} from '../proj.js';
|
import {get as getProjection} from '../proj.js';
|
||||||
import {
|
import {
|
||||||
readBoolean,
|
readBoolean,
|
||||||
@@ -631,7 +631,7 @@ class KML extends XMLFeature {
|
|||||||
* @return {import("../Feature.js").default} Feature.
|
* @return {import("../Feature.js").default} Feature.
|
||||||
*/
|
*/
|
||||||
readFeatureFromNode(node, opt_options) {
|
readFeatureFromNode(node, opt_options) {
|
||||||
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
|
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const feature = this.readPlacemark_(node, [
|
const feature = this.readPlacemark_(node, [
|
||||||
@@ -651,7 +651,7 @@ class KML extends XMLFeature {
|
|||||||
* @return {Array<import("../Feature.js").default>} Features.
|
* @return {Array<import("../Feature.js").default>} Features.
|
||||||
*/
|
*/
|
||||||
readFeaturesFromNode(node, opt_options) {
|
readFeaturesFromNode(node, opt_options) {
|
||||||
if (!includes(NAMESPACE_URIS, node.namespaceURI)) {
|
if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
let features;
|
let features;
|
||||||
@@ -730,14 +730,14 @@ class KML extends XMLFeature {
|
|||||||
*/
|
*/
|
||||||
readNameFromNode(node) {
|
readNameFromNode(node) {
|
||||||
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||||
if (includes(NAMESPACE_URIS, n.namespaceURI) && n.localName == 'name') {
|
if (NAMESPACE_URIS.includes(n.namespaceURI) && n.localName == 'name') {
|
||||||
return readString(n);
|
return readString(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||||
const localName = n.localName;
|
const localName = n.localName;
|
||||||
if (
|
if (
|
||||||
includes(NAMESPACE_URIS, n.namespaceURI) &&
|
NAMESPACE_URIS.includes(n.namespaceURI) &&
|
||||||
(localName == 'Document' ||
|
(localName == 'Document' ||
|
||||||
localName == 'Folder' ||
|
localName == 'Folder' ||
|
||||||
localName == 'Placemark' ||
|
localName == 'Placemark' ||
|
||||||
@@ -803,7 +803,7 @@ class KML extends XMLFeature {
|
|||||||
const networkLinks = [];
|
const networkLinks = [];
|
||||||
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||||
if (
|
if (
|
||||||
includes(NAMESPACE_URIS, n.namespaceURI) &&
|
NAMESPACE_URIS.includes(n.namespaceURI) &&
|
||||||
n.localName == 'NetworkLink'
|
n.localName == 'NetworkLink'
|
||||||
) {
|
) {
|
||||||
const obj = pushParseAndPop({}, NETWORK_LINK_PARSERS, n, []);
|
const obj = pushParseAndPop({}, NETWORK_LINK_PARSERS, n, []);
|
||||||
@@ -813,7 +813,7 @@ class KML extends XMLFeature {
|
|||||||
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||||
const localName = n.localName;
|
const localName = n.localName;
|
||||||
if (
|
if (
|
||||||
includes(NAMESPACE_URIS, n.namespaceURI) &&
|
NAMESPACE_URIS.includes(n.namespaceURI) &&
|
||||||
(localName == 'Document' || localName == 'Folder' || localName == 'kml')
|
(localName == 'Document' || localName == 'Folder' || localName == 'kml')
|
||||||
) {
|
) {
|
||||||
extend(networkLinks, this.readNetworkLinksFromNode(n));
|
extend(networkLinks, this.readNetworkLinksFromNode(n));
|
||||||
@@ -867,7 +867,7 @@ class KML extends XMLFeature {
|
|||||||
readRegionFromNode(node) {
|
readRegionFromNode(node) {
|
||||||
const regions = [];
|
const regions = [];
|
||||||
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||||
if (includes(NAMESPACE_URIS, n.namespaceURI) && n.localName == 'Region') {
|
if (NAMESPACE_URIS.includes(n.namespaceURI) && n.localName == 'Region') {
|
||||||
const obj = pushParseAndPop({}, REGION_PARSERS, n, []);
|
const obj = pushParseAndPop({}, REGION_PARSERS, n, []);
|
||||||
regions.push(obj);
|
regions.push(obj);
|
||||||
}
|
}
|
||||||
@@ -875,7 +875,7 @@ class KML extends XMLFeature {
|
|||||||
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
||||||
const localName = n.localName;
|
const localName = n.localName;
|
||||||
if (
|
if (
|
||||||
includes(NAMESPACE_URIS, n.namespaceURI) &&
|
NAMESPACE_URIS.includes(n.namespaceURI) &&
|
||||||
(localName == 'Document' || localName == 'Folder' || localName == 'kml')
|
(localName == 'Document' || localName == 'Folder' || localName == 'kml')
|
||||||
) {
|
) {
|
||||||
extend(regions, this.readRegionFromNode(n));
|
extend(regions, this.readRegionFromNode(n));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import GML2 from './GML2.js';
|
import GML2 from './GML2.js';
|
||||||
import XMLFeature from './XMLFeature.js';
|
import XMLFeature from './XMLFeature.js';
|
||||||
import {assign} from '../obj.js';
|
import {assign} from '../obj.js';
|
||||||
import {extend, includes} from '../array.js';
|
import {extend} from '../array.js';
|
||||||
import {makeArrayPusher, makeStructureNS, pushParseAndPop} from '../xml.js';
|
import {makeArrayPusher, makeStructureNS, pushParseAndPop} from '../xml.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,7 +100,7 @@ class WMSGetFeatureInfo extends XMLFeature {
|
|||||||
const toRemove = layerIdentifier;
|
const toRemove = layerIdentifier;
|
||||||
const layerName = layerElement.localName.replace(toRemove, '');
|
const layerName = layerElement.localName.replace(toRemove, '');
|
||||||
|
|
||||||
if (this.layers_ && !includes(this.layers_, layerName)) {
|
if (this.layers_ && !this.layers_.includes(layerName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import {
|
|||||||
squaredDistanceToSegment,
|
squaredDistanceToSegment,
|
||||||
} from '../coordinate.js';
|
} from '../coordinate.js';
|
||||||
import {createEditingStyle} from '../style/Style.js';
|
import {createEditingStyle} from '../style/Style.js';
|
||||||
import {equals, includes} from '../array.js';
|
import {equals} from '../array.js';
|
||||||
import {fromCircle} from '../geom/Polygon.js';
|
import {fromCircle} from '../geom/Polygon.js';
|
||||||
import {
|
import {
|
||||||
fromUserCoordinate,
|
fromUserCoordinate,
|
||||||
@@ -1190,7 +1190,7 @@ class Modify extends PointerInteraction {
|
|||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
geometry.getType() === 'Point' &&
|
geometry.getType() === 'Point' &&
|
||||||
includes(this.features_.getArray(), feature)
|
this.features_.getArray().includes(feature)
|
||||||
) {
|
) {
|
||||||
hitPointGeometry = geometry;
|
hitPointGeometry = geometry;
|
||||||
const coordinate = geometry.getFlatCoordinates().slice(0, 2);
|
const coordinate = geometry.getFlatCoordinates().slice(0, 2);
|
||||||
|
|||||||
@@ -4,12 +4,13 @@
|
|||||||
import Collection from '../Collection.js';
|
import Collection from '../Collection.js';
|
||||||
import CollectionEventType from '../CollectionEventType.js';
|
import CollectionEventType from '../CollectionEventType.js';
|
||||||
import Event from '../events/Event.js';
|
import Event from '../events/Event.js';
|
||||||
|
import Feature from '../Feature.js';
|
||||||
import Interaction from './Interaction.js';
|
import Interaction from './Interaction.js';
|
||||||
import VectorLayer from '../layer/Vector.js';
|
import VectorLayer from '../layer/Vector.js';
|
||||||
import {TRUE} from '../functions.js';
|
import {TRUE} from '../functions.js';
|
||||||
import {clear} from '../obj.js';
|
import {clear} from '../obj.js';
|
||||||
import {createEditingStyle} from '../style/Style.js';
|
import {createEditingStyle} from '../style/Style.js';
|
||||||
import {extend, includes} from '../array.js';
|
import {extend} from '../array.js';
|
||||||
import {getUid} from '../util.js';
|
import {getUid} from '../util.js';
|
||||||
import {never, shiftKeyOnly, singleClick} from '../events/condition.js';
|
import {never, shiftKeyOnly, singleClick} from '../events/condition.js';
|
||||||
|
|
||||||
@@ -26,11 +27,9 @@ const SelectEventType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that takes an {@link module:ol/Feature~Feature} or
|
* A function that takes an {@link module:ol/Feature~Feature} and returns `true` if the feature may be
|
||||||
* {@link module:ol/render/Feature~RenderFeature} and an
|
|
||||||
* {@link module:ol/layer/Layer~Layer} and returns `true` if the feature may be
|
|
||||||
* selected or `false` otherwise.
|
* selected or `false` otherwise.
|
||||||
* @typedef {function(import("../Feature.js").FeatureLike, import("../layer/Layer.js").default<import("../source/Source").default>):boolean} FilterFunction
|
* @typedef {function(import("../Feature.js").default, import("../layer/Layer.js").default<import("../source/Source").default>):boolean} FilterFunction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,7 +257,7 @@ class Select extends Interaction {
|
|||||||
} else {
|
} else {
|
||||||
const layers = options.layers;
|
const layers = options.layers;
|
||||||
layerFilter = function (layer) {
|
layerFilter = function (layer) {
|
||||||
return includes(layers, layer);
|
return layers.includes(layer);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -281,7 +280,7 @@ class Select extends Interaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
* @param {import("../Feature.js").default} feature Feature.
|
||||||
* @param {import("../layer/Layer.js").default} layer Layer.
|
* @param {import("../layer/Layer.js").default} layer Layer.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@@ -310,7 +309,7 @@ class Select extends Interaction {
|
|||||||
/**
|
/**
|
||||||
* Returns the associated {@link module:ol/layer/Vector~VectorLayer vector layer} of
|
* Returns the associated {@link module:ol/layer/Vector~VectorLayer vector layer} of
|
||||||
* a selected feature.
|
* a selected feature.
|
||||||
* @param {import("../Feature.js").FeatureLike} feature Feature
|
* @param {import("../Feature.js").default} feature Feature
|
||||||
* @return {import('../layer/Vector.js').default} Layer.
|
* @return {import('../layer/Vector.js').default} Layer.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@@ -451,7 +450,7 @@ class Select extends Interaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("../Feature.js").FeatureLike} feature Feature.
|
* @param {import("../Feature.js").default} feature Feature.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
removeFeatureLayerAssociation_(feature) {
|
removeFeatureLayerAssociation_(feature) {
|
||||||
@@ -475,8 +474,17 @@ class Select extends Interaction {
|
|||||||
const set = !add && !remove && !toggle;
|
const set = !add && !remove && !toggle;
|
||||||
const map = mapBrowserEvent.map;
|
const map = mapBrowserEvent.map;
|
||||||
const features = this.getFeatures();
|
const features = this.getFeatures();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array<import("../Feature.js").default>}
|
||||||
|
*/
|
||||||
const deselected = [];
|
const deselected = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array<import("../Feature.js").default>}
|
||||||
|
*/
|
||||||
const selected = [];
|
const selected = [];
|
||||||
|
|
||||||
if (set) {
|
if (set) {
|
||||||
// Replace the currently selected feature(s) with the feature(s) at the
|
// Replace the currently selected feature(s) with the feature(s) at the
|
||||||
// pixel, or clear the selected feature(s) if there is no feature at
|
// pixel, or clear the selected feature(s) if there is no feature at
|
||||||
@@ -490,11 +498,12 @@ class Select extends Interaction {
|
|||||||
* @return {boolean|undefined} Continue to iterate over the features.
|
* @return {boolean|undefined} Continue to iterate over the features.
|
||||||
*/
|
*/
|
||||||
function (feature, layer) {
|
function (feature, layer) {
|
||||||
if (this.filter_(feature, layer)) {
|
if (!(feature instanceof Feature) || !this.filter_(feature, layer)) {
|
||||||
this.addFeatureLayerAssociation_(feature, layer);
|
return;
|
||||||
selected.push(feature);
|
|
||||||
return !this.multi_;
|
|
||||||
}
|
}
|
||||||
|
this.addFeatureLayerAssociation_(feature, layer);
|
||||||
|
selected.push(feature);
|
||||||
|
return !this.multi_;
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
{
|
{
|
||||||
layerFilter: this.layerFilter_,
|
layerFilter: this.layerFilter_,
|
||||||
@@ -525,19 +534,20 @@ class Select extends Interaction {
|
|||||||
* @return {boolean|undefined} Continue to iterate over the features.
|
* @return {boolean|undefined} Continue to iterate over the features.
|
||||||
*/
|
*/
|
||||||
function (feature, layer) {
|
function (feature, layer) {
|
||||||
if (this.filter_(feature, layer)) {
|
if (!(feature instanceof Feature) || !this.filter_(feature, layer)) {
|
||||||
if ((add || toggle) && !includes(features.getArray(), feature)) {
|
return;
|
||||||
this.addFeatureLayerAssociation_(feature, layer);
|
|
||||||
selected.push(feature);
|
|
||||||
} else if (
|
|
||||||
(remove || toggle) &&
|
|
||||||
includes(features.getArray(), feature)
|
|
||||||
) {
|
|
||||||
deselected.push(feature);
|
|
||||||
this.removeFeatureLayerAssociation_(feature);
|
|
||||||
}
|
|
||||||
return !this.multi_;
|
|
||||||
}
|
}
|
||||||
|
if ((add || toggle) && !features.getArray().includes(feature)) {
|
||||||
|
this.addFeatureLayerAssociation_(feature, layer);
|
||||||
|
selected.push(feature);
|
||||||
|
} else if (
|
||||||
|
(remove || toggle) &&
|
||||||
|
features.getArray().includes(feature)
|
||||||
|
) {
|
||||||
|
deselected.push(feature);
|
||||||
|
this.removeFeatureLayerAssociation_(feature);
|
||||||
|
}
|
||||||
|
return !this.multi_;
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
{
|
{
|
||||||
layerFilter: this.layerFilter_,
|
layerFilter: this.layerFilter_,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import InteractionProperty from './Property.js';
|
|||||||
import PointerInteraction from './Pointer.js';
|
import PointerInteraction from './Pointer.js';
|
||||||
import {TRUE} from '../functions.js';
|
import {TRUE} from '../functions.js';
|
||||||
import {always} from '../events/condition.js';
|
import {always} from '../events/condition.js';
|
||||||
import {includes} from '../array.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
@@ -182,7 +181,7 @@ class Translate extends PointerInteraction {
|
|||||||
} else {
|
} else {
|
||||||
const layers = options.layers;
|
const layers = options.layers;
|
||||||
layerFilter = function (layer) {
|
layerFilter = function (layer) {
|
||||||
return includes(layers, layer);
|
return layers.includes(layer);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -347,7 +346,7 @@ class Translate extends PointerInteraction {
|
|||||||
pixel,
|
pixel,
|
||||||
function (feature, layer) {
|
function (feature, layer) {
|
||||||
if (this.filter_(feature, layer)) {
|
if (this.filter_(feature, layer)) {
|
||||||
if (!this.features_ || includes(this.features_.getArray(), feature)) {
|
if (!this.features_ || this.features_.getArray().includes(feature)) {
|
||||||
return feature;
|
return feature;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-13
@@ -9,7 +9,6 @@ import {DEFAULT_TILE_SIZE} from '../tilegrid/common.js';
|
|||||||
import {Versions} from '../format/IIIFInfo.js';
|
import {Versions} from '../format/IIIFInfo.js';
|
||||||
import {assert} from '../asserts.js';
|
import {assert} from '../asserts.js';
|
||||||
import {getTopLeft} from '../extent.js';
|
import {getTopLeft} from '../extent.js';
|
||||||
import {includes} from '../array.js';
|
|
||||||
import {toSize} from '../size.js';
|
import {toSize} from '../size.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,11 +118,11 @@ class IIIF extends TileImage {
|
|||||||
const supportsArbitraryTiling =
|
const supportsArbitraryTiling =
|
||||||
supports != undefined &&
|
supports != undefined &&
|
||||||
Array.isArray(supports) &&
|
Array.isArray(supports) &&
|
||||||
(includes(supports, 'regionByPx') || includes(supports, 'regionByPct')) &&
|
(supports.includes('regionByPx') || supports.includes('regionByPct')) &&
|
||||||
(includes(supports, 'sizeByWh') ||
|
(supports.includes('sizeByWh') ||
|
||||||
includes(supports, 'sizeByH') ||
|
supports.includes('sizeByH') ||
|
||||||
includes(supports, 'sizeByW') ||
|
supports.includes('sizeByW') ||
|
||||||
includes(supports, 'sizeByPct'));
|
supports.includes('sizeByPct'));
|
||||||
|
|
||||||
let tileWidth, tileHeight, maxZoom;
|
let tileWidth, tileHeight, maxZoom;
|
||||||
|
|
||||||
@@ -278,10 +277,10 @@ class IIIF extends TileImage {
|
|||||||
regionParam = 'full';
|
regionParam = 'full';
|
||||||
} else if (
|
} else if (
|
||||||
!supportsArbitraryTiling ||
|
!supportsArbitraryTiling ||
|
||||||
includes(supports, 'regionByPx')
|
supports.includes('regionByPx')
|
||||||
) {
|
) {
|
||||||
regionParam = regionX + ',' + regionY + ',' + regionW + ',' + regionH;
|
regionParam = regionX + ',' + regionY + ',' + regionW + ',' + regionH;
|
||||||
} else if (includes(supports, 'regionByPct')) {
|
} else if (supports.includes('regionByPct')) {
|
||||||
const pctX = formatPercentage((regionX / width) * 100),
|
const pctX = formatPercentage((regionX / width) * 100),
|
||||||
pctY = formatPercentage((regionY / height) * 100),
|
pctY = formatPercentage((regionY / height) * 100),
|
||||||
pctW = formatPercentage((regionW / width) * 100),
|
pctW = formatPercentage((regionW / width) * 100),
|
||||||
@@ -290,16 +289,16 @@ class IIIF extends TileImage {
|
|||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
version == Versions.VERSION3 &&
|
version == Versions.VERSION3 &&
|
||||||
(!supportsArbitraryTiling || includes(supports, 'sizeByWh'))
|
(!supportsArbitraryTiling || supports.includes('sizeByWh'))
|
||||||
) {
|
) {
|
||||||
sizeParam = sizeW + ',' + sizeH;
|
sizeParam = sizeW + ',' + sizeH;
|
||||||
} else if (!supportsArbitraryTiling || includes(supports, 'sizeByW')) {
|
} else if (!supportsArbitraryTiling || supports.includes('sizeByW')) {
|
||||||
sizeParam = sizeW + ',';
|
sizeParam = sizeW + ',';
|
||||||
} else if (includes(supports, 'sizeByH')) {
|
} else if (supports.includes('sizeByH')) {
|
||||||
sizeParam = ',' + sizeH;
|
sizeParam = ',' + sizeH;
|
||||||
} else if (includes(supports, 'sizeByWh')) {
|
} else if (supports.includes('sizeByWh')) {
|
||||||
sizeParam = sizeW + ',' + sizeH;
|
sizeParam = sizeW + ',' + sizeH;
|
||||||
} else if (includes(supports, 'sizeByPct')) {
|
} else if (supports.includes('sizeByPct')) {
|
||||||
sizeParam = 'pct:' + formatPercentage(100 / scale);
|
sizeParam = 'pct:' + formatPercentage(100 / scale);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {containsExtent} from '../extent.js';
|
|||||||
import {createFromCapabilitiesMatrixSet} from '../tilegrid/WMTS.js';
|
import {createFromCapabilitiesMatrixSet} from '../tilegrid/WMTS.js';
|
||||||
import {createFromTileUrlFunctions, expandUrl} from '../tileurlfunction.js';
|
import {createFromTileUrlFunctions, expandUrl} from '../tileurlfunction.js';
|
||||||
import {equivalent, get as getProjection, transformExtent} from '../proj.js';
|
import {equivalent, get as getProjection, transformExtent} from '../proj.js';
|
||||||
import {find, findIndex, includes} from '../array.js';
|
import {find, findIndex} from '../array.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request encoding. One of 'KVP', 'REST'.
|
* Request encoding. One of 'KVP', 'REST'.
|
||||||
@@ -566,7 +566,7 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
|||||||
requestEncoding = encodings[0];
|
requestEncoding = encodings[0];
|
||||||
}
|
}
|
||||||
if (requestEncoding === 'KVP') {
|
if (requestEncoding === 'KVP') {
|
||||||
if (includes(encodings, 'KVP')) {
|
if (encodings.includes('KVP')) {
|
||||||
urls.push(/** @type {string} */ (gets[i]['href']));
|
urls.push(/** @type {string} */ (gets[i]['href']));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user