WebMapTileServiceImageryProvider.js 23 KB

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