WebMapServiceImageryProvider.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. import defaultValue from "../Core/defaultValue.js";
  2. import defined from "../Core/defined.js";
  3. import deprecationWarning from "../Core/deprecationWarning.js";
  4. import DeveloperError from "../Core/DeveloperError.js";
  5. import GeographicTilingScheme from "../Core/GeographicTilingScheme.js";
  6. import Resource from "../Core/Resource.js";
  7. import WebMercatorProjection from "../Core/WebMercatorProjection.js";
  8. import GetFeatureInfoFormat from "./GetFeatureInfoFormat.js";
  9. import TimeDynamicImagery from "./TimeDynamicImagery.js";
  10. import UrlTemplateImageryProvider from "./UrlTemplateImageryProvider.js";
  11. /**
  12. * EPSG codes known to include reverse axis orders, but are not within 4000-5000.
  13. *
  14. * @type {number[]}
  15. */
  16. const includesReverseAxis = [
  17. 3034, // ETRS89-extended / LCC Europe
  18. 3035, // ETRS89-extended / LAEA Europe
  19. 3042, // ETRS89 / UTM zone 30N (N-E)
  20. 3043, // ETRS89 / UTM zone 31N (N-E)
  21. 3044, // ETRS89 / UTM zone 32N (N-E)
  22. ];
  23. /**
  24. * EPSG codes known to not include reverse axis orders, and are within 4000-5000.
  25. *
  26. * @type {number[]}
  27. */
  28. const excludesReverseAxis = [
  29. 4471, // Mayotte
  30. 4559, // French Antilles
  31. ];
  32. /**
  33. * @typedef {object} WebMapServiceImageryProvider.ConstructorOptions
  34. *
  35. * Initialization options for the WebMapServiceImageryProvider constructor
  36. *
  37. * @property {Resource|string} url The URL of the WMS service. The URL supports the same keywords as the {@link UrlTemplateImageryProvider}.
  38. * @property {string} layers The layers to include, separated by commas.
  39. * @property {object} [parameters=WebMapServiceImageryProvider.DefaultParameters] Additional parameters to pass to the WMS server in the GetMap URL.
  40. * @property {object} [getFeatureInfoParameters=WebMapServiceImageryProvider.GetFeatureInfoDefaultParameters] Additional parameters to pass to the WMS server in the GetFeatureInfo URL.
  41. * @property {boolean} [enablePickFeatures=true] If true, {@link WebMapServiceImageryProvider#pickFeatures} will invoke
  42. * the GetFeatureInfo operation on the WMS server and return the features included in the response. If false,
  43. * {@link WebMapServiceImageryProvider#pickFeatures} will immediately return undefined (indicating no pickable features)
  44. * without communicating with the server. Set this property to false if you know your WMS server does not support
  45. * GetFeatureInfo or if you don't want this provider's features to be pickable. Note that this can be dynamically
  46. * overridden by modifying the WebMapServiceImageryProvider#enablePickFeatures property.
  47. * @property {GetFeatureInfoFormat[]} [getFeatureInfoFormats=WebMapServiceImageryProvider.DefaultGetFeatureInfoFormats] The formats
  48. * in which to try WMS GetFeatureInfo requests.
  49. * @property {Rectangle} [rectangle=Rectangle.MAX_VALUE] The rectangle of the layer.
  50. * @property {TilingScheme} [tilingScheme=new GeographicTilingScheme()] The tiling scheme to use to divide the world into tiles.
  51. * @property {Ellipsoid} [ellipsoid] The ellipsoid. If the tilingScheme is specified,
  52. * this parameter is ignored and the tiling scheme's ellipsoid is used instead. If neither
  53. * parameter is specified, the WGS84 ellipsoid is used.
  54. * @property {number} [tileWidth=256] The width of each tile in pixels.
  55. * @property {number} [tileHeight=256] The height of each tile in pixels.
  56. * @property {number} [minimumLevel=0] The minimum level-of-detail supported by the imagery provider. Take care when
  57. * specifying this that the number of tiles at the minimum level is small, such as four or less. A larger number is
  58. * likely to result in rendering problems.
  59. * @property {number} [maximumLevel] The maximum level-of-detail supported by the imagery provider, or undefined if there is no limit.
  60. * If not specified, there is no limit.
  61. * @property {string} [crs] CRS specification, for use with WMS specification >= 1.3.0.
  62. * @property {string} [srs] SRS specification, for use with WMS specification 1.1.0 or 1.1.1
  63. * @property {Credit|string} [credit] A credit for the data source, which is displayed on the canvas.
  64. * @property {string|string[]} [subdomains='abc'] The subdomains to use for the <code>{s}</code> placeholder in the URL template.
  65. * If this parameter is a single string, each character in the string is a subdomain. If it is
  66. * an array, each element in the array is a subdomain.
  67. * @property {Clock} [clock] A Clock instance that is used when determining the value for the time dimension. Required when `times` is specified.
  68. * @property {TimeIntervalCollection} [times] TimeIntervalCollection with its data property being an object containing time dynamic dimension and their values.
  69. * @property {Resource|string} [getFeatureInfoUrl] The getFeatureInfo URL of the WMS service. If the property is not defined then we use the property value of url.
  70. */
  71. /**
  72. * Provides tiled imagery hosted by a Web Map Service (WMS) server.
  73. *
  74. * @alias WebMapServiceImageryProvider
  75. * @constructor
  76. *
  77. * @param {WebMapServiceImageryProvider.ConstructorOptions} options Object describing initialization options
  78. *
  79. * @see ArcGisMapServerImageryProvider
  80. * @see BingMapsImageryProvider
  81. * @see GoogleEarthEnterpriseMapsProvider
  82. * @see OpenStreetMapImageryProvider
  83. * @see SingleTileImageryProvider
  84. * @see TileMapServiceImageryProvider
  85. * @see WebMapTileServiceImageryProvider
  86. * @see UrlTemplateImageryProvider
  87. *
  88. * @see {@link http://resources.esri.com/help/9.3/arcgisserver/apis/rest/|ArcGIS Server REST API}
  89. * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
  90. *
  91. * @example
  92. * const provider = new Cesium.WebMapServiceImageryProvider({
  93. * url : 'https://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer',
  94. * layers : '0',
  95. * proxy: new Cesium.DefaultProxy('/proxy/')
  96. * });
  97. * const imageryLayer = new Cesium.ImageryLayer(provider);
  98. * viewer.imageryLayers.add(imageryLayer);
  99. */
  100. function WebMapServiceImageryProvider(options) {
  101. options = defaultValue(options, defaultValue.EMPTY_OBJECT);
  102. //>>includeStart('debug', pragmas.debug);
  103. if (!defined(options.url)) {
  104. throw new DeveloperError("options.url is required.");
  105. }
  106. if (!defined(options.layers)) {
  107. throw new DeveloperError("options.layers is required.");
  108. }
  109. //>>includeEnd('debug');
  110. if (defined(options.times) && !defined(options.clock)) {
  111. throw new DeveloperError(
  112. "options.times was specified, so options.clock is required."
  113. );
  114. }
  115. this._defaultAlpha = undefined;
  116. this._defaultNightAlpha = undefined;
  117. this._defaultDayAlpha = undefined;
  118. this._defaultBrightness = undefined;
  119. this._defaultContrast = undefined;
  120. this._defaultHue = undefined;
  121. this._defaultSaturation = undefined;
  122. this._defaultGamma = undefined;
  123. this._defaultMinificationFilter = undefined;
  124. this._defaultMagnificationFilter = undefined;
  125. this._getFeatureInfoUrl = defaultValue(
  126. options.getFeatureInfoUrl,
  127. options.url
  128. );
  129. const resource = Resource.createIfNeeded(options.url);
  130. const pickFeatureResource = Resource.createIfNeeded(this._getFeatureInfoUrl);
  131. resource.setQueryParameters(
  132. WebMapServiceImageryProvider.DefaultParameters,
  133. true
  134. );
  135. pickFeatureResource.setQueryParameters(
  136. WebMapServiceImageryProvider.GetFeatureInfoDefaultParameters,
  137. true
  138. );
  139. if (defined(options.parameters)) {
  140. resource.setQueryParameters(objectToLowercase(options.parameters));
  141. }
  142. if (defined(options.getFeatureInfoParameters)) {
  143. pickFeatureResource.setQueryParameters(
  144. objectToLowercase(options.getFeatureInfoParameters)
  145. );
  146. }
  147. const that = this;
  148. this._reload = undefined;
  149. if (defined(options.times)) {
  150. this._timeDynamicImagery = new TimeDynamicImagery({
  151. clock: options.clock,
  152. times: options.times,
  153. requestImageFunction: function (x, y, level, request, interval) {
  154. return requestImage(that, x, y, level, request, interval);
  155. },
  156. reloadFunction: function () {
  157. if (defined(that._reload)) {
  158. that._reload();
  159. }
  160. },
  161. });
  162. }
  163. const parameters = {};
  164. parameters.layers = options.layers;
  165. parameters.bbox =
  166. "{westProjected},{southProjected},{eastProjected},{northProjected}";
  167. parameters.width = "{width}";
  168. parameters.height = "{height}";
  169. // Use SRS or CRS based on the WMS version.
  170. if (parseFloat(resource.queryParameters.version) >= 1.3) {
  171. // Use CRS with 1.3.0 and going forward.
  172. // For GeographicTilingScheme, use CRS:84 vice EPSG:4326 to specify lon, lat (x, y) ordering for
  173. // bbox requests.
  174. parameters.crs = defaultValue(
  175. options.crs,
  176. options.tilingScheme &&
  177. options.tilingScheme.projection instanceof WebMercatorProjection
  178. ? "EPSG:3857"
  179. : "CRS:84"
  180. );
  181. // The axis order in previous versions of the WMS specifications was to always use easting (x or lon ) and northing (y or
  182. // lat). WMS 1.3.0 specifies that, depending on the particular CRS, the x axis may or may not be oriented West-to-East,
  183. // and the y axis may or may not be oriented South-to-North. The WMS portrayal operation shall account for axis order.
  184. // This affects some of the EPSG codes that were commonly used such as ESPG:4326. The current implementation
  185. // makes sure that coordinates passed to the server (as part of the GetMap BBOX parameter) as well as those advertised
  186. // in the capabilities document reflect the inverse axe orders for EPSG codes between 4000 and 5000.
  187. // - Taken from Section 9.1.3 of https://download.osgeo.org/mapserver/docs/MapServer-56.pdf
  188. const parts = parameters.crs.split(":");
  189. if (parts[0] === "EPSG" && parts.length === 2) {
  190. const code = Number(parts[1]);
  191. if (
  192. (code >= 4000 && code < 5000 && !excludesReverseAxis.includes(code)) ||
  193. includesReverseAxis.includes(code)
  194. ) {
  195. parameters.bbox =
  196. "{southProjected},{westProjected},{northProjected},{eastProjected}";
  197. }
  198. }
  199. } else {
  200. // SRS for WMS 1.1.0 or 1.1.1.
  201. parameters.srs = defaultValue(
  202. options.srs,
  203. options.tilingScheme &&
  204. options.tilingScheme.projection instanceof WebMercatorProjection
  205. ? "EPSG:3857"
  206. : "EPSG:4326"
  207. );
  208. }
  209. resource.setQueryParameters(parameters, true);
  210. pickFeatureResource.setQueryParameters(parameters, true);
  211. const pickFeatureParams = {
  212. query_layers: options.layers,
  213. info_format: "{format}",
  214. };
  215. // use correct pixel coordinate identifier based on version
  216. if (parseFloat(pickFeatureResource.queryParameters.version) >= 1.3) {
  217. pickFeatureParams.i = "{i}";
  218. pickFeatureParams.j = "{j}";
  219. } else {
  220. pickFeatureParams.x = "{i}";
  221. pickFeatureParams.y = "{j}";
  222. }
  223. pickFeatureResource.setQueryParameters(pickFeatureParams, true);
  224. this._resource = resource;
  225. this._pickFeaturesResource = pickFeatureResource;
  226. this._layers = options.layers;
  227. // Let UrlTemplateImageryProvider do the actual URL building.
  228. this._tileProvider = new UrlTemplateImageryProvider({
  229. url: resource,
  230. pickFeaturesUrl: pickFeatureResource,
  231. tilingScheme: defaultValue(
  232. options.tilingScheme,
  233. new GeographicTilingScheme({ ellipsoid: options.ellipsoid })
  234. ),
  235. rectangle: options.rectangle,
  236. tileWidth: options.tileWidth,
  237. tileHeight: options.tileHeight,
  238. minimumLevel: options.minimumLevel,
  239. maximumLevel: options.maximumLevel,
  240. subdomains: options.subdomains,
  241. tileDiscardPolicy: options.tileDiscardPolicy,
  242. credit: options.credit,
  243. getFeatureInfoFormats: defaultValue(
  244. options.getFeatureInfoFormats,
  245. WebMapServiceImageryProvider.DefaultGetFeatureInfoFormats
  246. ),
  247. enablePickFeatures: options.enablePickFeatures,
  248. });
  249. this._ready = true;
  250. this._readyPromise = Promise.resolve(true);
  251. }
  252. function requestImage(imageryProvider, col, row, level, request, interval) {
  253. const dynamicIntervalData = defined(interval) ? interval.data : undefined;
  254. const tileProvider = imageryProvider._tileProvider;
  255. if (defined(dynamicIntervalData)) {
  256. // We set the query parameters within the tile provider, because it is managing the query.
  257. tileProvider._resource.setQueryParameters(dynamicIntervalData);
  258. }
  259. return tileProvider.requestImage(col, row, level, request);
  260. }
  261. function pickFeatures(
  262. imageryProvider,
  263. x,
  264. y,
  265. level,
  266. longitude,
  267. latitude,
  268. interval
  269. ) {
  270. const dynamicIntervalData = defined(interval) ? interval.data : undefined;
  271. const tileProvider = imageryProvider._tileProvider;
  272. if (defined(dynamicIntervalData)) {
  273. // We set the query parameters within the tile provider, because it is managing the query.
  274. tileProvider._pickFeaturesResource.setQueryParameters(dynamicIntervalData);
  275. }
  276. return tileProvider.pickFeatures(x, y, level, longitude, latitude);
  277. }
  278. Object.defineProperties(WebMapServiceImageryProvider.prototype, {
  279. /**
  280. * Gets the URL of the WMS server.
  281. * @memberof WebMapServiceImageryProvider.prototype
  282. * @type {string}
  283. * @readonly
  284. */
  285. url: {
  286. get: function () {
  287. return this._resource._url;
  288. },
  289. },
  290. /**
  291. * Gets the proxy used by this provider.
  292. * @memberof WebMapServiceImageryProvider.prototype
  293. * @type {Proxy}
  294. * @readonly
  295. */
  296. proxy: {
  297. get: function () {
  298. return this._resource.proxy;
  299. },
  300. },
  301. /**
  302. * Gets the names of the WMS layers, separated by commas.
  303. * @memberof WebMapServiceImageryProvider.prototype
  304. * @type {string}
  305. * @readonly
  306. */
  307. layers: {
  308. get: function () {
  309. return this._layers;
  310. },
  311. },
  312. /**
  313. * Gets the width of each tile, in pixels.
  314. * @memberof WebMapServiceImageryProvider.prototype
  315. * @type {number}
  316. * @readonly
  317. */
  318. tileWidth: {
  319. get: function () {
  320. return this._tileProvider.tileWidth;
  321. },
  322. },
  323. /**
  324. * Gets the height of each tile, in pixels.
  325. * @memberof WebMapServiceImageryProvider.prototype
  326. * @type {number}
  327. * @readonly
  328. */
  329. tileHeight: {
  330. get: function () {
  331. return this._tileProvider.tileHeight;
  332. },
  333. },
  334. /**
  335. * Gets the maximum level-of-detail that can be requested.
  336. * @memberof WebMapServiceImageryProvider.prototype
  337. * @type {number|undefined}
  338. * @readonly
  339. */
  340. maximumLevel: {
  341. get: function () {
  342. return this._tileProvider.maximumLevel;
  343. },
  344. },
  345. /**
  346. * Gets the minimum level-of-detail that can be requested.
  347. * @memberof WebMapServiceImageryProvider.prototype
  348. * @type {number}
  349. * @readonly
  350. */
  351. minimumLevel: {
  352. get: function () {
  353. return this._tileProvider.minimumLevel;
  354. },
  355. },
  356. /**
  357. * Gets the tiling scheme used by this provider.
  358. * @memberof WebMapServiceImageryProvider.prototype
  359. * @type {TilingScheme}
  360. * @readonly
  361. */
  362. tilingScheme: {
  363. get: function () {
  364. return this._tileProvider.tilingScheme;
  365. },
  366. },
  367. /**
  368. * Gets the rectangle, in radians, of the imagery provided by this instance.
  369. * @memberof WebMapServiceImageryProvider.prototype
  370. * @type {Rectangle}
  371. * @readonly
  372. */
  373. rectangle: {
  374. get: function () {
  375. return this._tileProvider.rectangle;
  376. },
  377. },
  378. /**
  379. * Gets the tile discard policy. If not undefined, the discard policy is responsible
  380. * for filtering out "missing" tiles via its shouldDiscardImage function. If this function
  381. * returns undefined, no tiles are filtered.
  382. * @memberof WebMapServiceImageryProvider.prototype
  383. * @type {TileDiscardPolicy}
  384. * @readonly
  385. */
  386. tileDiscardPolicy: {
  387. get: function () {
  388. return this._tileProvider.tileDiscardPolicy;
  389. },
  390. },
  391. /**
  392. * Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
  393. * to the event, you will be notified of the error and can potentially recover from it. Event listeners
  394. * are passed an instance of {@link TileProviderError}.
  395. * @memberof WebMapServiceImageryProvider.prototype
  396. * @type {Event}
  397. * @readonly
  398. */
  399. errorEvent: {
  400. get: function () {
  401. return this._tileProvider.errorEvent;
  402. },
  403. },
  404. /**
  405. * Gets a value indicating whether or not the provider is ready for use.
  406. * @memberof WebMapServiceImageryProvider.prototype
  407. * @type {boolean}
  408. * @readonly
  409. * @deprecated
  410. */
  411. ready: {
  412. get: function () {
  413. deprecationWarning(
  414. "WebMapServiceImageryProvider.ready",
  415. "WebMapServiceImageryProvider.ready was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107."
  416. );
  417. return this._tileProvider.ready;
  418. },
  419. },
  420. /**
  421. * Gets a promise that resolves to true when the provider is ready for use.
  422. * @memberof WebMapServiceImageryProvider.prototype
  423. * @type {Promise<boolean>}
  424. * @readonly
  425. * @deprecated
  426. */
  427. readyPromise: {
  428. get: function () {
  429. deprecationWarning(
  430. "WebMapServiceImageryProvider.readyPromise",
  431. "WebMapServiceImageryProvider.readyPromise was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107."
  432. );
  433. return this._tileProvider.readyPromise;
  434. },
  435. },
  436. /**
  437. * Gets the credit to display when this imagery provider is active. Typically this is used to credit
  438. * the source of the imagery.
  439. * @memberof WebMapServiceImageryProvider.prototype
  440. * @type {Credit}
  441. * @readonly
  442. */
  443. credit: {
  444. get: function () {
  445. return this._tileProvider.credit;
  446. },
  447. },
  448. /**
  449. * Gets a value indicating whether or not the images provided by this imagery provider
  450. * include an alpha channel. If this property is false, an alpha channel, if present, will
  451. * be ignored. If this property is true, any images without an alpha channel will be treated
  452. * as if their alpha is 1.0 everywhere. When this property is false, memory usage
  453. * and texture upload time are reduced.
  454. * @memberof WebMapServiceImageryProvider.prototype
  455. * @type {boolean}
  456. * @readonly
  457. */
  458. hasAlphaChannel: {
  459. get: function () {
  460. return this._tileProvider.hasAlphaChannel;
  461. },
  462. },
  463. /**
  464. * Gets or sets a value indicating whether feature picking is enabled. If true, {@link WebMapServiceImageryProvider#pickFeatures} will
  465. * invoke the <code>GetFeatureInfo</code> service on the WMS server and attempt to interpret the features included in the response. If false,
  466. * {@link WebMapServiceImageryProvider#pickFeatures} will immediately return undefined (indicating no pickable
  467. * features) without communicating with the server. Set this property to false if you know your data
  468. * source does not support picking features or if you don't want this provider's features to be pickable.
  469. * @memberof WebMapServiceImageryProvider.prototype
  470. * @type {boolean}
  471. * @default true
  472. */
  473. enablePickFeatures: {
  474. get: function () {
  475. return this._tileProvider.enablePickFeatures;
  476. },
  477. set: function (enablePickFeatures) {
  478. this._tileProvider.enablePickFeatures = enablePickFeatures;
  479. },
  480. },
  481. /**
  482. * Gets or sets a clock that is used to get keep the time used for time dynamic parameters.
  483. * @memberof WebMapServiceImageryProvider.prototype
  484. * @type {Clock}
  485. */
  486. clock: {
  487. get: function () {
  488. return this._timeDynamicImagery.clock;
  489. },
  490. set: function (value) {
  491. this._timeDynamicImagery.clock = value;
  492. },
  493. },
  494. /**
  495. * Gets or sets a time interval collection that is used to get time dynamic parameters. The data of each
  496. * TimeInterval is an object containing the keys and values of the properties that are used during
  497. * tile requests.
  498. * @memberof WebMapServiceImageryProvider.prototype
  499. * @type {TimeIntervalCollection}
  500. */
  501. times: {
  502. get: function () {
  503. return this._timeDynamicImagery.times;
  504. },
  505. set: function (value) {
  506. this._timeDynamicImagery.times = value;
  507. },
  508. },
  509. /**
  510. * Gets the getFeatureInfo URL of the WMS server.
  511. * @memberof WebMapServiceImageryProvider.prototype
  512. * @type {Resource|string}
  513. * @readonly
  514. */
  515. getFeatureInfoUrl: {
  516. get: function () {
  517. return this._getFeatureInfoUrl;
  518. },
  519. },
  520. /**
  521. * The default alpha blending value of this provider, with 0.0 representing fully transparent and
  522. * 1.0 representing fully opaque.
  523. * @memberof WebMapServiceImageryProvider.prototype
  524. * @type {Number|undefined}
  525. * @deprecated
  526. */
  527. defaultAlpha: {
  528. get: function () {
  529. deprecationWarning(
  530. "WebMapServiceImageryProvider.defaultAlpha",
  531. "WebMapServiceImageryProvider.defaultAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.alpha instead."
  532. );
  533. return this._defaultAlpha;
  534. },
  535. set: function (value) {
  536. deprecationWarning(
  537. "WebMapServiceImageryProvider.defaultAlpha",
  538. "WebMapServiceImageryProvider.defaultAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.alpha instead."
  539. );
  540. this._defaultAlpha = value;
  541. },
  542. },
  543. /**
  544. * The default alpha blending value on the night side of the globe of this provider, with 0.0 representing fully transparent and
  545. * 1.0 representing fully opaque.
  546. * @memberof WebMapServiceImageryProvider.prototype
  547. * @type {Number|undefined}
  548. * @deprecated
  549. */
  550. defaultNightAlpha: {
  551. get: function () {
  552. deprecationWarning(
  553. "WebMapServiceImageryProvider.defaultNightAlpha",
  554. "WebMapServiceImageryProvider.defaultNightAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.nightAlpha instead."
  555. );
  556. return this._defaultNightAlpha;
  557. },
  558. set: function (value) {
  559. deprecationWarning(
  560. "WebMapServiceImageryProvider.defaultNightAlpha",
  561. "WebMapServiceImageryProvider.defaultNightAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.nightAlpha instead."
  562. );
  563. this._defaultNightAlpha = value;
  564. },
  565. },
  566. /**
  567. * The default alpha blending value on the day side of the globe of this provider, with 0.0 representing fully transparent and
  568. * 1.0 representing fully opaque.
  569. * @memberof WebMapServiceImageryProvider.prototype
  570. * @type {Number|undefined}
  571. * @deprecated
  572. */
  573. defaultDayAlpha: {
  574. get: function () {
  575. deprecationWarning(
  576. "WebMapServiceImageryProvider.defaultDayAlpha",
  577. "WebMapServiceImageryProvider.defaultDayAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.dayAlpha instead."
  578. );
  579. return this._defaultDayAlpha;
  580. },
  581. set: function (value) {
  582. deprecationWarning(
  583. "WebMapServiceImageryProvider.defaultDayAlpha",
  584. "WebMapServiceImageryProvider.defaultDayAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.dayAlpha instead."
  585. );
  586. this._defaultDayAlpha = value;
  587. },
  588. },
  589. /**
  590. * The default brightness of this provider. 1.0 uses the unmodified imagery color. Less than 1.0
  591. * makes the imagery darker while greater than 1.0 makes it brighter.
  592. * @memberof WebMapServiceImageryProvider.prototype
  593. * @type {Number|undefined}
  594. * @deprecated
  595. */
  596. defaultBrightness: {
  597. get: function () {
  598. deprecationWarning(
  599. "WebMapServiceImageryProvider.defaultBrightness",
  600. "WebMapServiceImageryProvider.defaultBrightness was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.brightness instead."
  601. );
  602. return this._defaultBrightness;
  603. },
  604. set: function (value) {
  605. deprecationWarning(
  606. "WebMapServiceImageryProvider.defaultBrightness",
  607. "WebMapServiceImageryProvider.defaultBrightness was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.brightness instead."
  608. );
  609. this._defaultBrightness = value;
  610. },
  611. },
  612. /**
  613. * The default contrast of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces
  614. * the contrast while greater than 1.0 increases it.
  615. * @memberof WebMapServiceImageryProvider.prototype
  616. * @type {Number|undefined}
  617. * @deprecated
  618. */
  619. defaultContrast: {
  620. get: function () {
  621. deprecationWarning(
  622. "WebMapServiceImageryProvider.defaultContrast",
  623. "WebMapServiceImageryProvider.defaultContrast was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.contrast instead."
  624. );
  625. return this._defaultContrast;
  626. },
  627. set: function (value) {
  628. deprecationWarning(
  629. "WebMapServiceImageryProvider.defaultContrast",
  630. "WebMapServiceImageryProvider.defaultContrast was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.contrast instead."
  631. );
  632. this._defaultContrast = value;
  633. },
  634. },
  635. /**
  636. * The default hue of this provider in radians. 0.0 uses the unmodified imagery color.
  637. * @memberof WebMapServiceImageryProvider.prototype
  638. * @type {Number|undefined}
  639. * @deprecated
  640. */
  641. defaultHue: {
  642. get: function () {
  643. deprecationWarning(
  644. "WebMapServiceImageryProvider.defaultHue",
  645. "WebMapServiceImageryProvider.defaultHue was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.hue instead."
  646. );
  647. return this._defaultHue;
  648. },
  649. set: function (value) {
  650. deprecationWarning(
  651. "WebMapServiceImageryProvider.defaultHue",
  652. "WebMapServiceImageryProvider.defaultHue was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.hue instead."
  653. );
  654. this._defaultHue = value;
  655. },
  656. },
  657. /**
  658. * The default saturation of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces the
  659. * saturation while greater than 1.0 increases it.
  660. * @memberof WebMapServiceImageryProvider.prototype
  661. * @type {Number|undefined}
  662. * @deprecated
  663. */
  664. defaultSaturation: {
  665. get: function () {
  666. deprecationWarning(
  667. "WebMapServiceImageryProvider.defaultSaturation",
  668. "WebMapServiceImageryProvider.defaultSaturation was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.saturation instead."
  669. );
  670. return this._defaultSaturation;
  671. },
  672. set: function (value) {
  673. deprecationWarning(
  674. "WebMapServiceImageryProvider.defaultSaturation",
  675. "WebMapServiceImageryProvider.defaultSaturation was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.saturation instead."
  676. );
  677. this._defaultSaturation = value;
  678. },
  679. },
  680. /**
  681. * The default gamma correction to apply to this provider. 1.0 uses the unmodified imagery color.
  682. * @memberof WebMapServiceImageryProvider.prototype
  683. * @type {Number|undefined}
  684. * @deprecated
  685. */
  686. defaultGamma: {
  687. get: function () {
  688. deprecationWarning(
  689. "WebMapServiceImageryProvider.defaultGamma",
  690. "WebMapServiceImageryProvider.defaultGamma was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.gamma instead."
  691. );
  692. return this._defaultGamma;
  693. },
  694. set: function (value) {
  695. deprecationWarning(
  696. "WebMapServiceImageryProvider.defaultGamma",
  697. "WebMapServiceImageryProvider.defaultGamma was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.gamma instead."
  698. );
  699. this._defaultGamma = value;
  700. },
  701. },
  702. /**
  703. * The default texture minification filter to apply to this provider.
  704. * @memberof WebMapServiceImageryProvider.prototype
  705. * @type {TextureMinificationFilter}
  706. * @deprecated
  707. */
  708. defaultMinificationFilter: {
  709. get: function () {
  710. deprecationWarning(
  711. "WebMapServiceImageryProvider.defaultMinificationFilter",
  712. "WebMapServiceImageryProvider.defaultMinificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.minificationFilter instead."
  713. );
  714. return this._defaultMinificationFilter;
  715. },
  716. set: function (value) {
  717. deprecationWarning(
  718. "WebMapServiceImageryProvider.defaultMinificationFilter",
  719. "WebMapServiceImageryProvider.defaultMinificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.minificationFilter instead."
  720. );
  721. this._defaultMinificationFilter = value;
  722. },
  723. },
  724. /**
  725. * The default texture magnification filter to apply to this provider.
  726. * @memberof WebMapServiceImageryProvider.prototype
  727. * @type {TextureMagnificationFilter}
  728. * @deprecated
  729. */
  730. defaultMagnificationFilter: {
  731. get: function () {
  732. deprecationWarning(
  733. "WebMapServiceImageryProvider.defaultMagnificationFilter",
  734. "WebMapServiceImageryProvider.defaultMagnificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.magnificationFilter instead."
  735. );
  736. return this._defaultMagnificationFilter;
  737. },
  738. set: function (value) {
  739. deprecationWarning(
  740. "WebMapServiceImageryProvider.defaultMagnificationFilter",
  741. "WebMapServiceImageryProvider.defaultMagnificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.magnificationFilter instead."
  742. );
  743. this._defaultMagnificationFilter = value;
  744. },
  745. },
  746. });
  747. /**
  748. * Gets the credits to be displayed when a given tile is displayed.
  749. *
  750. * @param {number} x The tile X coordinate.
  751. * @param {number} y The tile Y coordinate.
  752. * @param {number} level The tile level;
  753. * @returns {Credit[]} The credits to be displayed when the tile is displayed.
  754. */
  755. WebMapServiceImageryProvider.prototype.getTileCredits = function (x, y, level) {
  756. return this._tileProvider.getTileCredits(x, y, level);
  757. };
  758. /**
  759. * Requests the image for a given tile.
  760. *
  761. * @param {number} x The tile X coordinate.
  762. * @param {number} y The tile Y coordinate.
  763. * @param {number} level The tile level.
  764. * @param {Request} [request] The request object. Intended for internal use only.
  765. * @returns {Promise<ImageryTypes>|undefined} A promise for the image that will resolve when the image is available, or
  766. * undefined if there are too many active requests to the server, and the request should be retried later.
  767. */
  768. WebMapServiceImageryProvider.prototype.requestImage = function (
  769. x,
  770. y,
  771. level,
  772. request
  773. ) {
  774. let result;
  775. const timeDynamicImagery = this._timeDynamicImagery;
  776. let currentInterval;
  777. // Try and load from cache
  778. if (defined(timeDynamicImagery)) {
  779. currentInterval = timeDynamicImagery.currentInterval;
  780. result = timeDynamicImagery.getFromCache(x, y, level, request);
  781. }
  782. // Couldn't load from cache
  783. if (!defined(result)) {
  784. result = requestImage(this, x, y, level, request, currentInterval);
  785. }
  786. // If we are approaching an interval, preload this tile in the next interval
  787. if (defined(result) && defined(timeDynamicImagery)) {
  788. timeDynamicImagery.checkApproachingInterval(x, y, level, request);
  789. }
  790. return result;
  791. };
  792. /**
  793. * Asynchronously determines what features, if any, are located at a given longitude and latitude within
  794. * a tile.
  795. *
  796. * @param {number} x The tile X coordinate.
  797. * @param {number} y The tile Y coordinate.
  798. * @param {number} level The tile level.
  799. * @param {number} longitude The longitude at which to pick features.
  800. * @param {number} latitude The latitude at which to pick features.
  801. * @return {Promise<ImageryLayerFeatureInfo[]>|undefined} A promise for the picked features that will resolve when the asynchronous
  802. * picking completes. The resolved value is an array of {@link ImageryLayerFeatureInfo}
  803. * instances. The array may be empty if no features are found at the given location.
  804. */
  805. WebMapServiceImageryProvider.prototype.pickFeatures = function (
  806. x,
  807. y,
  808. level,
  809. longitude,
  810. latitude
  811. ) {
  812. const timeDynamicImagery = this._timeDynamicImagery;
  813. const currentInterval = defined(timeDynamicImagery)
  814. ? timeDynamicImagery.currentInterval
  815. : undefined;
  816. return pickFeatures(this, x, y, level, longitude, latitude, currentInterval);
  817. };
  818. /**
  819. * The default parameters to include in the WMS URL to obtain images. The values are as follows:
  820. * service=WMS
  821. * version=1.1.1
  822. * request=GetMap
  823. * styles=
  824. * format=image/jpeg
  825. *
  826. * @constant
  827. * @type {object}
  828. */
  829. WebMapServiceImageryProvider.DefaultParameters = Object.freeze({
  830. service: "WMS",
  831. version: "1.1.1",
  832. request: "GetMap",
  833. styles: "",
  834. format: "image/jpeg",
  835. });
  836. /**
  837. * The default parameters to include in the WMS URL to get feature information. The values are as follows:
  838. * service=WMS
  839. * version=1.1.1
  840. * request=GetFeatureInfo
  841. *
  842. * @constant
  843. * @type {object}
  844. */
  845. WebMapServiceImageryProvider.GetFeatureInfoDefaultParameters = Object.freeze({
  846. service: "WMS",
  847. version: "1.1.1",
  848. request: "GetFeatureInfo",
  849. });
  850. WebMapServiceImageryProvider.DefaultGetFeatureInfoFormats = Object.freeze([
  851. Object.freeze(new GetFeatureInfoFormat("json", "application/json")),
  852. Object.freeze(new GetFeatureInfoFormat("xml", "text/xml")),
  853. Object.freeze(new GetFeatureInfoFormat("text", "text/html")),
  854. ]);
  855. function objectToLowercase(obj) {
  856. const result = {};
  857. for (const key in obj) {
  858. if (obj.hasOwnProperty(key)) {
  859. result[key.toLowerCase()] = obj[key];
  860. }
  861. }
  862. return result;
  863. }
  864. export default WebMapServiceImageryProvider;