From ac4e472353834aad59de62f095e418080ade50b5 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sat, 4 Sep 2021 10:31:36 -0600 Subject: [PATCH] Use union type for corner of origin --- src/ol/source/ogcTileUtil.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ol/source/ogcTileUtil.js b/src/ol/source/ogcTileUtil.js index de5fae0f5e..6ad4ace43a 100644 --- a/src/ol/source/ogcTileUtil.js +++ b/src/ol/source/ogcTileUtil.js @@ -16,6 +16,10 @@ import {getIntersection as intersectExtents} from '../extent.js'; * @typedef {'map' | 'vector'} TileType */ +/** + * @typedef {'topLeft' | 'bottomLeft'} CornerOfOrigin + */ + /** * @typedef {Object} TileSet * @property {TileType} dataType Type of data represented in the tileset. @@ -53,7 +57,7 @@ import {getIntersection as intersectExtents} from '../extent.js'; * @property {string} id The tile matrix identifier. * @property {number} cellSize The pixel resolution (map units per pixel). * @property {Array} pointOfOrigin The map location of the matrix origin. - * @property {string} [cornerOfOrigin='topLeft'] The corner of the matrix that represents the origin ('topLeft' or 'bottomLeft'). + * @property {CornerOfOrigin} [cornerOfOrigin='topLeft'] The corner of the matrix that represents the origin ('topLeft' or 'bottomLeft'). * @property {number} matrixWidth The number of columns. * @property {number} matrixHeight The number of rows. * @property {number} tileWidth The pixel width of a tile. @@ -93,8 +97,6 @@ const knownVectorMediaTypes = { * @property {Object} [context] Optional context for constructing the URL. */ -const BOTTOM_LEFT_ORIGIN = 'bottomLeft'; - /** * @param {Array} links Tileset links. * @param {string} [mediaType] The preferred media type. @@ -244,7 +246,7 @@ function parseTileMatrixSet( const maxX = origins[i][0] + (limit.maxTileCol + 1) * tileMapWidth; const tileMapHeight = matrix.cellSize * matrix.tileHeight; - const upsideDown = matrix.cornerOfOrigin === BOTTOM_LEFT_ORIGIN; + const upsideDown = matrix.cornerOfOrigin === 'bottomLeft'; let minY; let maxY; @@ -278,7 +280,7 @@ function parseTileMatrixSet( const id = matrixIds[tileCoord[0]]; const matrix = matrixLookup[id]; - const upsideDown = matrix.cornerOfOrigin === BOTTOM_LEFT_ORIGIN; + const upsideDown = matrix.cornerOfOrigin === 'bottomLeft'; const localContext = { tileMatrix: id,