Merge pull request #10981 from nielsmeijer/issue-wmts-bbox

Calculate WMTS TileGrid extent using TileMatrixSetLimit when available
This commit is contained in:
Andreas Hocevar
2020-05-03 12:14:27 +02:00
committed by GitHub
4 changed files with 379 additions and 106 deletions

View File

@@ -449,22 +449,41 @@ export function optionsFromCapabilities(wmtsCap, config) {
}
const wrapX = false;
const switchOriginXY = projection.getAxisOrientation().substr(0, 2) == 'ne';
let matrix = matrixSetObj.TileMatrix[0];
// create default matrixLimit
let selectedMatrixLimit = {
MinTileCol: 0,
MinTileRow: 0,
// substract one to end up at tile top left
MaxTileCol: matrix.MatrixWidth - 1,
MaxTileRow: matrix.MatrixHeight - 1,
};
//in case of matrix limits, use matrix limits to calculate extent
if (matrixLimits) {
selectedMatrixLimit = matrixLimits[matrixLimits.length - 1];
matrix = matrixSetObj.TileMatrix.find(
(value) => value.Identifier === selectedMatrixLimit.TileMatrix
);
}
const matrix0 = matrixSetObj.TileMatrix[0];
const resolution =
(matrix0.ScaleDenominator * 0.00028) / projection.getMetersPerUnit(); // WMTS 1.0.0: standardized rendering pixel size
const origin =
projection === getProjection('EPSG:4326')
? [matrix0.TopLeftCorner[1], matrix0.TopLeftCorner[0]]
: matrix0.TopLeftCorner;
const tileSpanX = matrix0.TileWidth * resolution;
const tileSpanY = matrix0.TileHeight * resolution;
(matrix.ScaleDenominator * 0.00028) / projection.getMetersPerUnit(); // WMTS 1.0.0: standardized rendering pixel size
const origin = switchOriginXY
? [matrix.TopLeftCorner[1], matrix.TopLeftCorner[0]]
: matrix.TopLeftCorner;
const tileSpanX = matrix.TileWidth * resolution;
const tileSpanY = matrix.TileHeight * resolution;
const extent = [
origin[0],
origin[1] - tileSpanY * matrix0.MatrixHeight,
origin[0] + tileSpanX * matrix0.MatrixWidth,
origin[1],
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 (projection.getExtent() === null) {