diff --git a/src/ol/format/WMTSCapabilities.js b/src/ol/format/WMTSCapabilities.js index 9e72eb213e..9dceae171d 100644 --- a/src/ol/format/WMTSCapabilities.js +++ b/src/ol/format/WMTSCapabilities.js @@ -103,7 +103,7 @@ const LAYER_PARSERS = makeStructureNS( makeStructureNS(OWS_NAMESPACE_URIS, { 'Title': makeObjectPropertySetter(readString), 'Abstract': makeObjectPropertySetter(readString), - 'WGS84BoundingBox': makeObjectPropertySetter(readWgs84BoundingBox), + 'WGS84BoundingBox': makeObjectPropertySetter(readBoundingBox), 'Identifier': makeObjectPropertySetter(readString), }) ); @@ -196,6 +196,7 @@ const TMS_PARSERS = makeStructureNS( makeStructureNS(OWS_NAMESPACE_URIS, { 'SupportedCRS': makeObjectPropertySetter(readString), 'Identifier': makeObjectPropertySetter(readString), + 'BoundingBox': makeObjectPropertySetter(readBoundingBox), }) ); @@ -304,9 +305,9 @@ function readResourceUrl(node, objectStack) { /** * @param {Element} node Node. * @param {Array<*>} objectStack Object stack. - * @return {Object|undefined} WGS84 BBox object. + * @return {Object|undefined} BBox object. */ -function readWgs84BoundingBox(node, objectStack) { +function readBoundingBox(node, objectStack) { const coordinates = pushParseAndPop( [], WGS84_BBOX_READERS, diff --git a/src/ol/source/WMTS.js b/src/ol/source/WMTS.js index b56288bca8..4f73cfbcf0 100644 --- a/src/ol/source/WMTS.js +++ b/src/ol/source/WMTS.js @@ -9,7 +9,7 @@ import {assign} from '../obj.js'; 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 {equivalent, get as getProjection} from '../proj.js'; import {find, findIndex, includes} from '../array.js'; /** @@ -479,27 +479,25 @@ export function optionsFromCapabilities(wmtsCap, config) { : matrix.TopLeftCorner; const tileSpanX = matrix.TileWidth * resolution; const tileSpanY = matrix.TileHeight * resolution; - let extent; - const wgs84BoundingBox = l['WGS84BoundingBox']; - const tileMatrixExtend = [ + const matrixSetExtent = matrixSetObj['BoundingBox']; + let extent = [ origin[0] + tileSpanX * selectedMatrixLimit.MinTileCol, // add one to get proper bottom/right coordinate origin[1] - tileSpanY * (1 + selectedMatrixLimit.MaxTileRow), origin[0] + tileSpanX * (1 + selectedMatrixLimit.MaxTileCol), origin[1] - tileSpanY * selectedMatrixLimit.MinTileRow, ]; - if (wgs84BoundingBox !== undefined) { + + if ( + matrixSetExtent !== undefined && + !containsExtent(matrixSetExtent, extent) + ) { + const wgs84BoundingBox = l['WGS84BoundingBox']; const wgs84ProjectionExtent = getProjection('EPSG:4326').getExtent(); + extent = matrixSetExtent; wrapX = wgs84BoundingBox[0] === wgs84ProjectionExtent[0] && wgs84BoundingBox[2] === wgs84ProjectionExtent[2]; - extent = transformExtent(wgs84BoundingBox, 'EPSG:4326', projection); - - if (!containsExtent(tileMatrixExtend, extent)) { - extent = tileMatrixExtend; - } - } else { - extent = tileMatrixExtend; } if (projection.getExtent() === null) {