package.tilegrid.WMTS.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ol Show documentation
Show all versions of ol Show documentation
OpenLayers mapping library
The newest version!
/**
* @module ol/tilegrid/WMTS
*/
import TileGrid from './TileGrid.js';
import {get as getProjection} from '../proj.js';
/**
* @typedef {Object} Options
* @property {import("../extent.js").Extent} [extent] Extent for the tile grid. No tiles
* outside this extent will be requested by {@link module:ol/source/Tile~TileSource} sources.
* When no `origin` or `origins` are configured, the `origin` will be set to the
* top-left corner of the extent.
* @property {import("../coordinate.js").Coordinate} [origin] The tile grid origin, i.e.
* where the `x` and `y` axes meet (`[z, 0, 0]`). Tile coordinates increase left
* to right and downwards. If not specified, `extent` or `origins` must be provided.
* @property {Array} [origins] Tile grid origins,
* i.e. where the `x` and `y` axes meet (`[z, 0, 0]`), for each zoom level. If
* given, the array length should match the length of the `resolutions` array, i.e.
* each resolution can have a different origin. Tile coordinates increase left to
* right and downwards. If not specified, `extent` or `origin` must be provided.
* @property {!Array} resolutions Resolutions. The array index of each
* resolution needs to match the zoom level. This means that even if a `minZoom`
* is configured, the resolutions array will have a length of `maxZoom + 1`
* @property {!Array} matrixIds matrix IDs. The length of this array needs
* to match the length of the `resolutions` array.
* @property {Array} [sizes] Number of tile rows and columns
* of the grid for each zoom level. The values here are the `TileMatrixWidth` and
* `TileMatrixHeight` advertised in the GetCapabilities response of the WMTS, and
* define each zoom level's extent together with the `origin` or `origins`.
* A grid `extent` can be configured in addition, and will further limit the extent for
* which tile requests are made by sources. If the bottom-left corner of
* an extent is used as `origin` or `origins`, then the `y` value must be
* negative because OpenLayers tile coordinates use the top left as the origin.
* @property {number|import("../size.js").Size} [tileSize] Tile size.
* @property {Array} [tileSizes] Tile sizes. The length of
* this array needs to match the length of the `resolutions` array.
*/
/**
* @classdesc
* Set the grid pattern for sources accessing WMTS tiled-image servers.
* @api
*/
class WMTSTileGrid extends TileGrid {
/**
* @param {Options} options WMTS options.
*/
constructor(options) {
super({
extent: options.extent,
origin: options.origin,
origins: options.origins,
resolutions: options.resolutions,
tileSize: options.tileSize,
tileSizes: options.tileSizes,
sizes: options.sizes,
});
/**
* @private
* @type {!Array}
*/
this.matrixIds_ = options.matrixIds;
}
/**
* @param {number} z Z.
* @return {string} MatrixId..
*/
getMatrixId(z) {
return this.matrixIds_[z];
}
/**
* Get the list of matrix identifiers.
* @return {Array} MatrixIds.
* @api
*/
getMatrixIds() {
return this.matrixIds_;
}
}
export default WMTSTileGrid;
/**
* Create a tile grid from a WMTS capabilities matrix set and an
* optional TileMatrixSetLimits.
* @param {Object} matrixSet An object representing a matrixSet in the
* capabilities document.
* @param {import("../extent.js").Extent} [extent] An optional extent to restrict the tile
* ranges the server provides.
* @param {Array