WebMapTileServiceImageryProvider.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  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 deprecationWarning from "../Core/deprecationWarning.js";
  6. import DeveloperError from "../Core/DeveloperError.js";
  7. import Event from "../Core/Event.js";
  8. import Rectangle from "../Core/Rectangle.js";
  9. import Resource from "../Core/Resource.js";
  10. import WebMercatorTilingScheme from "../Core/WebMercatorTilingScheme.js";
  11. import ImageryProvider from "./ImageryProvider.js";
  12. import TimeDynamicImagery from "./TimeDynamicImagery.js";
  13. const 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. * const 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. * const 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. * const 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. * const 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. this._defaultAlpha = undefined;
  136. this._defaultNightAlpha = undefined;
  137. this._defaultDayAlpha = undefined;
  138. this._defaultBrightness = undefined;
  139. this._defaultContrast = undefined;
  140. this._defaultHue = undefined;
  141. this._defaultSaturation = undefined;
  142. this._defaultGamma = undefined;
  143. this._defaultMinificationFilter = undefined;
  144. this._defaultMagnificationFilter = undefined;
  145. const resource = Resource.createIfNeeded(options.url);
  146. const style = options.style;
  147. const tileMatrixSetID = options.tileMatrixSetID;
  148. const url = resource.url;
  149. const bracketMatch = url.match(/{/g);
  150. if (
  151. !defined(bracketMatch) ||
  152. (bracketMatch.length === 1 && /{s}/.test(url))
  153. ) {
  154. resource.setQueryParameters(defaultParameters);
  155. this._useKvp = true;
  156. } else {
  157. const templateValues = {
  158. style: style,
  159. Style: style,
  160. TileMatrixSet: tileMatrixSetID,
  161. };
  162. resource.setTemplateValues(templateValues);
  163. this._useKvp = false;
  164. }
  165. this._resource = resource;
  166. this._layer = options.layer;
  167. this._style = style;
  168. this._tileMatrixSetID = tileMatrixSetID;
  169. this._tileMatrixLabels = options.tileMatrixLabels;
  170. this._format = defaultValue(options.format, "image/jpeg");
  171. this._tileDiscardPolicy = options.tileDiscardPolicy;
  172. this._tilingScheme = defined(options.tilingScheme)
  173. ? options.tilingScheme
  174. : new WebMercatorTilingScheme({ ellipsoid: options.ellipsoid });
  175. this._tileWidth = defaultValue(options.tileWidth, 256);
  176. this._tileHeight = defaultValue(options.tileHeight, 256);
  177. this._minimumLevel = defaultValue(options.minimumLevel, 0);
  178. this._maximumLevel = options.maximumLevel;
  179. this._rectangle = defaultValue(
  180. options.rectangle,
  181. this._tilingScheme.rectangle
  182. );
  183. this._dimensions = options.dimensions;
  184. const that = this;
  185. this._reload = undefined;
  186. if (defined(options.times)) {
  187. this._timeDynamicImagery = new TimeDynamicImagery({
  188. clock: options.clock,
  189. times: options.times,
  190. requestImageFunction: function (x, y, level, request, interval) {
  191. return requestImage(that, x, y, level, request, interval);
  192. },
  193. reloadFunction: function () {
  194. if (defined(that._reload)) {
  195. that._reload();
  196. }
  197. },
  198. });
  199. }
  200. this._readyPromise = Promise.resolve(true);
  201. this._ready = true;
  202. // Check the number of tiles at the minimum level. If it's more than four,
  203. // throw an exception, because starting at the higher minimum
  204. // level will cause too many tiles to be downloaded and rendered.
  205. const swTile = this._tilingScheme.positionToTileXY(
  206. Rectangle.southwest(this._rectangle),
  207. this._minimumLevel
  208. );
  209. const neTile = this._tilingScheme.positionToTileXY(
  210. Rectangle.northeast(this._rectangle),
  211. this._minimumLevel
  212. );
  213. const tileCount =
  214. (Math.abs(neTile.x - swTile.x) + 1) * (Math.abs(neTile.y - swTile.y) + 1);
  215. //>>includeStart('debug', pragmas.debug);
  216. if (tileCount > 4) {
  217. throw new DeveloperError(
  218. `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.`
  219. );
  220. }
  221. //>>includeEnd('debug');
  222. this._errorEvent = new Event();
  223. const credit = options.credit;
  224. this._credit = typeof credit === "string" ? new Credit(credit) : credit;
  225. this._subdomains = options.subdomains;
  226. if (Array.isArray(this._subdomains)) {
  227. this._subdomains = this._subdomains.slice();
  228. } else if (defined(this._subdomains) && this._subdomains.length > 0) {
  229. this._subdomains = this._subdomains.split("");
  230. } else {
  231. this._subdomains = ["a", "b", "c"];
  232. }
  233. }
  234. function requestImage(imageryProvider, col, row, level, request, interval) {
  235. const labels = imageryProvider._tileMatrixLabels;
  236. const tileMatrix = defined(labels) ? labels[level] : level.toString();
  237. const subdomains = imageryProvider._subdomains;
  238. const staticDimensions = imageryProvider._dimensions;
  239. const dynamicIntervalData = defined(interval) ? interval.data : undefined;
  240. let resource;
  241. let templateValues;
  242. if (!imageryProvider._useKvp) {
  243. templateValues = {
  244. TileMatrix: tileMatrix,
  245. TileRow: row.toString(),
  246. TileCol: col.toString(),
  247. s: subdomains[(col + row + level) % subdomains.length],
  248. };
  249. resource = imageryProvider._resource.getDerivedResource({
  250. request: request,
  251. });
  252. resource.setTemplateValues(templateValues);
  253. if (defined(staticDimensions)) {
  254. resource.setTemplateValues(staticDimensions);
  255. }
  256. if (defined(dynamicIntervalData)) {
  257. resource.setTemplateValues(dynamicIntervalData);
  258. }
  259. } else {
  260. // build KVP request
  261. let query = {};
  262. query.tilematrix = tileMatrix;
  263. query.layer = imageryProvider._layer;
  264. query.style = imageryProvider._style;
  265. query.tilerow = row;
  266. query.tilecol = col;
  267. query.tilematrixset = imageryProvider._tileMatrixSetID;
  268. query.format = imageryProvider._format;
  269. if (defined(staticDimensions)) {
  270. query = combine(query, staticDimensions);
  271. }
  272. if (defined(dynamicIntervalData)) {
  273. query = combine(query, dynamicIntervalData);
  274. }
  275. templateValues = {
  276. s: subdomains[(col + row + level) % subdomains.length],
  277. };
  278. resource = imageryProvider._resource.getDerivedResource({
  279. queryParameters: query,
  280. request: request,
  281. });
  282. resource.setTemplateValues(templateValues);
  283. }
  284. return ImageryProvider.loadImage(imageryProvider, resource);
  285. }
  286. Object.defineProperties(WebMapTileServiceImageryProvider.prototype, {
  287. /**
  288. * Gets the URL of the service hosting the imagery.
  289. * @memberof WebMapTileServiceImageryProvider.prototype
  290. * @type {string}
  291. * @readonly
  292. */
  293. url: {
  294. get: function () {
  295. return this._resource.url;
  296. },
  297. },
  298. /**
  299. * Gets the proxy used by this provider.
  300. * @memberof WebMapTileServiceImageryProvider.prototype
  301. * @type {Proxy}
  302. * @readonly
  303. */
  304. proxy: {
  305. get: function () {
  306. return this._resource.proxy;
  307. },
  308. },
  309. /**
  310. * Gets the width of each tile, in pixels.
  311. * @memberof WebMapTileServiceImageryProvider.prototype
  312. * @type {number}
  313. * @readonly
  314. */
  315. tileWidth: {
  316. get: function () {
  317. return this._tileWidth;
  318. },
  319. },
  320. /**
  321. * Gets the height of each tile, in pixels.
  322. * @memberof WebMapTileServiceImageryProvider.prototype
  323. * @type {number}
  324. * @readonly
  325. */
  326. tileHeight: {
  327. get: function () {
  328. return this._tileHeight;
  329. },
  330. },
  331. /**
  332. * Gets the maximum level-of-detail that can be requested.
  333. * @memberof WebMapTileServiceImageryProvider.prototype
  334. * @type {number|undefined}
  335. * @readonly
  336. */
  337. maximumLevel: {
  338. get: function () {
  339. return this._maximumLevel;
  340. },
  341. },
  342. /**
  343. * Gets the minimum level-of-detail that can be requested.
  344. * @memberof WebMapTileServiceImageryProvider.prototype
  345. * @type {number}
  346. * @readonly
  347. */
  348. minimumLevel: {
  349. get: function () {
  350. return this._minimumLevel;
  351. },
  352. },
  353. /**
  354. * Gets the tiling scheme used by this provider.
  355. * @memberof WebMapTileServiceImageryProvider.prototype
  356. * @type {TilingScheme}
  357. * @readonly
  358. */
  359. tilingScheme: {
  360. get: function () {
  361. return this._tilingScheme;
  362. },
  363. },
  364. /**
  365. * Gets the rectangle, in radians, of the imagery provided by this instance.
  366. * @memberof WebMapTileServiceImageryProvider.prototype
  367. * @type {Rectangle}
  368. * @readonly
  369. */
  370. rectangle: {
  371. get: function () {
  372. return this._rectangle;
  373. },
  374. },
  375. /**
  376. * Gets the tile discard policy. If not undefined, the discard policy is responsible
  377. * for filtering out "missing" tiles via its shouldDiscardImage function. If this function
  378. * returns undefined, no tiles are filtered.
  379. * @memberof WebMapTileServiceImageryProvider.prototype
  380. * @type {TileDiscardPolicy}
  381. * @readonly
  382. */
  383. tileDiscardPolicy: {
  384. get: function () {
  385. return this._tileDiscardPolicy;
  386. },
  387. },
  388. /**
  389. * Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
  390. * to the event, you will be notified of the error and can potentially recover from it. Event listeners
  391. * are passed an instance of {@link TileProviderError}.
  392. * @memberof WebMapTileServiceImageryProvider.prototype
  393. * @type {Event}
  394. * @readonly
  395. */
  396. errorEvent: {
  397. get: function () {
  398. return this._errorEvent;
  399. },
  400. },
  401. /**
  402. * Gets the mime type of images returned by this imagery provider.
  403. * @memberof WebMapTileServiceImageryProvider.prototype
  404. * @type {string}
  405. * @readonly
  406. */
  407. format: {
  408. get: function () {
  409. return this._format;
  410. },
  411. },
  412. /**
  413. * Gets a value indicating whether or not the provider is ready for use.
  414. * @memberof WebMapTileServiceImageryProvider.prototype
  415. * @type {boolean}
  416. * @readonly
  417. * @deprecated
  418. */
  419. ready: {
  420. get: function () {
  421. deprecationWarning(
  422. "WebMapTileServiceImageryProvider.ready",
  423. "WebMapTileServiceImageryProvider.ready was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107."
  424. );
  425. return true;
  426. },
  427. },
  428. /**
  429. * Gets a promise that resolves to true when the provider is ready for use.
  430. * @memberof WebMapTileServiceImageryProvider.prototype
  431. * @type {Promise<boolean>}
  432. * @readonly
  433. * @deprecated
  434. */
  435. readyPromise: {
  436. get: function () {
  437. deprecationWarning(
  438. "WebMapTileServiceImageryProvider.readyPromise",
  439. "WebMapTileServiceImageryProvider.readyPromise was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107."
  440. );
  441. return this._readyPromise;
  442. },
  443. },
  444. /**
  445. * Gets the credit to display when this imagery provider is active. Typically this is used to credit
  446. * the source of the imagery.
  447. * @memberof WebMapTileServiceImageryProvider.prototype
  448. * @type {Credit}
  449. * @readonly
  450. */
  451. credit: {
  452. get: function () {
  453. return this._credit;
  454. },
  455. },
  456. /**
  457. * Gets a value indicating whether or not the images provided by this imagery provider
  458. * include an alpha channel. If this property is false, an alpha channel, if present, will
  459. * be ignored. If this property is true, any images without an alpha channel will be treated
  460. * as if their alpha is 1.0 everywhere. When this property is false, memory usage
  461. * and texture upload time are reduced.
  462. * @memberof WebMapTileServiceImageryProvider.prototype
  463. * @type {boolean}
  464. * @readonly
  465. */
  466. hasAlphaChannel: {
  467. get: function () {
  468. return true;
  469. },
  470. },
  471. /**
  472. * Gets or sets a clock that is used to get keep the time used for time dynamic parameters.
  473. * @memberof WebMapTileServiceImageryProvider.prototype
  474. * @type {Clock}
  475. */
  476. clock: {
  477. get: function () {
  478. return this._timeDynamicImagery.clock;
  479. },
  480. set: function (value) {
  481. this._timeDynamicImagery.clock = value;
  482. },
  483. },
  484. /**
  485. * Gets or sets a time interval collection that is used to get time dynamic parameters. The data of each
  486. * TimeInterval is an object containing the keys and values of the properties that are used during
  487. * tile requests.
  488. * @memberof WebMapTileServiceImageryProvider.prototype
  489. * @type {TimeIntervalCollection}
  490. */
  491. times: {
  492. get: function () {
  493. return this._timeDynamicImagery.times;
  494. },
  495. set: function (value) {
  496. this._timeDynamicImagery.times = value;
  497. },
  498. },
  499. /**
  500. * Gets or sets an object that contains static dimensions and their values.
  501. * @memberof WebMapTileServiceImageryProvider.prototype
  502. * @type {object}
  503. */
  504. dimensions: {
  505. get: function () {
  506. return this._dimensions;
  507. },
  508. set: function (value) {
  509. if (this._dimensions !== value) {
  510. this._dimensions = value;
  511. if (defined(this._reload)) {
  512. this._reload();
  513. }
  514. }
  515. },
  516. },
  517. /**
  518. * The default alpha blending value of this provider, with 0.0 representing fully transparent and
  519. * 1.0 representing fully opaque.
  520. * @memberof WebMapTileServiceImageryProvider.prototype
  521. * @type {Number|undefined}
  522. * @deprecated
  523. */
  524. defaultAlpha: {
  525. get: function () {
  526. deprecationWarning(
  527. "WebMapTileServiceImageryProvider.defaultAlpha",
  528. "WebMapTileServiceImageryProvider.defaultAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.alpha instead."
  529. );
  530. return this._defaultAlpha;
  531. },
  532. set: function (value) {
  533. deprecationWarning(
  534. "WebMapTileServiceImageryProvider.defaultAlpha",
  535. "WebMapTileServiceImageryProvider.defaultAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.alpha instead."
  536. );
  537. this._defaultAlpha = value;
  538. },
  539. },
  540. /**
  541. * The default alpha blending value on the night side of the globe of this provider, with 0.0 representing fully transparent and
  542. * 1.0 representing fully opaque.
  543. * @memberof WebMapTileServiceImageryProvider.prototype
  544. * @type {Number|undefined}
  545. * @deprecated
  546. */
  547. defaultNightAlpha: {
  548. get: function () {
  549. deprecationWarning(
  550. "WebMapTileServiceImageryProvider.defaultNightAlpha",
  551. "WebMapTileServiceImageryProvider.defaultNightAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.nightAlpha instead."
  552. );
  553. return this._defaultNightAlpha;
  554. },
  555. set: function (value) {
  556. deprecationWarning(
  557. "WebMapTileServiceImageryProvider.defaultNightAlpha",
  558. "WebMapTileServiceImageryProvider.defaultNightAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.nightAlpha instead."
  559. );
  560. this._defaultNightAlpha = value;
  561. },
  562. },
  563. /**
  564. * The default alpha blending value on the day side of the globe of this provider, with 0.0 representing fully transparent and
  565. * 1.0 representing fully opaque.
  566. * @memberof WebMapTileServiceImageryProvider.prototype
  567. * @type {Number|undefined}
  568. * @deprecated
  569. */
  570. defaultDayAlpha: {
  571. get: function () {
  572. deprecationWarning(
  573. "WebMapTileServiceImageryProvider.defaultDayAlpha",
  574. "WebMapTileServiceImageryProvider.defaultDayAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.dayAlpha instead."
  575. );
  576. return this._defaultDayAlpha;
  577. },
  578. set: function (value) {
  579. deprecationWarning(
  580. "WebMapTileServiceImageryProvider.defaultDayAlpha",
  581. "WebMapTileServiceImageryProvider.defaultDayAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.dayAlpha instead."
  582. );
  583. this._defaultDayAlpha = value;
  584. },
  585. },
  586. /**
  587. * The default brightness of this provider. 1.0 uses the unmodified imagery color. Less than 1.0
  588. * makes the imagery darker while greater than 1.0 makes it brighter.
  589. * @memberof WebMapTileServiceImageryProvider.prototype
  590. * @type {Number|undefined}
  591. * @deprecated
  592. */
  593. defaultBrightness: {
  594. get: function () {
  595. deprecationWarning(
  596. "WebMapTileServiceImageryProvider.defaultBrightness",
  597. "WebMapTileServiceImageryProvider.defaultBrightness was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.brightness instead."
  598. );
  599. return this._defaultBrightness;
  600. },
  601. set: function (value) {
  602. deprecationWarning(
  603. "WebMapTileServiceImageryProvider.defaultBrightness",
  604. "WebMapTileServiceImageryProvider.defaultBrightness was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.brightness instead."
  605. );
  606. this._defaultBrightness = value;
  607. },
  608. },
  609. /**
  610. * The default contrast of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces
  611. * the contrast while greater than 1.0 increases it.
  612. * @memberof WebMapTileServiceImageryProvider.prototype
  613. * @type {Number|undefined}
  614. * @deprecated
  615. */
  616. defaultContrast: {
  617. get: function () {
  618. deprecationWarning(
  619. "WebMapTileServiceImageryProvider.defaultContrast",
  620. "WebMapTileServiceImageryProvider.defaultContrast was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.contrast instead."
  621. );
  622. return this._defaultContrast;
  623. },
  624. set: function (value) {
  625. deprecationWarning(
  626. "WebMapTileServiceImageryProvider.defaultContrast",
  627. "WebMapTileServiceImageryProvider.defaultContrast was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.contrast instead."
  628. );
  629. this._defaultContrast = value;
  630. },
  631. },
  632. /**
  633. * The default hue of this provider in radians. 0.0 uses the unmodified imagery color.
  634. * @memberof WebMapTileServiceImageryProvider.prototype
  635. * @type {Number|undefined}
  636. * @deprecated
  637. */
  638. defaultHue: {
  639. get: function () {
  640. deprecationWarning(
  641. "WebMapTileServiceImageryProvider.defaultHue",
  642. "WebMapTileServiceImageryProvider.defaultHue was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.hue instead."
  643. );
  644. return this._defaultHue;
  645. },
  646. set: function (value) {
  647. deprecationWarning(
  648. "WebMapTileServiceImageryProvider.defaultHue",
  649. "WebMapTileServiceImageryProvider.defaultHue was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.hue instead."
  650. );
  651. this._defaultHue = value;
  652. },
  653. },
  654. /**
  655. * The default saturation of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces the
  656. * saturation while greater than 1.0 increases it.
  657. * @memberof WebMapTileServiceImageryProvider.prototype
  658. * @type {Number|undefined}
  659. * @deprecated
  660. */
  661. defaultSaturation: {
  662. get: function () {
  663. deprecationWarning(
  664. "WebMapTileServiceImageryProvider.defaultSaturation",
  665. "WebMapTileServiceImageryProvider.defaultSaturation was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.saturation instead."
  666. );
  667. return this._defaultSaturation;
  668. },
  669. set: function (value) {
  670. deprecationWarning(
  671. "WebMapTileServiceImageryProvider.defaultSaturation",
  672. "WebMapTileServiceImageryProvider.defaultSaturation was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.saturation instead."
  673. );
  674. this._defaultSaturation = value;
  675. },
  676. },
  677. /**
  678. * The default gamma correction to apply to this provider. 1.0 uses the unmodified imagery color.
  679. * @memberof WebMapTileServiceImageryProvider.prototype
  680. * @type {Number|undefined}
  681. * @deprecated
  682. */
  683. defaultGamma: {
  684. get: function () {
  685. deprecationWarning(
  686. "WebMapTileServiceImageryProvider.defaultGamma",
  687. "WebMapTileServiceImageryProvider.defaultGamma was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.gamma instead."
  688. );
  689. return this._defaultGamma;
  690. },
  691. set: function (value) {
  692. deprecationWarning(
  693. "WebMapTileServiceImageryProvider.defaultGamma",
  694. "WebMapTileServiceImageryProvider.defaultGamma was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.gamma instead."
  695. );
  696. this._defaultGamma = value;
  697. },
  698. },
  699. /**
  700. * The default texture minification filter to apply to this provider.
  701. * @memberof WebMapTileServiceImageryProvider.prototype
  702. * @type {TextureMinificationFilter}
  703. * @deprecated
  704. */
  705. defaultMinificationFilter: {
  706. get: function () {
  707. deprecationWarning(
  708. "WebMapTileServiceImageryProvider.defaultMinificationFilter",
  709. "WebMapTileServiceImageryProvider.defaultMinificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.minificationFilter instead."
  710. );
  711. return this._defaultMinificationFilter;
  712. },
  713. set: function (value) {
  714. deprecationWarning(
  715. "WebMapTileServiceImageryProvider.defaultMinificationFilter",
  716. "WebMapTileServiceImageryProvider.defaultMinificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.minificationFilter instead."
  717. );
  718. this._defaultMinificationFilter = value;
  719. },
  720. },
  721. /**
  722. * The default texture magnification filter to apply to this provider.
  723. * @memberof WebMapTileServiceImageryProvider.prototype
  724. * @type {TextureMagnificationFilter}
  725. * @deprecated
  726. */
  727. defaultMagnificationFilter: {
  728. get: function () {
  729. deprecationWarning(
  730. "WebMapTileServiceImageryProvider.defaultMagnificationFilter",
  731. "WebMapTileServiceImageryProvider.defaultMagnificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.magnificationFilter instead."
  732. );
  733. return this._defaultMagnificationFilter;
  734. },
  735. set: function (value) {
  736. deprecationWarning(
  737. "WebMapTileServiceImageryProvider.defaultMagnificationFilter",
  738. "WebMapTileServiceImageryProvider.defaultMagnificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.magnificationFilter instead."
  739. );
  740. this._defaultMagnificationFilter = value;
  741. },
  742. },
  743. });
  744. /**
  745. * Gets the credits to be displayed when a given tile is displayed.
  746. *
  747. * @param {number} x The tile X coordinate.
  748. * @param {number} y The tile Y coordinate.
  749. * @param {number} level The tile level;
  750. * @returns {Credit[]} The credits to be displayed when the tile is displayed.
  751. */
  752. WebMapTileServiceImageryProvider.prototype.getTileCredits = function (
  753. x,
  754. y,
  755. level
  756. ) {
  757. return undefined;
  758. };
  759. /**
  760. * Requests the image for a given tile.
  761. *
  762. * @param {number} x The tile X coordinate.
  763. * @param {number} y The tile Y coordinate.
  764. * @param {number} level The tile level.
  765. * @param {Request} [request] The request object. Intended for internal use only.
  766. * @returns {Promise<ImageryTypes>|undefined} A promise for the image that will resolve when the image is available, or
  767. * undefined if there are too many active requests to the server, and the request should be retried later.
  768. */
  769. WebMapTileServiceImageryProvider.prototype.requestImage = function (
  770. x,
  771. y,
  772. level,
  773. request
  774. ) {
  775. let result;
  776. const timeDynamicImagery = this._timeDynamicImagery;
  777. let currentInterval;
  778. // Try and load from cache
  779. if (defined(timeDynamicImagery)) {
  780. currentInterval = timeDynamicImagery.currentInterval;
  781. result = timeDynamicImagery.getFromCache(x, y, level, request);
  782. }
  783. // Couldn't load from cache
  784. if (!defined(result)) {
  785. result = requestImage(this, x, y, level, request, currentInterval);
  786. }
  787. // If we are approaching an interval, preload this tile in the next interval
  788. if (defined(result) && defined(timeDynamicImagery)) {
  789. timeDynamicImagery.checkApproachingInterval(x, y, level, request);
  790. }
  791. return result;
  792. };
  793. /**
  794. * Picking features is not currently supported by this imagery provider, so this function simply returns
  795. * undefined.
  796. *
  797. * @param {number} x The tile X coordinate.
  798. * @param {number} y The tile Y coordinate.
  799. * @param {number} level The tile level.
  800. * @param {number} longitude The longitude at which to pick features.
  801. * @param {number} latitude The latitude at which to pick features.
  802. * @return {undefined} Undefined since picking is not supported.
  803. */
  804. WebMapTileServiceImageryProvider.prototype.pickFeatures = function (
  805. x,
  806. y,
  807. level,
  808. longitude,
  809. latitude
  810. ) {
  811. return undefined;
  812. };
  813. export default WebMapTileServiceImageryProvider;