智慧水务管理系统 - 精河县供水工程综合管理平台

WebMapServiceImageryProvider.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. import Frozen from "../Core/Frozen.js";
  2. import defined from "../Core/defined.js";
  3. import DeveloperError from "../Core/DeveloperError.js";
  4. import GeographicTilingScheme from "../Core/GeographicTilingScheme.js";
  5. import Resource from "../Core/Resource.js";
  6. import WebMercatorProjection from "../Core/WebMercatorProjection.js";
  7. import GetFeatureInfoFormat from "./GetFeatureInfoFormat.js";
  8. import TimeDynamicImagery from "./TimeDynamicImagery.js";
  9. import UrlTemplateImageryProvider from "./UrlTemplateImageryProvider.js";
  10. /**
  11. * EPSG codes known to include reverse axis orders, but are not within 4000-5000.
  12. *
  13. * @type {number[]}
  14. */
  15. const includesReverseAxis = [
  16. 3034, // ETRS89-extended / LCC Europe
  17. 3035, // ETRS89-extended / LAEA Europe
  18. 3042, // ETRS89 / UTM zone 30N (N-E)
  19. 3043, // ETRS89 / UTM zone 31N (N-E)
  20. 3044, // ETRS89 / UTM zone 32N (N-E)
  21. ];
  22. /**
  23. * EPSG codes known to not include reverse axis orders, and are within 4000-5000.
  24. *
  25. * @type {number[]}
  26. */
  27. const excludesReverseAxis = [
  28. 4471, // Mayotte
  29. 4559, // French Antilles
  30. ];
  31. /**
  32. * @typedef {object} WebMapServiceImageryProvider.ConstructorOptions
  33. *
  34. * Initialization options for the WebMapServiceImageryProvider constructor
  35. *
  36. * @property {Resource|string} url The URL of the WMS service. The URL supports the same keywords as the {@link UrlTemplateImageryProvider}.
  37. * @property {string} layers The layers to include, separated by commas.
  38. * @property {object} [parameters=WebMapServiceImageryProvider.DefaultParameters] Additional parameters to pass to the WMS server in the GetMap URL.
  39. * @property {boolean} [enablePickFeatures=true] If true, {@link WebMapServiceImageryProvider#pickFeatures} will invoke
  40. * the GetFeatureInfo operation on the WMS server and return the features included in the response. If false,
  41. * {@link WebMapServiceImageryProvider#pickFeatures} will immediately return undefined (indicating no pickable features)
  42. * without communicating with the server. Set this property to false if you know your WMS server does not support
  43. * GetFeatureInfo or if you don't want this provider's features to be pickable. Note that this can be dynamically
  44. * overridden by modifying the WebMapServiceImageryProvider#enablePickFeatures property.
  45. * @property {object} [getFeatureInfoParameters=WebMapServiceImageryProvider.GetFeatureInfoDefaultParameters] Additional parameters to pass to the WMS server in the GetFeatureInfo URL.
  46. * @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.
  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. */
  70. /**
  71. * Provides tiled imagery hosted by a Web Map Service (WMS) server.
  72. *
  73. * @alias WebMapServiceImageryProvider
  74. * @constructor
  75. *
  76. * @param {WebMapServiceImageryProvider.ConstructorOptions} options Object describing initialization options
  77. *
  78. * @see ArcGisMapServerImageryProvider
  79. * @see BingMapsImageryProvider
  80. * @see GoogleEarthEnterpriseMapsProvider
  81. * @see OpenStreetMapImageryProvider
  82. * @see SingleTileImageryProvider
  83. * @see TileMapServiceImageryProvider
  84. * @see WebMapTileServiceImageryProvider
  85. * @see UrlTemplateImageryProvider
  86. *
  87. * @see {@link https://enterprise.arcgis.com/en/server/latest/publish-services/linux/wms-services.htm|ArcGIS Server WMS Services}
  88. * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
  89. *
  90. * @example
  91. * // WMS servers operated by the US government https://apps.nationalmap.gov/services/
  92. * const provider = new Cesium.WebMapServiceImageryProvider({
  93. * url : 'https://basemap.nationalmap.gov:443/arcgis/services/USGSHydroCached/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 = options ?? Frozen.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 = options.getFeatureInfoUrl ?? options.url;
  126. const resource = Resource.createIfNeeded(options.url);
  127. const pickFeatureResource = Resource.createIfNeeded(this._getFeatureInfoUrl);
  128. resource.setQueryParameters(
  129. WebMapServiceImageryProvider.DefaultParameters,
  130. true,
  131. );
  132. pickFeatureResource.setQueryParameters(
  133. WebMapServiceImageryProvider.GetFeatureInfoDefaultParameters,
  134. true,
  135. );
  136. if (defined(options.parameters)) {
  137. resource.setQueryParameters(objectToLowercase(options.parameters));
  138. }
  139. if (defined(options.getFeatureInfoParameters)) {
  140. pickFeatureResource.setQueryParameters(
  141. objectToLowercase(options.getFeatureInfoParameters),
  142. );
  143. }
  144. const that = this;
  145. this._reload = undefined;
  146. if (defined(options.times)) {
  147. this._timeDynamicImagery = new TimeDynamicImagery({
  148. clock: options.clock,
  149. times: options.times,
  150. requestImageFunction: function (x, y, level, request, interval) {
  151. return requestImage(that, x, y, level, request, interval);
  152. },
  153. reloadFunction: function () {
  154. if (defined(that._reload)) {
  155. that._reload();
  156. }
  157. },
  158. });
  159. }
  160. const parameters = {};
  161. parameters.layers = options.layers;
  162. parameters.bbox =
  163. "{westProjected},{southProjected},{eastProjected},{northProjected}";
  164. parameters.width = "{width}";
  165. parameters.height = "{height}";
  166. // Use SRS or CRS based on the WMS version.
  167. if (parseFloat(resource.queryParameters.version) >= 1.3) {
  168. // Use CRS with 1.3.0 and going forward.
  169. // For GeographicTilingScheme, use CRS:84 vice EPSG:4326 to specify lon, lat (x, y) ordering for
  170. // bbox requests.
  171. parameters.crs =
  172. options.crs ??
  173. (options.tilingScheme &&
  174. options.tilingScheme.projection instanceof WebMercatorProjection
  175. ? "EPSG:3857"
  176. : "CRS:84");
  177. // The axis order in previous versions of the WMS specifications was to always use easting (x or lon ) and northing (y or
  178. // lat). WMS 1.3.0 specifies that, depending on the particular CRS, the x axis may or may not be oriented West-to-East,
  179. // and the y axis may or may not be oriented South-to-North. The WMS portrayal operation shall account for axis order.
  180. // This affects some of the EPSG codes that were commonly used such as ESPG:4326. The current implementation
  181. // makes sure that coordinates passed to the server (as part of the GetMap BBOX parameter) as well as those advertised
  182. // in the capabilities document reflect the inverse axe orders for EPSG codes between 4000 and 5000.
  183. // - Taken from Section 9.1.3 of https://download.osgeo.org/mapserver/docs/MapServer-56.pdf
  184. const parts = parameters.crs.split(":");
  185. if (parts[0] === "EPSG" && parts.length === 2) {
  186. const code = Number(parts[1]);
  187. if (
  188. (code >= 4000 && code < 5000 && !excludesReverseAxis.includes(code)) ||
  189. includesReverseAxis.includes(code)
  190. ) {
  191. parameters.bbox =
  192. "{southProjected},{westProjected},{northProjected},{eastProjected}";
  193. }
  194. }
  195. } else {
  196. // SRS for WMS 1.1.0 or 1.1.1.
  197. parameters.srs =
  198. options.srs ??
  199. (options.tilingScheme &&
  200. options.tilingScheme.projection instanceof WebMercatorProjection
  201. ? "EPSG:3857"
  202. : "EPSG:4326");
  203. }
  204. resource.setQueryParameters(parameters, true);
  205. pickFeatureResource.setQueryParameters(parameters, true);
  206. const pickFeatureParams = {
  207. query_layers: options.layers,
  208. info_format: "{format}",
  209. };
  210. // use correct pixel coordinate identifier based on version
  211. if (parseFloat(pickFeatureResource.queryParameters.version) >= 1.3) {
  212. pickFeatureParams.i = "{i}";
  213. pickFeatureParams.j = "{j}";
  214. } else {
  215. pickFeatureParams.x = "{i}";
  216. pickFeatureParams.y = "{j}";
  217. }
  218. pickFeatureResource.setQueryParameters(pickFeatureParams, true);
  219. this._resource = resource;
  220. this._pickFeaturesResource = pickFeatureResource;
  221. this._layers = options.layers;
  222. // Let UrlTemplateImageryProvider do the actual URL building.
  223. this._tileProvider = new UrlTemplateImageryProvider({
  224. url: resource,
  225. pickFeaturesUrl: pickFeatureResource,
  226. tilingScheme:
  227. options.tilingScheme ??
  228. new GeographicTilingScheme({ ellipsoid: options.ellipsoid }),
  229. rectangle: options.rectangle,
  230. tileWidth: options.tileWidth,
  231. tileHeight: options.tileHeight,
  232. minimumLevel: options.minimumLevel,
  233. maximumLevel: options.maximumLevel,
  234. subdomains: options.subdomains,
  235. tileDiscardPolicy: options.tileDiscardPolicy,
  236. credit: options.credit,
  237. getFeatureInfoFormats:
  238. options.getFeatureInfoFormats ??
  239. WebMapServiceImageryProvider.DefaultGetFeatureInfoFormats,
  240. enablePickFeatures: options.enablePickFeatures,
  241. });
  242. }
  243. function requestImage(imageryProvider, col, row, level, request, interval) {
  244. const dynamicIntervalData = defined(interval) ? interval.data : undefined;
  245. const tileProvider = imageryProvider._tileProvider;
  246. if (defined(dynamicIntervalData)) {
  247. // We set the query parameters within the tile provider, because it is managing the query.
  248. tileProvider._resource.setQueryParameters(dynamicIntervalData);
  249. }
  250. return tileProvider.requestImage(col, row, level, request);
  251. }
  252. function pickFeatures(
  253. imageryProvider,
  254. x,
  255. y,
  256. level,
  257. longitude,
  258. latitude,
  259. interval,
  260. ) {
  261. const dynamicIntervalData = defined(interval) ? interval.data : undefined;
  262. const tileProvider = imageryProvider._tileProvider;
  263. if (defined(dynamicIntervalData)) {
  264. // We set the query parameters within the tile provider, because it is managing the query.
  265. tileProvider._pickFeaturesResource.setQueryParameters(dynamicIntervalData);
  266. }
  267. return tileProvider.pickFeatures(x, y, level, longitude, latitude);
  268. }
  269. Object.defineProperties(WebMapServiceImageryProvider.prototype, {
  270. /**
  271. * Gets the URL of the WMS server.
  272. * @memberof WebMapServiceImageryProvider.prototype
  273. * @type {string}
  274. * @readonly
  275. */
  276. url: {
  277. get: function () {
  278. return this._resource._url;
  279. },
  280. },
  281. /**
  282. * Gets the proxy used by this provider.
  283. * @memberof WebMapServiceImageryProvider.prototype
  284. * @type {Proxy}
  285. * @readonly
  286. */
  287. proxy: {
  288. get: function () {
  289. return this._resource.proxy;
  290. },
  291. },
  292. /**
  293. * Gets the names of the WMS layers, separated by commas.
  294. * @memberof WebMapServiceImageryProvider.prototype
  295. * @type {string}
  296. * @readonly
  297. */
  298. layers: {
  299. get: function () {
  300. return this._layers;
  301. },
  302. },
  303. /**
  304. * Gets the width of each tile, in pixels.
  305. * @memberof WebMapServiceImageryProvider.prototype
  306. * @type {number}
  307. * @readonly
  308. */
  309. tileWidth: {
  310. get: function () {
  311. return this._tileProvider.tileWidth;
  312. },
  313. },
  314. /**
  315. * Gets the height of each tile, in pixels.
  316. * @memberof WebMapServiceImageryProvider.prototype
  317. * @type {number}
  318. * @readonly
  319. */
  320. tileHeight: {
  321. get: function () {
  322. return this._tileProvider.tileHeight;
  323. },
  324. },
  325. /**
  326. * Gets the maximum level-of-detail that can be requested.
  327. * @memberof WebMapServiceImageryProvider.prototype
  328. * @type {number|undefined}
  329. * @readonly
  330. */
  331. maximumLevel: {
  332. get: function () {
  333. return this._tileProvider.maximumLevel;
  334. },
  335. },
  336. /**
  337. * Gets the minimum level-of-detail that can be requested.
  338. * @memberof WebMapServiceImageryProvider.prototype
  339. * @type {number}
  340. * @readonly
  341. */
  342. minimumLevel: {
  343. get: function () {
  344. return this._tileProvider.minimumLevel;
  345. },
  346. },
  347. /**
  348. * Gets the tiling scheme used by this provider.
  349. * @memberof WebMapServiceImageryProvider.prototype
  350. * @type {TilingScheme}
  351. * @readonly
  352. */
  353. tilingScheme: {
  354. get: function () {
  355. return this._tileProvider.tilingScheme;
  356. },
  357. },
  358. /**
  359. * Gets the rectangle, in radians, of the imagery provided by this instance.
  360. * @memberof WebMapServiceImageryProvider.prototype
  361. * @type {Rectangle}
  362. * @readonly
  363. */
  364. rectangle: {
  365. get: function () {
  366. return this._tileProvider.rectangle;
  367. },
  368. },
  369. /**
  370. * Gets the tile discard policy. If not undefined, the discard policy is responsible
  371. * for filtering out "missing" tiles via its shouldDiscardImage function. If this function
  372. * returns undefined, no tiles are filtered.
  373. * @memberof WebMapServiceImageryProvider.prototype
  374. * @type {TileDiscardPolicy}
  375. * @readonly
  376. */
  377. tileDiscardPolicy: {
  378. get: function () {
  379. return this._tileProvider.tileDiscardPolicy;
  380. },
  381. },
  382. /**
  383. * Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
  384. * to the event, you will be notified of the error and can potentially recover from it. Event listeners
  385. * are passed an instance of {@link TileProviderError}.
  386. * @memberof WebMapServiceImageryProvider.prototype
  387. * @type {Event}
  388. * @readonly
  389. */
  390. errorEvent: {
  391. get: function () {
  392. return this._tileProvider.errorEvent;
  393. },
  394. },
  395. /**
  396. * Gets the credit to display when this imagery provider is active. Typically this is used to credit
  397. * the source of the imagery.
  398. * @memberof WebMapServiceImageryProvider.prototype
  399. * @type {Credit}
  400. * @readonly
  401. */
  402. credit: {
  403. get: function () {
  404. return this._tileProvider.credit;
  405. },
  406. },
  407. /**
  408. * Gets a value indicating whether or not the images provided by this imagery provider
  409. * include an alpha channel. If this property is false, an alpha channel, if present, will
  410. * be ignored. If this property is true, any images without an alpha channel will be treated
  411. * as if their alpha is 1.0 everywhere. When this property is false, memory usage
  412. * and texture upload time are reduced.
  413. * @memberof WebMapServiceImageryProvider.prototype
  414. * @type {boolean}
  415. * @readonly
  416. */
  417. hasAlphaChannel: {
  418. get: function () {
  419. return this._tileProvider.hasAlphaChannel;
  420. },
  421. },
  422. /**
  423. * Gets or sets a value indicating whether feature picking is enabled. If true, {@link WebMapServiceImageryProvider#pickFeatures} will
  424. * invoke the <code>GetFeatureInfo</code> service on the WMS server and attempt to interpret the features included in the response. If false,
  425. * {@link WebMapServiceImageryProvider#pickFeatures} will immediately return undefined (indicating no pickable
  426. * features) without communicating with the server. Set this property to false if you know your data
  427. * source does not support picking features or if you don't want this provider's features to be pickable.
  428. * @memberof WebMapServiceImageryProvider.prototype
  429. * @type {boolean}
  430. * @default true
  431. */
  432. enablePickFeatures: {
  433. get: function () {
  434. return this._tileProvider.enablePickFeatures;
  435. },
  436. set: function (enablePickFeatures) {
  437. this._tileProvider.enablePickFeatures = enablePickFeatures;
  438. },
  439. },
  440. /**
  441. * Gets or sets a clock that is used to get keep the time used for time dynamic parameters.
  442. * @memberof WebMapServiceImageryProvider.prototype
  443. * @type {Clock}
  444. */
  445. clock: {
  446. get: function () {
  447. return this._timeDynamicImagery.clock;
  448. },
  449. set: function (value) {
  450. this._timeDynamicImagery.clock = value;
  451. },
  452. },
  453. /**
  454. * Gets or sets a time interval collection that is used to get time dynamic parameters. The data of each
  455. * TimeInterval is an object containing the keys and values of the properties that are used during
  456. * tile requests.
  457. * @memberof WebMapServiceImageryProvider.prototype
  458. * @type {TimeIntervalCollection}
  459. */
  460. times: {
  461. get: function () {
  462. return this._timeDynamicImagery.times;
  463. },
  464. set: function (value) {
  465. this._timeDynamicImagery.times = value;
  466. },
  467. },
  468. /**
  469. * Gets the getFeatureInfo URL of the WMS server.
  470. * @memberof WebMapServiceImageryProvider.prototype
  471. * @type {Resource|string}
  472. * @readonly
  473. */
  474. getFeatureInfoUrl: {
  475. get: function () {
  476. return this._getFeatureInfoUrl;
  477. },
  478. },
  479. });
  480. /**
  481. * Gets the credits to be displayed when a given tile is displayed.
  482. *
  483. * @param {number} x The tile X coordinate.
  484. * @param {number} y The tile Y coordinate.
  485. * @param {number} level The tile level;
  486. * @returns {Credit[]} The credits to be displayed when the tile is displayed.
  487. */
  488. WebMapServiceImageryProvider.prototype.getTileCredits = function (x, y, level) {
  489. return this._tileProvider.getTileCredits(x, y, level);
  490. };
  491. /**
  492. * Requests the image for a given tile.
  493. *
  494. * @param {number} x The tile X coordinate.
  495. * @param {number} y The tile Y coordinate.
  496. * @param {number} level The tile level.
  497. * @param {Request} [request] The request object. Intended for internal use only.
  498. * @returns {Promise<ImageryTypes>|undefined} A promise for the image that will resolve when the image is available, or
  499. * undefined if there are too many active requests to the server, and the request should be retried later.
  500. */
  501. WebMapServiceImageryProvider.prototype.requestImage = function (
  502. x,
  503. y,
  504. level,
  505. request,
  506. ) {
  507. let result;
  508. const timeDynamicImagery = this._timeDynamicImagery;
  509. let currentInterval;
  510. // Try and load from cache
  511. if (defined(timeDynamicImagery)) {
  512. currentInterval = timeDynamicImagery.currentInterval;
  513. result = timeDynamicImagery.getFromCache(x, y, level, request);
  514. }
  515. // Couldn't load from cache
  516. if (!defined(result)) {
  517. result = requestImage(this, x, y, level, request, currentInterval);
  518. }
  519. // If we are approaching an interval, preload this tile in the next interval
  520. if (defined(result) && defined(timeDynamicImagery)) {
  521. timeDynamicImagery.checkApproachingInterval(x, y, level, request);
  522. }
  523. return result;
  524. };
  525. /**
  526. * Asynchronously determines what features, if any, are located at a given longitude and latitude within
  527. * a tile.
  528. *
  529. * @param {number} x The tile X coordinate.
  530. * @param {number} y The tile Y coordinate.
  531. * @param {number} level The tile level.
  532. * @param {number} longitude The longitude at which to pick features.
  533. * @param {number} latitude The latitude at which to pick features.
  534. * @return {Promise<ImageryLayerFeatureInfo[]>|undefined} A promise for the picked features that will resolve when the asynchronous
  535. * picking completes. The resolved value is an array of {@link ImageryLayerFeatureInfo}
  536. * instances. The array may be empty if no features are found at the given location.
  537. */
  538. WebMapServiceImageryProvider.prototype.pickFeatures = function (
  539. x,
  540. y,
  541. level,
  542. longitude,
  543. latitude,
  544. ) {
  545. const timeDynamicImagery = this._timeDynamicImagery;
  546. const currentInterval = defined(timeDynamicImagery)
  547. ? timeDynamicImagery.currentInterval
  548. : undefined;
  549. return pickFeatures(this, x, y, level, longitude, latitude, currentInterval);
  550. };
  551. /**
  552. * The default parameters to include in the WMS URL to obtain images. The values are as follows:
  553. * service=WMS
  554. * version=1.1.1
  555. * request=GetMap
  556. * styles=
  557. * format=image/jpeg
  558. *
  559. * @constant
  560. * @type {object}
  561. */
  562. WebMapServiceImageryProvider.DefaultParameters = Object.freeze({
  563. service: "WMS",
  564. version: "1.1.1",
  565. request: "GetMap",
  566. styles: "",
  567. format: "image/jpeg",
  568. });
  569. /**
  570. * The default parameters to include in the WMS URL to get feature information. The values are as follows:
  571. * service=WMS
  572. * version=1.1.1
  573. * request=GetFeatureInfo
  574. *
  575. * @constant
  576. * @type {object}
  577. */
  578. WebMapServiceImageryProvider.GetFeatureInfoDefaultParameters = Object.freeze({
  579. service: "WMS",
  580. version: "1.1.1",
  581. request: "GetFeatureInfo",
  582. });
  583. WebMapServiceImageryProvider.DefaultGetFeatureInfoFormats = Object.freeze([
  584. Object.freeze(new GetFeatureInfoFormat("json", "application/json")),
  585. Object.freeze(new GetFeatureInfoFormat("xml", "text/xml")),
  586. Object.freeze(new GetFeatureInfoFormat("text", "text/html")),
  587. ]);
  588. function objectToLowercase(obj) {
  589. const result = {};
  590. for (const key in obj) {
  591. if (obj.hasOwnProperty(key)) {
  592. result[key.toLowerCase()] = obj[key];
  593. }
  594. }
  595. return result;
  596. }
  597. export default WebMapServiceImageryProvider;