From ff488c8214306f00e7e52980b4ae3ef4e185e12f Mon Sep 17 00:00:00 2001 From: Michael Kuenzli Date: Tue, 17 Apr 2018 14:17:13 +0200 Subject: [PATCH 1/3] Move olx.tilegrid.TileGridOptions to ol/tilegrid/TileGrid --- externs/olx.js | 80 ------------------------------------- src/ol/tilegrid.js | 2 +- src/ol/tilegrid/TileGrid.js | 29 +++++++++++++- 3 files changed, 29 insertions(+), 82 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 29caa4202a..55387980ba 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -649,86 +649,6 @@ olx.style.StyleOptions.prototype.text; olx.style.StyleOptions.prototype.zIndex; -/** - * @typedef {{extent: (ol.Extent|undefined), - * minZoom: (number|undefined), - * origin: (ol.Coordinate|undefined), - * origins: (Array.|undefined), - * resolutions: !Array., - * sizes: (Array.|undefined), - * tileSize: (number|ol.Size|undefined), - * tileSizes: (Array.|undefined)}} - */ -olx.tilegrid.TileGridOptions; - - -/** - * Extent for the tile grid. No tiles outside this extent will be requested by - * {@link ol.source.Tile} sources. When no `origin` or `origins` are - * configured, the `origin` will be set to the top-left corner of the extent. - * @type {ol.Extent|undefined} - * @api - */ -olx.tilegrid.TileGridOptions.prototype.extent; - - -/** - * Minimum zoom. Default is 0. - * @type {number|undefined} - * @api - */ -olx.tilegrid.TileGridOptions.prototype.minZoom; - - -/** - * The tile grid origin, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`). - * Tile coordinates increase left to right and upwards. If not specified, - * `extent` or `origins` must be provided. - * @type {ol.Coordinate|undefined} - * @api - */ -olx.tilegrid.TileGridOptions.prototype.origin; - - -/** - * 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 upwards. If not specified, `extent` - * or `origin` must be provided. - * @type {Array.|undefined} - * @api - */ -olx.tilegrid.TileGridOptions.prototype.origins; - - -/** - * 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`. - * @type {!Array.} - * @api - */ -olx.tilegrid.TileGridOptions.prototype.resolutions; - - -/** - * Tile size. Default is `[256, 256]`. - * @type {number|ol.Size|undefined} - * @api - */ -olx.tilegrid.TileGridOptions.prototype.tileSize; - - -/** - * Tile sizes. If given, the array length should match the length of the - * `resolutions` array, i.e. each resolution can have a different tile size. - * @type {Array.|undefined} - * @api - */ -olx.tilegrid.TileGridOptions.prototype.tileSizes; - - /** * @typedef {{extent: (ol.Extent|undefined), * origin: (ol.Coordinate|undefined), diff --git a/src/ol/tilegrid.js b/src/ol/tilegrid.js index 18875e8e6a..6e9a0643c4 100644 --- a/src/ol/tilegrid.js +++ b/src/ol/tilegrid.js @@ -77,7 +77,7 @@ export function createForExtent(extent, opt_maxZoom, opt_tileSize, opt_corner) { * @api */ export function createXYZ(opt_options) { - const options = /** @type {olx.tilegrid.TileGridOptions} */ ({}); + const options = /** @type {module:ol/tilegrid/TileGrid~Options} */ ({}); assign(options, opt_options !== undefined ? opt_options : /** @type {olx.tilegrid.XYZOptions} */ ({})); if (options.extent === undefined) { diff --git a/src/ol/tilegrid/TileGrid.js b/src/ol/tilegrid/TileGrid.js index 63989395b3..d1935301fd 100644 --- a/src/ol/tilegrid/TileGrid.js +++ b/src/ol/tilegrid/TileGrid.js @@ -10,13 +10,40 @@ import {clamp} from '../math.js'; import {toSize} from '../size.js'; import {createOrUpdate as createOrUpdateTileCoord} from '../tilecoord.js'; + +/** + * @typedef {Object} Options + * @property {module:ol/extent~Extent} [extent] Extent for the tile grid. No tiles outside this + * extent will be requested by {@link module:ol/source/Tile} sources. When no `origin` or + * `origins` are configured, the `origin` will be set to the top-left corner of the extent. + * @property {number} [minZoom=0] Minimum zoom. + * @property {module:ol/coordinate~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 upwards. 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 upwards. 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.} [sizes] Sizes. + * @property {number|module:ol/size~Size} [tileSize] Tile size. + * Default is `[256, 256]`. + * @property {Array.} [tileSizes] Tile sizes. If given, the array length + * should match the length of the `resolutions` array, i.e. each resolution can have a different + * tile size. + */ + + /** * @classdesc * Base class for setting the grid pattern for sources accessing tiled-image * servers. * * @constructor - * @param {olx.tilegrid.TileGridOptions} options Tile grid options. + * @param {module:ol/tilegrid/TileGrid~Options} options Tile grid options. * @struct * @api */ From 2178393e18f7933cfab776c3f8a4ad38cb572b33 Mon Sep 17 00:00:00 2001 From: Michael Kuenzli Date: Tue, 17 Apr 2018 14:35:50 +0200 Subject: [PATCH 2/3] Move olx.tilegrid.WMTSOptions to ol/tilegrid/WMTS --- externs/olx.js | 108 ---------------------------------------- src/ol/tilegrid/WMTS.js | 41 ++++++++++++++- 2 files changed, 40 insertions(+), 109 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 55387980ba..7de64fb3e1 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -649,114 +649,6 @@ olx.style.StyleOptions.prototype.text; olx.style.StyleOptions.prototype.zIndex; -/** - * @typedef {{extent: (ol.Extent|undefined), - * origin: (ol.Coordinate|undefined), - * origins: (Array.|undefined), - * resolutions: !Array., - * matrixIds: !Array., - * sizes: (Array.|undefined), - * tileSize: (number|ol.Size|undefined), - * tileSizes: (Array.|undefined)}} - */ -olx.tilegrid.WMTSOptions; - - -/** - * Extent for the tile grid. No tiles outside this extent will be requested by - * {@link ol.source.Tile} sources. When no `origin` or `origins` are - * configured, the `origin` will be set to the top-left corner of the extent. - * @type {ol.Extent|undefined} - * @api - */ -olx.tilegrid.WMTSOptions.prototype.extent; - - -/** - * The tile grid origin, i.e. where the `x` and `y` axes meet (`[z, 0, 0]`). - * Tile coordinates increase left to right and upwards. If not specified, - * `extent` or `origins` must be provided. - * @type {ol.Coordinate|undefined} - * @api - */ -olx.tilegrid.WMTSOptions.prototype.origin; - - -/** - * 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 upwards. If not specified, `extent` or - * `origin` must be provided. - * @type {Array.|undefined} - * @api - */ -olx.tilegrid.WMTSOptions.prototype.origins; - - -/** - * 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` - * @type {!Array.} - * @api - */ -olx.tilegrid.WMTSOptions.prototype.resolutions; - - -/** - * matrix IDs. The length of this array needs to match the length of the - * `resolutions` array. - * @type {!Array.} - * @api - */ -olx.tilegrid.WMTSOptions.prototype.matrixIds; - - -/** - * 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 the grid's extent together - * with the `origin`. An `extent` can be configured in addition, and will - * further limit the extent for which tile requests are made by sources. Note - * that when the top-left corner of the `extent` is used as `origin` or - * `origins`, then the `y` value must be negative because OpenLayers tile - * coordinates increase upwards. - * @type {Array.|undefined} - * @api - */ -olx.tilegrid.WMTSOptions.prototype.sizes; - - -/** - * Tile size. - * @type {number|ol.Size|undefined} - * @api - */ -olx.tilegrid.WMTSOptions.prototype.tileSize; - - -/** - * Tile sizes. The length of this array needs to match the length of the - * `resolutions` array. - * @type {Array.|undefined} - * @api - */ -olx.tilegrid.WMTSOptions.prototype.tileSizes; - - -/** - * Number of tile columns that cover the grid's extent for each zoom level. Only - * required when used with a source that has `wrapX` set to `true`, and only - * when the grid's origin differs from the one of the projection's extent. The - * array length has to match the length of the `resolutions` array, i.e. each - * resolution will have a matching entry here. - * @type {Array.|undefined} - * @api - */ -olx.tilegrid.WMTSOptions.prototype.widths; - - /** * @typedef {{extent: (ol.Extent|undefined), * maxZoom: (number|undefined), diff --git a/src/ol/tilegrid/WMTS.js b/src/ol/tilegrid/WMTS.js index 6f85132fde..2f20824b29 100644 --- a/src/ol/tilegrid/WMTS.js +++ b/src/ol/tilegrid/WMTS.js @@ -6,13 +6,52 @@ import {find} from '../array.js'; import {get as getProjection} from '../proj.js'; import TileGrid from '../tilegrid/TileGrid.js'; + +/** + * @typedef {Object} Options + * @property {module:ol/extent~Extent} [extent] Extent for the tile grid. No tiles + * outside this extent will be requested by {@link module:ol/source/Tile} sources. + * When no `origin` or `origins` are configured, the `origin` will be set to the + * top-left corner of the extent. + * @property {module:ol/coordinate~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 upwards. 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 upwards. 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 the grid's extent together with the `origin`. + * An `extent` can be configured in addition, and will further limit the extent for + * which tile requests are made by sources. Note that when the top-left corner of + * the `extent` is used as `origin` or `origins`, then the `y` value must be + * negative because OpenLayers tile coordinates increase upwards. + * @property {number|module:ol/size~Size} [tileSize] Tile size. + * @property {Array.} [tileSizes] Tile sizes. The length of + * this array needs to match the length of the `resolutions` array. + * @property {Array.} [widths] Number of tile columns that cover the grid's + * extent for each zoom level. Only required when used with a source that has `wrapX` + * set to `true`, and only when the grid's origin differs from the one of the + * projection's extent. The array length has to match the length of the `resolutions` + * array, i.e. each resolution will have a matching entry here. + */ + + /** * @classdesc * Set the grid pattern for sources accessing WMTS tiled-image servers. * * @constructor * @extends {module:ol/tilegrid/TileGrid~TileGrid} - * @param {olx.tilegrid.WMTSOptions} options WMTS options. + * @param {module:ol/tilegrid/WMTS~Options} options WMTS options. * @struct * @api */ From 310b9256eb27bb3b8333990c0a57fceaaabe3e43 Mon Sep 17 00:00:00 2001 From: Michael Kuenzli Date: Tue, 17 Apr 2018 14:46:51 +0200 Subject: [PATCH 3/3] Move olx.tilegrid.XYZOptions to ol/tilegrid --- externs/olx.js | 46 ---------------------------------------------- src/ol/tilegrid.js | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 48 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 7de64fb3e1..06bcb88675 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -647,49 +647,3 @@ olx.style.StyleOptions.prototype.text; * @api */ olx.style.StyleOptions.prototype.zIndex; - - -/** - * @typedef {{extent: (ol.Extent|undefined), - * maxZoom: (number|undefined), - * minZoom: (number|undefined), - * tileSize: (number|ol.Size|undefined)}} - */ -olx.tilegrid.XYZOptions; - - -/** - * Extent for the tile grid. The origin for an XYZ tile grid is the top-left - * corner of the extent. The zero level of the grid is defined by the - * resolution at which one tile fits in the provided extent. If not provided, - * the extent of the EPSG:3857 projection is used. - * @type {ol.Extent|undefined} - * @api - */ -olx.tilegrid.XYZOptions.prototype.extent; - - -/** - * Maximum zoom. The default is `ol.DEFAULT_MAX_ZOOM`. This determines the - * number of levels in the grid set. For example, a `maxZoom` of 21 means there - * are 22 levels in the grid set. - * @type {number|undefined} - * @api - */ -olx.tilegrid.XYZOptions.prototype.maxZoom; - - -/** - * Minimum zoom. Default is 0. - * @type {number|undefined} - * @api - */ -olx.tilegrid.XYZOptions.prototype.minZoom; - - -/** - * Tile size in pixels. Default is `[256, 256]`. - * @type {number|ol.Size|undefined} - * @api - */ -olx.tilegrid.XYZOptions.prototype.tileSize; diff --git a/src/ol/tilegrid.js b/src/ol/tilegrid.js index 6e9a0643c4..b7d068ed2a 100644 --- a/src/ol/tilegrid.js +++ b/src/ol/tilegrid.js @@ -70,16 +70,28 @@ export function createForExtent(extent, opt_maxZoom, opt_tileSize, opt_corner) { } +/** + * @typedef {Object} XYZOptions + * @property {module:ol/extent~Extent} [extent] Extent for the tile grid. The origin for an XYZ tile grid is the + * top-left corner of the extent. The zero level of the grid is defined by the resolution at which one tile fits in the + * provided extent. If not provided, the extent of the EPSG:3857 projection is used. + * @property {number} [maxZoom] Maximum zoom. The default is `ol.DEFAULT_MAX_ZOOM`. This determines the number of levels + * in the grid set. For example, a `maxZoom` of 21 means there are 22 levels in the grid set. + * @property {number} [minZoom=0] Minimum zoom. + * @property {number|module:ol/size~Size} [tileSize=[256, 256]] Tile size in pixels. + */ + + /** * Creates a tile grid with a standard XYZ tiling scheme. - * @param {olx.tilegrid.XYZOptions=} opt_options Tile grid options. + * @param {module:ol/tilegrid~XYZOptions=} opt_options Tile grid options. * @return {!module:ol/tilegrid/TileGrid~TileGrid} Tile grid instance. * @api */ export function createXYZ(opt_options) { const options = /** @type {module:ol/tilegrid/TileGrid~Options} */ ({}); assign(options, opt_options !== undefined ? - opt_options : /** @type {olx.tilegrid.XYZOptions} */ ({})); + opt_options : /** @type {module:ol/tilegrid~XYZOptions} */ ({})); if (options.extent === undefined) { options.extent = getProjection('EPSG:3857').getExtent(); }