Merge pull request #13887 from tschaub/array-find
Remove find and findIndex from array module
This commit is contained in:
@@ -9,7 +9,6 @@ import {containsExtent} from '../extent.js';
|
||||
import {createFromCapabilitiesMatrixSet} from '../tilegrid/WMTS.js';
|
||||
import {createFromTileUrlFunctions, expandUrl} from '../tileurlfunction.js';
|
||||
import {equivalent, get as getProjection, transformExtent} from '../proj.js';
|
||||
import {find, findIndex} from '../array.js';
|
||||
|
||||
/**
|
||||
* Request encoding. One of 'KVP', 'REST'.
|
||||
@@ -372,18 +371,18 @@ export default WMTS;
|
||||
*/
|
||||
export function optionsFromCapabilities(wmtsCap, config) {
|
||||
const layers = wmtsCap['Contents']['Layer'];
|
||||
const l = find(layers, function (elt, index, array) {
|
||||
const l = layers.find(function (elt) {
|
||||
return elt['Identifier'] == config['layer'];
|
||||
});
|
||||
if (l === null) {
|
||||
if (!l) {
|
||||
return null;
|
||||
}
|
||||
const tileMatrixSets = wmtsCap['Contents']['TileMatrixSet'];
|
||||
let idx;
|
||||
if (l['TileMatrixSetLink'].length > 1) {
|
||||
if ('projection' in config) {
|
||||
idx = findIndex(l['TileMatrixSetLink'], function (elt, index, array) {
|
||||
const tileMatrixSet = find(tileMatrixSets, function (el) {
|
||||
idx = l['TileMatrixSetLink'].findIndex(function (elt) {
|
||||
const tileMatrixSet = tileMatrixSets.find(function (el) {
|
||||
return el['Identifier'] == elt['TileMatrixSet'];
|
||||
});
|
||||
const supportedCRS = tileMatrixSet['SupportedCRS'];
|
||||
@@ -396,7 +395,7 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
idx = findIndex(l['TileMatrixSetLink'], function (elt, index, array) {
|
||||
idx = l['TileMatrixSetLink'].findIndex(function (elt) {
|
||||
return elt['TileMatrixSet'] == config['matrixSet'];
|
||||
});
|
||||
}
|
||||
@@ -417,7 +416,7 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
||||
if ('format' in config) {
|
||||
format = config['format'];
|
||||
}
|
||||
idx = findIndex(l['Style'], function (elt, index, array) {
|
||||
idx = l['Style'].findIndex(function (elt) {
|
||||
if ('style' in config) {
|
||||
return elt['Title'] == config['style'];
|
||||
} else {
|
||||
@@ -442,7 +441,7 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
||||
}
|
||||
|
||||
const matrixSets = wmtsCap['Contents']['TileMatrixSet'];
|
||||
const matrixSetObj = find(matrixSets, function (elt, index, array) {
|
||||
const matrixSetObj = matrixSets.find(function (elt) {
|
||||
return elt['Identifier'] == matrixSet;
|
||||
});
|
||||
|
||||
@@ -477,8 +476,7 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
||||
//in case of matrix limits, use matrix limits to calculate extent
|
||||
if (matrixLimits) {
|
||||
selectedMatrixLimit = matrixLimits[matrixLimits.length - 1];
|
||||
const m = find(
|
||||
matrixSetObj.TileMatrix,
|
||||
const m = matrixSetObj.TileMatrix.find(
|
||||
(tileMatrixValue) =>
|
||||
tileMatrixValue.Identifier === selectedMatrixLimit.TileMatrix ||
|
||||
matrixSetObj.Identifier + ':' + tileMatrixValue.Identifier ===
|
||||
@@ -556,7 +554,7 @@ export function optionsFromCapabilities(wmtsCap, config) {
|
||||
|
||||
for (let i = 0, ii = gets.length; i < ii; ++i) {
|
||||
if (gets[i]['Constraint']) {
|
||||
const constraint = find(gets[i]['Constraint'], function (element) {
|
||||
const constraint = gets[i]['Constraint'].find(function (element) {
|
||||
return element['name'] == 'GetEncoding';
|
||||
});
|
||||
const encodings = constraint['AllowedValues']['Value'];
|
||||
|
||||
Reference in New Issue
Block a user