From 15fba2cbaf60ccd73fe74db029598b26c9a46535 Mon Sep 17 00:00:00 2001 From: Florent gravin Date: Wed, 28 Mar 2018 17:03:30 +0200 Subject: [PATCH] Remove olx.source.TileImageOptions --- externs/olx.js | 172 ------------------------------------- src/ol/source/TileImage.js | 44 +++++++++- 2 files changed, 43 insertions(+), 173 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index e8488049ec..07f255d072 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -98,178 +98,6 @@ olx.source.TileUTFGridOptions.prototype.tileJSON; olx.source.TileUTFGridOptions.prototype.url; -/** - * @typedef {{attributions: (ol.AttributionLike|undefined), - * cacheSize: (number|undefined), - * crossOrigin: (null|string|undefined), - * opaque: (boolean|undefined), - * projection: ol.ProjectionLike, - * reprojectionErrorThreshold: (number|undefined), - * state: (ol.source.State|undefined), - * tileClass: (function(new: ol.ImageTile, ol.TileCoord, - * ol.TileState, string, ?string, - * ol.TileLoadFunctionType)|undefined), - * tileGrid: (ol.tilegrid.TileGrid|undefined), - * tileLoadFunction: (ol.TileLoadFunctionType|undefined), - * tilePixelRatio: (number|undefined), - * tileUrlFunction: (ol.TileUrlFunctionType|undefined), - * url: (string|undefined), - * urls: (Array.|undefined), - * wrapX: (boolean|undefined), - * transition: (number|undefined)}} - */ -olx.source.TileImageOptions; - - -/** - * Attributions. - * @type {ol.AttributionLike|undefined} - * @api - */ -olx.source.TileImageOptions.prototype.attributions; - - -/** - * Cache size. Default is `2048`. - * @type {number|undefined} - * @api - */ -olx.source.TileImageOptions.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 {null|string|undefined} - * @api - */ -olx.source.TileImageOptions.prototype.crossOrigin; - - -/** - * Whether the layer is opaque. - * @type {boolean|undefined} - * @api - */ -olx.source.TileImageOptions.prototype.opaque; - - -/** - * Projection. - * @type {ol.ProjectionLike} - * @api - */ -olx.source.TileImageOptions.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.TileImageOptions.prototype.reprojectionErrorThreshold; - - -/** - * Source state. - * @type {ol.source.State|undefined} - * @api - */ -olx.source.TileImageOptions.prototype.state; - - -/** - * 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.TileImageOptions.prototype.tileClass; - - -/** - * Tile grid. - * @type {ol.tilegrid.TileGrid|undefined} - * @api - */ -olx.source.TileImageOptions.prototype.tileGrid; - - -/** - * 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.TileImageOptions.prototype.tileLoadFunction; - - -/** - * 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.TileImageOptions.prototype.tilePixelRatio; - - -/** - * Optional function to get tile URL given a tile coordinate and the projection. - * @type {ol.TileUrlFunctionType|undefined} - * @api - */ -olx.source.TileImageOptions.prototype.tileUrlFunction; - - -/** - * URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. - * 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.TileImageOptions.prototype.url; - - -/** - * An array of URL templates. - * @type {Array.|undefined} - * @api - */ -olx.source.TileImageOptions.prototype.urls; - - -/** - * Whether to wrap the world horizontally. The default, `undefined`, is to - * request out-of-bounds tiles from the server. When set to `false`, only one - * world will be rendered. When set to `true`, tiles will be requested for one - * world only, but they will be wrapped horizontally to render multiple worlds. - * @type {boolean|undefined} - * @api - */ -olx.source.TileImageOptions.prototype.wrapX; - - -/** - * Duration of the opacity transition for rendering. To disable the opacity - * transition, pass `transition: 0`. - * @type {number|undefined} - * @api - */ -olx.source.TileImageOptions.prototype.transition; - - /** * @typedef {{attributions: (ol.AttributionLike|undefined), * cacheSize: (number|undefined), diff --git a/src/ol/source/TileImage.js b/src/ol/source/TileImage.js index 73a9d1cce8..ecc32656de 100644 --- a/src/ol/source/TileImage.js +++ b/src/ol/source/TileImage.js @@ -14,6 +14,48 @@ import UrlTile from '../source/UrlTile.js'; import {getKey, getKeyZXY} from '../tilecoord.js'; import {getForProjection as getTileGridForProjection} from '../tilegrid.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 {boolean} [opaque=true] Whether the layer is opaque. + * @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.State} [state] Source state. + * @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. + * @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 {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 {ol.TileUrlFunctionType} [tileUrlFunction] Optional function to get tile URL given a tile coordinate and the projection. + * @property {string} [url] URL template. Must include `{x}`, `{y}` or `{-y}`, and `{z}` placeholders. + * A `{?-?}` template pattern, for example `subdomain{a-f}.domain.com`, may be + * used instead of defining each one separately in the `urls` option. + * @property {Array.} [urls] An array of URL templates. + * @property {boolean} [wrapX=undefined] Whether to wrap the world horizontally. The default, is to + * request out-of-bounds tiles from the server. When set to `false`, only one + * world will be rendered. When set to `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 * Base class for sources providing images divided into a tile grid. @@ -21,7 +63,7 @@ import {getForProjection as getTileGridForProjection} from '../tilegrid.js'; * @constructor * @fires ol.source.Tile.Event * @extends {ol.source.UrlTile} - * @param {olx.source.TileImageOptions} options Image tile options. + * @param {module:ol/source/TileImage~Options=} options Image tile options. * @api */ const TileImage = function(options) {