WebMapTileServiceImageryProvider.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. import combine from "../Core/combine.js";
  2. import Credit from "../Core/Credit.js";
  3. import defaultValue from "../Core/defaultValue.js";
  4. import defined from "../Core/defined.js";
  5. import DeveloperError from "../Core/DeveloperError.js";
  6. import Event from "../Core/Event.js";
  7. import Rectangle from "../Core/Rectangle.js";
  8. import Resource from "../Core/Resource.js";
  9. import WebMercatorTilingScheme from "../Core/WebMercatorTilingScheme.js";
  10. import when from "../ThirdParty/when.js";
  11. import ImageryProvider from "./ImageryProvider.js";
  12. import TimeDynamicImagery from "./TimeDynamicImagery.js";
  13. var defaultParameters = Object.freeze({
  14. service: "WMTS",
  15. version: "1.0.0",
  16. request: "GetTile",
  17. });
  18. /**
  19. * @typedef {Object} WebMapTileServiceImageryProvider.ConstructorOptions
  20. *
  21. * Initialization options for the WebMapTileServiceImageryProvider constructor
  22. *
  23. * @property {Resource|String} url The base URL for the WMTS GetTile operation (for KVP-encoded requests) or the tile-URL template (for RESTful requests). The tile-URL template should contain the following variables: {style}, {TileMatrixSet}, {TileMatrix}, {TileRow}, {TileCol}. The first two are optional if actual values are hardcoded or not required by the server. The {s} keyword may be used to specify subdomains.
  24. * @property {String} [format='image/jpeg'] The MIME type for images to retrieve from the server.
  25. * @property {String} layer The layer name for WMTS requests.
  26. * @property {String} style The style name for WMTS requests.
  27. * @property {String} tileMatrixSetID The identifier of the TileMatrixSet to use for WMTS requests.
  28. * @property {Array} [tileMatrixLabels] A list of identifiers in the TileMatrix to use for WMTS requests, one per TileMatrix level.
  29. * @property {Clock} [clock] A Clock instance that is used when determining the value for the time dimension. Required when `times` is specified.
  30. * @property {TimeIntervalCollection} [times] TimeIntervalCollection with its <code>data</code> property being an object containing time dynamic dimension and their values.
  31. * @property {Object} [dimensions] A object containing static dimensions and their values.
  32. * @property {Number} [tileWidth=256] The tile width in pixels.
  33. * @property {Number} [tileHeight=256] The tile height in pixels.
  34. * @property {TilingScheme} [tilingScheme] The tiling scheme corresponding to the organization of the tiles in the TileMatrixSet.
  35. * @property {Rectangle} [rectangle=Rectangle.MAX_VALUE] The rectangle covered by the layer.
  36. * @property {Number} [minimumLevel=0] The minimum level-of-detail supported by the imagery provider.
  37. * @property {Number} [maximumLevel] The maximum level-of-detail supported by the imagery provider, or undefined if there is no limit.
  38. * @property {Ellipsoid} [ellipsoid] The ellipsoid. If not specified, the WGS84 ellipsoid is used.
  39. * @property {Credit|String} [credit] A credit for the data source, which is displayed on the canvas.
  40. * @property {String|String[]} [subdomains='abc'] The subdomains to use for the <code>{s}</code> placeholder in the URL template.
  41. * If this parameter is a single string, each character in the string is a subdomain. If it is
  42. * an array, each element in the array is a subdomain.
  43. */
  44. /**
  45. * Provides tiled imagery served by {@link http://www.opengeospatial.org/standards/wmts|WMTS 1.0.0} compliant servers.
  46. * This provider supports HTTP KVP-encoded and RESTful GetTile requests, but does not yet support the SOAP encoding.
  47. *
  48. * @alias WebMapTileServiceImageryProvider
  49. * @constructor
  50. *
  51. * @param {WebMapTileServiceImageryProvider.ConstructorOptions} options Object describing initialization options
  52. *
  53. * @demo {@link https://sandcastle.cesium.com/index.html?src=Web%20Map%20Tile%20Service%20with%20Time.html|Cesium Sandcastle Web Map Tile Service with Time Demo}
  54. *
  55. * @example
  56. * // Example 1. USGS shaded relief tiles (KVP)
  57. * var shadedRelief1 = new Cesium.WebMapTileServiceImageryProvider({
  58. * url : 'http://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS',
  59. * layer : 'USGSShadedReliefOnly',
  60. * style : 'default',
  61. * format : 'image/jpeg',
  62. * tileMatrixSetID : 'default028mm',
  63. * // tileMatrixLabels : ['default028mm:0', 'default028mm:1', 'default028mm:2' ...],
  64. * maximumLevel: 19,
  65. * credit : new Cesium.Credit('U. S. Geological Survey')
  66. * });
  67. * viewer.imageryLayers.addImageryProvider(shadedRelief1);
  68. *
  69. * @example
  70. * // Example 2. USGS shaded relief tiles (RESTful)
  71. * var shadedRelief2 = new Cesium.WebMapTileServiceImageryProvider({
  72. * url : 'http://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS/tile/1.0.0/USGSShadedReliefOnly/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg',
  73. * layer : 'USGSShadedReliefOnly',
  74. * style : 'default',
  75. * format : 'image/jpeg',
  76. * tileMatrixSetID : 'default028mm',
  77. * maximumLevel: 19,
  78. * credit : new Cesium.Credit('U. S. Geological Survey')
  79. * });
  80. * viewer.imageryLayers.addImageryProvider(shadedRelief2);
  81. *
  82. * @example
  83. * // Example 3. NASA time dynamic weather data (RESTful)
  84. * var times = Cesium.TimeIntervalCollection.fromIso8601({
  85. * iso8601: '2015-07-30/2017-06-16/P1D',
  86. * dataCallback: function dataCallback(interval, index) {
  87. * return {
  88. * Time: Cesium.JulianDate.toIso8601(interval.start)
  89. * };
  90. * }
  91. * });
  92. * var weather = new Cesium.WebMapTileServiceImageryProvider({
  93. * url : 'https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/AMSR2_Snow_Water_Equivalent/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png',
  94. * layer : 'AMSR2_Snow_Water_Equivalent',
  95. * style : 'default',
  96. * tileMatrixSetID : '2km',
  97. * maximumLevel : 5,
  98. * format : 'image/png',
  99. * clock: clock,
  100. * times: times,
  101. * credit : new Cesium.Credit('NASA Global Imagery Browse Services for EOSDIS')
  102. * });
  103. * viewer.imageryLayers.addImageryProvider(weather);
  104. *
  105. * @see ArcGisMapServerImageryProvider
  106. * @see BingMapsImageryProvider
  107. * @see GoogleEarthEnterpriseMapsProvider
  108. * @see OpenStreetMapImageryProvider
  109. * @see SingleTileImageryProvider
  110. * @see TileMapServiceImageryProvider
  111. * @see WebMapServiceImageryProvider
  112. * @see UrlTemplateImageryProvider
  113. */
  114. function WebMapTileServiceImageryProvider(options) {
  115. options = defaultValue(options, defaultValue.EMPTY_OBJECT);
  116. //>>includeStart('debug', pragmas.debug);
  117. if (!defined(options.url)) {
  118. throw new DeveloperError("options.url is required.");
  119. }
  120. if (!defined(options.layer)) {
  121. throw new DeveloperError("options.layer is required.");
  122. }
  123. if (!defined(options.style)) {
  124. throw new DeveloperError("options.style is required.");
  125. }
  126. if (!defined(options.tileMatrixSetID)) {
  127. throw new DeveloperError("options.tileMatrixSetID is required.");
  128. }
  129. if (defined(options.times) && !defined(options.clock)) {
  130. throw new DeveloperError(
  131. "options.times was specified, so options.clock is required."
  132. );
  133. }
  134. //>>includeEnd('debug');
  135. /**
  136. * The default alpha blending value of this provider, with 0.0 representing fully transparent and
  137. * 1.0 representing fully opaque.
  138. *
  139. * @type {Number|undefined}
  140. * @default undefined
  141. */
  142. this.defaultAlpha = undefined;
  143. /**
  144. * The default alpha blending value on the night side of the globe of this provider, with 0.0 representing fully transparent and
  145. * 1.0 representing fully opaque.
  146. *
  147. * @type {Number|undefined}
  148. * @default undefined
  149. */
  150. this.defaultNightAlpha = undefined;
  151. /**
  152. * The default alpha blending value on the day side of the globe of this provider, with 0.0 representing fully transparent and
  153. * 1.0 representing fully opaque.
  154. *
  155. * @type {Number|undefined}
  156. * @default undefined
  157. */
  158. this.defaultDayAlpha = undefined;
  159. /**
  160. * The default brightness of this provider. 1.0 uses the unmodified imagery color. Less than 1.0
  161. * makes the imagery darker while greater than 1.0 makes it brighter.
  162. *
  163. * @type {Number|undefined}
  164. * @default undefined
  165. */
  166. this.defaultBrightness = undefined;
  167. /**
  168. * The default contrast of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces
  169. * the contrast while greater than 1.0 increases it.
  170. *
  171. * @type {Number|undefined}
  172. * @default undefined
  173. */
  174. this.defaultContrast = undefined;
  175. /**
  176. * The default hue of this provider in radians. 0.0 uses the unmodified imagery color.
  177. *
  178. * @type {Number|undefined}
  179. * @default undefined
  180. */
  181. this.defaultHue = undefined;
  182. /**
  183. * The default saturation of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces the
  184. * saturation while greater than 1.0 increases it.
  185. *
  186. * @type {Number|undefined}
  187. * @default undefined
  188. */
  189. this.defaultSaturation = undefined;
  190. /**
  191. * The default gamma correction to apply to this provider. 1.0 uses the unmodified imagery color.
  192. *
  193. * @type {Number|undefined}
  194. * @default undefined
  195. */
  196. this.defaultGamma = undefined;
  197. /**
  198. * The default texture minification filter to apply to this provider.
  199. *
  200. * @type {TextureMinificationFilter}
  201. * @default undefined
  202. */
  203. this.defaultMinificationFilter = undefined;
  204. /**
  205. * The default texture magnification filter to apply to this provider.
  206. *
  207. * @type {TextureMagnificationFilter}
  208. * @default undefined
  209. */
  210. this.defaultMagnificationFilter = undefined;
  211. var resource = Resource.createIfNeeded(options.url);
  212. var style = options.style;
  213. var tileMatrixSetID = options.tileMatrixSetID;
  214. var url = resource.url;
  215. if (url.indexOf("{") >= 0) {
  216. var templateValues = {
  217. style: style,
  218. Style: style,
  219. TileMatrixSet: tileMatrixSetID,
  220. };
  221. resource.setTemplateValues(templateValues);
  222. this._useKvp = false;
  223. } else {
  224. resource.setQueryParameters(defaultParameters);
  225. this._useKvp = true;
  226. }
  227. this._resource = resource;
  228. this._layer = options.layer;
  229. this._style = style;
  230. this._tileMatrixSetID = tileMatrixSetID;
  231. this._tileMatrixLabels = options.tileMatrixLabels;
  232. this._format = defaultValue(options.format, "image/jpeg");
  233. this._tileDiscardPolicy = options.tileDiscardPolicy;
  234. this._tilingScheme = defined(options.tilingScheme)
  235. ? options.tilingScheme
  236. : new WebMercatorTilingScheme({ ellipsoid: options.ellipsoid });
  237. this._tileWidth = defaultValue(options.tileWidth, 256);
  238. this._tileHeight = defaultValue(options.tileHeight, 256);
  239. this._minimumLevel = defaultValue(options.minimumLevel, 0);
  240. this._maximumLevel = options.maximumLevel;
  241. this._rectangle = defaultValue(
  242. options.rectangle,
  243. this._tilingScheme.rectangle
  244. );
  245. this._dimensions = options.dimensions;
  246. var that = this;
  247. this._reload = undefined;
  248. if (defined(options.times)) {
  249. this._timeDynamicImagery = new TimeDynamicImagery({
  250. clock: options.clock,
  251. times: options.times,
  252. requestImageFunction: function (x, y, level, request, interval) {
  253. return requestImage(that, x, y, level, request, interval);
  254. },
  255. reloadFunction: function () {
  256. if (defined(that._reload)) {
  257. that._reload();
  258. }
  259. },
  260. });
  261. }
  262. this._readyPromise = when.resolve(true);
  263. // Check the number of tiles at the minimum level. If it's more than four,
  264. // throw an exception, because starting at the higher minimum
  265. // level will cause too many tiles to be downloaded and rendered.
  266. var swTile = this._tilingScheme.positionToTileXY(
  267. Rectangle.southwest(this._rectangle),
  268. this._minimumLevel
  269. );
  270. var neTile = this._tilingScheme.positionToTileXY(
  271. Rectangle.northeast(this._rectangle),
  272. this._minimumLevel
  273. );
  274. var tileCount =
  275. (Math.abs(neTile.x - swTile.x) + 1) * (Math.abs(neTile.y - swTile.y) + 1);
  276. //>>includeStart('debug', pragmas.debug);
  277. if (tileCount > 4) {
  278. throw new DeveloperError(
  279. "The imagery provider's rectangle and minimumLevel indicate that there are " +
  280. tileCount +
  281. " tiles at the minimum level. Imagery providers with more than four tiles at the minimum level are not supported."
  282. );
  283. }
  284. //>>includeEnd('debug');
  285. this._errorEvent = new Event();
  286. var credit = options.credit;
  287. this._credit = typeof credit === "string" ? new Credit(credit) : credit;
  288. this._subdomains = options.subdomains;
  289. if (Array.isArray(this._subdomains)) {
  290. this._subdomains = this._subdomains.slice();
  291. } else if (defined(this._subdomains) && this._subdomains.length > 0) {
  292. this._subdomains = this._subdomains.split("");
  293. } else {
  294. this._subdomains = ["a", "b", "c"];
  295. }
  296. }
  297. function requestImage(imageryProvider, col, row, level, request, interval) {
  298. var labels = imageryProvider._tileMatrixLabels;
  299. var tileMatrix = defined(labels) ? labels[level] : level.toString();
  300. var subdomains = imageryProvider._subdomains;
  301. var staticDimensions = imageryProvider._dimensions;
  302. var dynamicIntervalData = defined(interval) ? interval.data : undefined;
  303. var resource;
  304. if (!imageryProvider._useKvp) {
  305. var templateValues = {
  306. TileMatrix: tileMatrix,
  307. TileRow: row.toString(),
  308. TileCol: col.toString(),
  309. s: subdomains[(col + row + level) % subdomains.length],
  310. };
  311. resource = imageryProvider._resource.getDerivedResource({
  312. request: request,
  313. });
  314. resource.setTemplateValues(templateValues);
  315. if (defined(staticDimensions)) {
  316. resource.setTemplateValues(staticDimensions);
  317. }
  318. if (defined(dynamicIntervalData)) {
  319. resource.setTemplateValues(dynamicIntervalData);
  320. }
  321. } else {
  322. // build KVP request
  323. var query = {};
  324. query.tilematrix = tileMatrix;
  325. query.layer = imageryProvider._layer;
  326. query.style = imageryProvider._style;
  327. query.tilerow = row;
  328. query.tilecol = col;
  329. query.tilematrixset = imageryProvider._tileMatrixSetID;
  330. query.format = imageryProvider._format;
  331. if (defined(staticDimensions)) {
  332. query = combine(query, staticDimensions);
  333. }
  334. if (defined(dynamicIntervalData)) {
  335. query = combine(query, dynamicIntervalData);
  336. }
  337. resource = imageryProvider._resource.getDerivedResource({
  338. queryParameters: query,
  339. request: request,
  340. });
  341. }
  342. return ImageryProvider.loadImage(imageryProvider, resource);
  343. }
  344. Object.defineProperties(WebMapTileServiceImageryProvider.prototype, {
  345. /**
  346. * Gets the URL of the service hosting the imagery.
  347. * @memberof WebMapTileServiceImageryProvider.prototype
  348. * @type {String}
  349. * @readonly
  350. */
  351. url: {
  352. get: function () {
  353. return this._resource.url;
  354. },
  355. },
  356. /**
  357. * Gets the proxy used by this provider.
  358. * @memberof WebMapTileServiceImageryProvider.prototype
  359. * @type {Proxy}
  360. * @readonly
  361. */
  362. proxy: {
  363. get: function () {
  364. return this._resource.proxy;
  365. },
  366. },
  367. /**
  368. * Gets the width of each tile, in pixels. This function should
  369. * not be called before {@link WebMapTileServiceImageryProvider#ready} returns true.
  370. * @memberof WebMapTileServiceImageryProvider.prototype
  371. * @type {Number}
  372. * @readonly
  373. */
  374. tileWidth: {
  375. get: function () {
  376. return this._tileWidth;
  377. },
  378. },
  379. /**
  380. * Gets the height of each tile, in pixels. This function should
  381. * not be called before {@link WebMapTileServiceImageryProvider#ready} returns true.
  382. * @memberof WebMapTileServiceImageryProvider.prototype
  383. * @type {Number}
  384. * @readonly
  385. */
  386. tileHeight: {
  387. get: function () {
  388. return this._tileHeight;
  389. },
  390. },
  391. /**
  392. * Gets the maximum level-of-detail that can be requested. This function should
  393. * not be called before {@link WebMapTileServiceImageryProvider#ready} returns true.
  394. * @memberof WebMapTileServiceImageryProvider.prototype
  395. * @type {Number|undefined}
  396. * @readonly
  397. */
  398. maximumLevel: {
  399. get: function () {
  400. return this._maximumLevel;
  401. },
  402. },
  403. /**
  404. * Gets the minimum level-of-detail that can be requested. This function should
  405. * not be called before {@link WebMapTileServiceImageryProvider#ready} returns true.
  406. * @memberof WebMapTileServiceImageryProvider.prototype
  407. * @type {Number}
  408. * @readonly
  409. */
  410. minimumLevel: {
  411. get: function () {
  412. return this._minimumLevel;
  413. },
  414. },
  415. /**
  416. * Gets the tiling scheme used by this provider. This function should
  417. * not be called before {@link WebMapTileServiceImageryProvider#ready} returns true.
  418. * @memberof WebMapTileServiceImageryProvider.prototype
  419. * @type {TilingScheme}
  420. * @readonly
  421. */
  422. tilingScheme: {
  423. get: function () {
  424. return this._tilingScheme;
  425. },
  426. },
  427. /**
  428. * Gets the rectangle, in radians, of the imagery provided by this instance. This function should
  429. * not be called before {@link WebMapTileServiceImageryProvider#ready} returns true.
  430. * @memberof WebMapTileServiceImageryProvider.prototype
  431. * @type {Rectangle}
  432. * @readonly
  433. */
  434. rectangle: {
  435. get: function () {
  436. return this._rectangle;
  437. },
  438. },
  439. /**
  440. * Gets the tile discard policy. If not undefined, the discard policy is responsible
  441. * for filtering out "missing" tiles via its shouldDiscardImage function. If this function
  442. * returns undefined, no tiles are filtered. This function should
  443. * not be called before {@link WebMapTileServiceImageryProvider#ready} returns true.
  444. * @memberof WebMapTileServiceImageryProvider.prototype
  445. * @type {TileDiscardPolicy}
  446. * @readonly
  447. */
  448. tileDiscardPolicy: {
  449. get: function () {
  450. return this._tileDiscardPolicy;
  451. },
  452. },
  453. /**
  454. * Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
  455. * to the event, you will be notified of the error and can potentially recover from it. Event listeners
  456. * are passed an instance of {@link TileProviderError}.
  457. * @memberof WebMapTileServiceImageryProvider.prototype
  458. * @type {Event}
  459. * @readonly
  460. */
  461. errorEvent: {
  462. get: function () {
  463. return this._errorEvent;
  464. },
  465. },
  466. /**
  467. * Gets the mime type of images returned by this imagery provider.
  468. * @memberof WebMapTileServiceImageryProvider.prototype
  469. * @type {String}
  470. * @readonly
  471. */
  472. format: {
  473. get: function () {
  474. return this._format;
  475. },
  476. },
  477. /**
  478. * Gets a value indicating whether or not the provider is ready for use.
  479. * @memberof WebMapTileServiceImageryProvider.prototype
  480. * @type {Boolean}
  481. * @readonly
  482. */
  483. ready: {
  484. value: true,
  485. },
  486. /**
  487. * Gets a promise that resolves to true when the provider is ready for use.
  488. * @memberof WebMapTileServiceImageryProvider.prototype
  489. * @type {Promise.<Boolean>}
  490. * @readonly
  491. */
  492. readyPromise: {
  493. get: function () {
  494. return this._readyPromise;
  495. },
  496. },
  497. /**
  498. * Gets the credit to display when this imagery provider is active. Typically this is used to credit
  499. * the source of the imagery. This function should not be called before {@link WebMapTileServiceImageryProvider#ready} returns true.
  500. * @memberof WebMapTileServiceImageryProvider.prototype
  501. * @type {Credit}
  502. * @readonly
  503. */
  504. credit: {
  505. get: function () {
  506. return this._credit;
  507. },
  508. },
  509. /**
  510. * Gets a value indicating whether or not the images provided by this imagery provider
  511. * include an alpha channel. If this property is false, an alpha channel, if present, will
  512. * be ignored. If this property is true, any images without an alpha channel will be treated
  513. * as if their alpha is 1.0 everywhere. When this property is false, memory usage
  514. * and texture upload time are reduced.
  515. * @memberof WebMapTileServiceImageryProvider.prototype
  516. * @type {Boolean}
  517. * @readonly
  518. */
  519. hasAlphaChannel: {
  520. get: function () {
  521. return true;
  522. },
  523. },
  524. /**
  525. * Gets or sets a clock that is used to get keep the time used for time dynamic parameters.
  526. * @memberof WebMapTileServiceImageryProvider.prototype
  527. * @type {Clock}
  528. */
  529. clock: {
  530. get: function () {
  531. return this._timeDynamicImagery.clock;
  532. },
  533. set: function (value) {
  534. this._timeDynamicImagery.clock = value;
  535. },
  536. },
  537. /**
  538. * Gets or sets a time interval collection that is used to get time dynamic parameters. The data of each
  539. * TimeInterval is an object containing the keys and values of the properties that are used during
  540. * tile requests.
  541. * @memberof WebMapTileServiceImageryProvider.prototype
  542. * @type {TimeIntervalCollection}
  543. */
  544. times: {
  545. get: function () {
  546. return this._timeDynamicImagery.times;
  547. },
  548. set: function (value) {
  549. this._timeDynamicImagery.times = value;
  550. },
  551. },
  552. /**
  553. * Gets or sets an object that contains static dimensions and their values.
  554. * @memberof WebMapTileServiceImageryProvider.prototype
  555. * @type {Object}
  556. */
  557. dimensions: {
  558. get: function () {
  559. return this._dimensions;
  560. },
  561. set: function (value) {
  562. if (this._dimensions !== value) {
  563. this._dimensions = value;
  564. if (defined(this._reload)) {
  565. this._reload();
  566. }
  567. }
  568. },
  569. },
  570. });
  571. /**
  572. * Gets the credits to be displayed when a given tile is displayed.
  573. *
  574. * @param {Number} x The tile X coordinate.
  575. * @param {Number} y The tile Y coordinate.
  576. * @param {Number} level The tile level;
  577. * @returns {Credit[]} The credits to be displayed when the tile is displayed.
  578. *
  579. * @exception {DeveloperError} <code>getTileCredits</code> must not be called before the imagery provider is ready.
  580. */
  581. WebMapTileServiceImageryProvider.prototype.getTileCredits = function (
  582. x,
  583. y,
  584. level
  585. ) {
  586. return undefined;
  587. };
  588. /**
  589. * Requests the image for a given tile. This function should
  590. * not be called before {@link WebMapTileServiceImageryProvider#ready} returns true.
  591. *
  592. * @param {Number} x The tile X coordinate.
  593. * @param {Number} y The tile Y coordinate.
  594. * @param {Number} level The tile level.
  595. * @param {Request} [request] The request object. Intended for internal use only.
  596. * @returns {Promise.<HTMLImageElement|HTMLCanvasElement>|undefined} A promise for the image that will resolve when the image is available, or
  597. * undefined if there are too many active requests to the server, and the request
  598. * should be retried later. The resolved image may be either an
  599. * Image or a Canvas DOM object.
  600. *
  601. * @exception {DeveloperError} <code>requestImage</code> must not be called before the imagery provider is ready.
  602. */
  603. WebMapTileServiceImageryProvider.prototype.requestImage = function (
  604. x,
  605. y,
  606. level,
  607. request
  608. ) {
  609. var result;
  610. var timeDynamicImagery = this._timeDynamicImagery;
  611. var currentInterval;
  612. // Try and load from cache
  613. if (defined(timeDynamicImagery)) {
  614. currentInterval = timeDynamicImagery.currentInterval;
  615. result = timeDynamicImagery.getFromCache(x, y, level, request);
  616. }
  617. // Couldn't load from cache
  618. if (!defined(result)) {
  619. result = requestImage(this, x, y, level, request, currentInterval);
  620. }
  621. // If we are approaching an interval, preload this tile in the next interval
  622. if (defined(result) && defined(timeDynamicImagery)) {
  623. timeDynamicImagery.checkApproachingInterval(x, y, level, request);
  624. }
  625. return result;
  626. };
  627. /**
  628. * Picking features is not currently supported by this imagery provider, so this function simply returns
  629. * undefined.
  630. *
  631. * @param {Number} x The tile X coordinate.
  632. * @param {Number} y The tile Y coordinate.
  633. * @param {Number} level The tile level.
  634. * @param {Number} longitude The longitude at which to pick features.
  635. * @param {Number} latitude The latitude at which to pick features.
  636. * @return {Promise.<ImageryLayerFeatureInfo[]>|undefined} A promise for the picked features that will resolve when the asynchronous
  637. * picking completes. The resolved value is an array of {@link ImageryLayerFeatureInfo}
  638. * instances. The array may be empty if no features are found at the given location.
  639. * It may also be undefined if picking is not supported.
  640. */
  641. WebMapTileServiceImageryProvider.prototype.pickFeatures = function (
  642. x,
  643. y,
  644. level,
  645. longitude,
  646. latitude
  647. ) {
  648. return undefined;
  649. };
  650. export default WebMapTileServiceImageryProvider;