diff --git a/externs/olx.js b/externs/olx.js index a7dede4253..5024d602ae 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -241,213 +241,6 @@ olx.source.TileArcGISRestOptions.prototype.transition; olx.source.TileArcGISRestOptions.prototype.urls; -/** - * @typedef {{attributions: (ol.AttributionLike|undefined), - * cacheSize: (number|undefined), - * crossOrigin: (string|null|undefined), - * tileGrid: ol.tilegrid.WMTS, - * projection: ol.ProjectionLike, - * reprojectionErrorThreshold: (number|undefined), - * requestEncoding: (ol.source.WMTSRequestEncoding|string|undefined), - * layer: string, - * style: string, - * tilePixelRatio: (number|undefined), - * version: (string|undefined), - * format: (string|undefined), - * matrixSet: string, - * dimensions: (!Object|undefined), - * url: (string|undefined), - * tileLoadFunction: (ol.TileLoadFunctionType|undefined), - * urls: (Array.|undefined), - * tileClass: (function(new: ol.ImageTile, ol.TileCoord, - * ol.TileState, string, ?string, - * ol.TileLoadFunctionType)|undefined), - * wrapX: (boolean|undefined), - * transition: (number|undefined)}} - */ -olx.source.WMTSOptions; - - -/** - * Attributions. - * @type {ol.AttributionLike|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.attributions; - - -/** - * Cache size. Default is `2048`. - * @type {number|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.cacheSize; - - -/** - * The `crossOrigin` attribute for loaded images. Note that you must provide a - * `crossOrigin` value if you are using the WebGL renderer or if you want to - * access pixel data with the Canvas renderer. See - * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} - * for more detail. - * @type {string|null|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.crossOrigin; - - -/** - * Tile grid. - * @type {ol.tilegrid.WMTS} - * @api - */ -olx.source.WMTSOptions.prototype.tileGrid; - - -/** - * Projection. - * @type {ol.ProjectionLike} - * @api - */ -olx.source.WMTSOptions.prototype.projection; - - -/** - * Maximum allowed reprojection error (in pixels). Default is `0.5`. - * Higher values can increase reprojection performance, but decrease precision. - * @type {number|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.reprojectionErrorThreshold; - - -/** - * Request encoding. Default is `KVP`. - * @type {ol.source.WMTSRequestEncoding|string|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.requestEncoding; - - -/** - * Layer name as advertised in the WMTS capabilities. - * @type {string} - * @api - */ -olx.source.WMTSOptions.prototype.layer; - - -/** - * Style name as advertised in the WMTS capabilities. - * @type {string} - * @api - */ -olx.source.WMTSOptions.prototype.style; - - -/** - * Class used to instantiate image tiles. Default is {@link ol.ImageTile}. - * @type {function(new: ol.ImageTile, ol.TileCoord, - * ol.TileState, string, ?string, - * ol.TileLoadFunctionType)|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.tileClass; - - -/** - * The pixel ratio used by the tile service. For example, if the tile - * service advertizes 256px by 256px tiles but actually sends 512px - * by 512px images (for retina/hidpi devices) then `tilePixelRatio` - * should be set to `2`. Default is `1`. - * @type {number|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.tilePixelRatio; - - -/** - * WMTS version. Default is `1.0.0`. - * @type {string|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.version; - - -/** - * Image format. Default is `image/jpeg`. - * @type {string|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.format; - - -/** - * Matrix set. - * @type {string} - * @api - */ -olx.source.WMTSOptions.prototype.matrixSet; - - -/** - * Additional "dimensions" for tile requests. This is an object with properties - * named like the advertised WMTS dimensions. - * @type {!Object|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.dimensions; - - -/** - * A URL for the service. For the RESTful request encoding, this is a URL - * template. For KVP encoding, it is normal URL. A `{?-?}` template pattern, - * for example `subdomain{a-f}.domain.com`, may be used instead of defining - * each one separately in the `urls` option. - * @type {string|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.url; - - -/** - * Optional function to load a tile given a URL. The default is - * ```js - * function(imageTile, src) { - * imageTile.getImage().src = src; - * }; - * ``` - * @type {ol.TileLoadFunctionType|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.tileLoadFunction; - - -/** - * An array of URLs. Requests will be distributed among the URLs in this array. - * @type {Array.|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.urls; - - -/** - * Whether to wrap the world horizontally. Default is `false`. - * @type {boolean|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.wrapX; - - -/** - * Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - * @type {number|undefined} - * @api - */ -olx.source.WMTSOptions.prototype.transition; - - /** * @typedef {{attributions: (ol.AttributionLike|undefined), * cacheSize: (number|undefined), diff --git a/src/ol/source/WMTS.js b/src/ol/source/WMTS.js index ba4cd19bba..841c11bb16 100644 --- a/src/ol/source/WMTS.js +++ b/src/ol/source/WMTS.js @@ -12,13 +12,96 @@ import WMTSRequestEncoding from '../source/WMTSRequestEncoding.js'; import {createFromCapabilitiesMatrixSet} from '../tilegrid/WMTS.js'; import {appendParams} from '../uri.js'; +/** + * @typedef {Object} Options + * @property {ol.AttributionLike} [attributions] Attributions. + * @property {number} [cacheSize=2048] Cache size. + * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that + * you must provide a `crossOrigin` value if you are using the WebGL renderer or if you want to + * access pixel data with the Canvas renderer. See + * {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image} for more detail. + * @property {ol.tilegrid.WMTS} tileGrid Tile grid. + * @property {ol.ProjectionLike} projection Projection. + * @property {boolean} [reprojectionErrorThreshold=0.5] Maximum allowed reprojection error (in pixels). + * Higher values can increase reprojection performance, but decrease precision. + * @property {ol.source.WMTSRequestEncoding|string} [requestEncoding='KVP'] Request encoding. + * @property {string} layer Layer name as advertised in the WMTS capabilities. + * @property {string} style Style name as advertised in the WMTS capabilities. + * @property {function(new: ol.ImageTile, ol.TileCoord, + * ol.TileState, string, ?string, + * ol.TileLoadFunctionType)} [tileClass] Class used to instantiate image tiles. Default is {@link ol.ImageTile}. + * @property {number} [tilePixelRatio=1] The pixel ratio used by the tile service. + * For example, if the tile service advertizes 256px by 256px tiles but actually sends 512px + * by 512px images (for retina/hidpi devices) then `tilePixelRatio` + * should be set to `2`. + * @property {string} [version='image/jpeg'] Image format. + * @property {string} [format='1.0.0'] WMTS version. + * @property {string} matrixSet Matrix set. + * @property {!Object} [dimensions] Additional "dimensions" for tile requests. + * This is an object with properties named like the advertised WMTS dimensions. + * @property {string} [url] A URL for the service. + * For the RESTful request encoding, this is a URL + * template. For KVP encoding, it is normal URL. A `{?-?}` template pattern, + * for example `subdomain{a-f}.domain.com`, may be used instead of defining + * each one separately in the `urls` option. + * @property {ol.TileLoadFunctionType} [tileLoadFunction] Optional function to load a tile given a URL. The default is + * ```js + * function(imageTile, src) { + * imageTile.getImage().src = src; + * }; + * ``` + * @property {Array.} [urls] An array of URLs. + * Requests will be distributed among the URLs in this array. + * @property {boolean} [wrapX=false] Whether to wrap the world horizontally. + * @property {number} [transition] Duration of the opacity transition for rendering. + * To disable the opacity transition, pass `transition: 0`. + + + * At least a `LAYERS` param is required. `STYLES` is + * `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX` + * and `CRS` (`SRS` for WMS version < 1.3.0) will be set dynamically. + * @property {number} [gutter=0] + * The size in pixels of the gutter around image tiles to ignore. By setting + * this property to a non-zero value, images will be requested that are wider + * and taller than the tile size by a value of `2 x gutter`. + * Using a non-zero value allows artifacts of rendering at tile edges to be + * ignored. If you control the WMS service it is recommended to address + * "artifacts at tile edges" issues by properly configuring the WMS service. For + * example, MapServer has a `tile_map_edge_buffer` configuration parameter for + * this. See http://mapserver.org/output/tile_mode.html. + * @property {boolean} [hidpi=true] Use the `ol.Map#pixelRatio` value when requesting + * the image from the remote server. + * @property {function(new: ol.ImageTile, ol.TileCoord, + * ol.TileState, string, ?string, + * ol.TileLoadFunctionType)} [tileClass] Class used to instantiate image tiles. + * Default is {@link ol.ImageTile}. + * @property {ol.tilegrid.TileGrid} [tileGrid] Tile grid. Base this on the resolutions, + * tilesize and extent supported by the server. + * If this is not defined, a default grid will be used: if there is a projection + * extent, the grid will be based on that; if not, a grid based on a global + * extent with origin at 0,0 will be used.. + * @property {ol.source.WMSServerType|string} [serverType=undefined] + * The type of the remote WMS server. Currently only used when `hidpi` is + * `true`. + * @property {string} [url] WMS service URL. + * @property {Array.} [urls] WMS service urls. + * Use this instead of `url` when the WMS supports multiple urls for GetMap requests. + * @property {boolean} [wrapX=true] Whether to wrap the world horizontally. + * When set to `false`, only one world + * will be rendered. When `true`, tiles will be requested for one world only, + * but they will be wrapped horizontally to render multiple worlds. + * @property {number} [transition] Duration of the opacity transition for rendering. + * To disable the opacity transition, pass `transition: 0`. + */ + + /** * @classdesc * Layer source for tile data from WMTS servers. * * @constructor * @extends {ol.source.TileImage} - * @param {olx.source.WMTSOptions} options WMTS options. + * @param {module:ol/source/WMTS~Options=} options WMTS options. * @api */ const WMTS = function(options) {