Adjusts the WMTSCapabilities format to read the projected TileMatrixSet's BoundingBox

This commit is contained in:
amir-ba
2020-08-09 17:55:18 +02:00
parent 3de64763e7
commit f3a33bd75a
2 changed files with 14 additions and 15 deletions

View File

@@ -103,7 +103,7 @@ const LAYER_PARSERS = makeStructureNS(
makeStructureNS(OWS_NAMESPACE_URIS, { makeStructureNS(OWS_NAMESPACE_URIS, {
'Title': makeObjectPropertySetter(readString), 'Title': makeObjectPropertySetter(readString),
'Abstract': makeObjectPropertySetter(readString), 'Abstract': makeObjectPropertySetter(readString),
'WGS84BoundingBox': makeObjectPropertySetter(readWgs84BoundingBox), 'WGS84BoundingBox': makeObjectPropertySetter(readBoundingBox),
'Identifier': makeObjectPropertySetter(readString), 'Identifier': makeObjectPropertySetter(readString),
}) })
); );
@@ -196,6 +196,7 @@ const TMS_PARSERS = makeStructureNS(
makeStructureNS(OWS_NAMESPACE_URIS, { makeStructureNS(OWS_NAMESPACE_URIS, {
'SupportedCRS': makeObjectPropertySetter(readString), 'SupportedCRS': makeObjectPropertySetter(readString),
'Identifier': makeObjectPropertySetter(readString), 'Identifier': makeObjectPropertySetter(readString),
'BoundingBox': makeObjectPropertySetter(readBoundingBox),
}) })
); );
@@ -304,9 +305,9 @@ function readResourceUrl(node, objectStack) {
/** /**
* @param {Element} node Node. * @param {Element} node Node.
* @param {Array<*>} objectStack Object stack. * @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( const coordinates = pushParseAndPop(
[], [],
WGS84_BBOX_READERS, WGS84_BBOX_READERS,

View File

@@ -9,7 +9,7 @@ import {assign} from '../obj.js';
import {containsExtent} from '../extent.js'; 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} from '../proj.js';
import {find, findIndex, includes} from '../array.js'; import {find, findIndex, includes} from '../array.js';
/** /**
@@ -479,27 +479,25 @@ export function optionsFromCapabilities(wmtsCap, config) {
: matrix.TopLeftCorner; : matrix.TopLeftCorner;
const tileSpanX = matrix.TileWidth * resolution; const tileSpanX = matrix.TileWidth * resolution;
const tileSpanY = matrix.TileHeight * resolution; const tileSpanY = matrix.TileHeight * resolution;
let extent; const matrixSetExtent = matrixSetObj['BoundingBox'];
const wgs84BoundingBox = l['WGS84BoundingBox']; let extent = [
const tileMatrixExtend = [
origin[0] + tileSpanX * selectedMatrixLimit.MinTileCol, origin[0] + tileSpanX * selectedMatrixLimit.MinTileCol,
// add one to get proper bottom/right coordinate // add one to get proper bottom/right coordinate
origin[1] - tileSpanY * (1 + selectedMatrixLimit.MaxTileRow), origin[1] - tileSpanY * (1 + selectedMatrixLimit.MaxTileRow),
origin[0] + tileSpanX * (1 + selectedMatrixLimit.MaxTileCol), origin[0] + tileSpanX * (1 + selectedMatrixLimit.MaxTileCol),
origin[1] - tileSpanY * selectedMatrixLimit.MinTileRow, origin[1] - tileSpanY * selectedMatrixLimit.MinTileRow,
]; ];
if (wgs84BoundingBox !== undefined) {
if (
matrixSetExtent !== undefined &&
!containsExtent(matrixSetExtent, extent)
) {
const wgs84BoundingBox = l['WGS84BoundingBox'];
const wgs84ProjectionExtent = getProjection('EPSG:4326').getExtent(); const wgs84ProjectionExtent = getProjection('EPSG:4326').getExtent();
extent = matrixSetExtent;
wrapX = wrapX =
wgs84BoundingBox[0] === wgs84ProjectionExtent[0] && wgs84BoundingBox[0] === wgs84ProjectionExtent[0] &&
wgs84BoundingBox[2] === wgs84ProjectionExtent[2]; wgs84BoundingBox[2] === wgs84ProjectionExtent[2];
extent = transformExtent(wgs84BoundingBox, 'EPSG:4326', projection);
if (!containsExtent(tileMatrixExtend, extent)) {
extent = tileMatrixExtend;
}
} else {
extent = tileMatrixExtend;
} }
if (projection.getExtent() === null) { if (projection.getExtent() === null) {