GoogleEarthEnterpriseMapsProvider.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. import buildModuleUrl from "../Core/buildModuleUrl.js";
  2. import Check from "../Core/Check.js";
  3. import Credit from "../Core/Credit.js";
  4. import defaultValue from "../Core/defaultValue.js";
  5. import defined from "../Core/defined.js";
  6. import DeveloperError from "../Core/DeveloperError.js";
  7. import Event from "../Core/Event.js";
  8. import GeographicTilingScheme from "../Core/GeographicTilingScheme.js";
  9. import Rectangle from "../Core/Rectangle.js";
  10. import Resource from "../Core/Resource.js";
  11. import RuntimeError from "../Core/RuntimeError.js";
  12. import TileProviderError from "../Core/TileProviderError.js";
  13. import WebMercatorTilingScheme from "../Core/WebMercatorTilingScheme.js";
  14. import when from "../ThirdParty/when.js";
  15. import ImageryProvider from "./ImageryProvider.js";
  16. /**
  17. * @typedef {Object} GoogleEarthEnterpriseMapsProvider.ConstructorOptions
  18. *
  19. * Initialization options for the GoogleEarthEnterpriseMapsProvider constructor
  20. *
  21. * @property {Resource|String} url The url of the Google Earth server hosting the imagery.
  22. * @property {Number} channel The channel (id) to be used when requesting data from the server.
  23. * The channel number can be found by looking at the json file located at:
  24. * earth.localdomain/default_map/query?request=Json&vars=geeServerDefs The /default_map path may
  25. * differ depending on your Google Earth Enterprise server configuration. Look for the "id" that
  26. * is associated with a "ImageryMaps" requestType. There may be more than one id available.
  27. * Example:
  28. * {
  29. * layers: [
  30. * {
  31. * id: 1002,
  32. * requestType: "ImageryMaps"
  33. * },
  34. * {
  35. * id: 1007,
  36. * requestType: "VectorMapsRaster"
  37. * }
  38. * ]
  39. * }
  40. * @property {String} [path="/default_map"] The path of the Google Earth server hosting the imagery.
  41. * @property {Number} [maximumLevel] The maximum level-of-detail supported by the Google Earth
  42. * Enterprise server, or undefined if there is no limit.
  43. * @property {TileDiscardPolicy} [tileDiscardPolicy] The policy that determines if a tile
  44. * is invalid and should be discarded. To ensure that no tiles are discarded, construct and pass
  45. * a {@link NeverTileDiscardPolicy} for this parameter.
  46. * @property {Ellipsoid} [ellipsoid] The ellipsoid. If not specified, the WGS84 ellipsoid is used.
  47. */
  48. /**
  49. * Provides tiled imagery using the Google Earth Imagery API.
  50. *
  51. * Notes: This imagery provider does not work with the public Google Earth servers. It works with the
  52. * Google Earth Enterprise Server.
  53. *
  54. * By default the Google Earth Enterprise server does not set the
  55. * {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing} headers. You can either
  56. * use a proxy server which adds these headers, or in the /opt/google/gehttpd/conf/gehttpd.conf
  57. * and add the 'Header set Access-Control-Allow-Origin "*"' option to the '<Directory />' and
  58. * '<Directory "/opt/google/gehttpd/htdocs">' directives.
  59. *
  60. * This provider is for use with 2D Maps API as part of Google Earth Enterprise. For 3D Earth API uses, it
  61. * is necessary to use {@link GoogleEarthEnterpriseImageryProvider}
  62. *
  63. * @alias GoogleEarthEnterpriseMapsProvider
  64. * @constructor
  65. *
  66. * @param {GoogleEarthEnterpriseMapsProvider.ConstructorOptions} options Object describing initialization options
  67. *
  68. * @exception {RuntimeError} Could not find layer with channel (id) of <code>options.channel</code>.
  69. * @exception {RuntimeError} Could not find a version in channel (id) <code>options.channel</code>.
  70. * @exception {RuntimeError} Unsupported projection <code>data.projection</code>.
  71. *
  72. * @see ArcGisMapServerImageryProvider
  73. * @see BingMapsImageryProvider
  74. * @see OpenStreetMapImageryProvider
  75. * @see SingleTileImageryProvider
  76. * @see TileMapServiceImageryProvider
  77. * @see WebMapServiceImageryProvider
  78. * @see WebMapTileServiceImageryProvider
  79. * @see UrlTemplateImageryProvider
  80. *
  81. *
  82. * @example
  83. * var google = new Cesium.GoogleEarthEnterpriseMapsProvider({
  84. * url : 'https://earth.localdomain',
  85. * channel : 1008
  86. * });
  87. *
  88. * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
  89. */
  90. function GoogleEarthEnterpriseMapsProvider(options) {
  91. options = defaultValue(options, {});
  92. //>>includeStart('debug', pragmas.debug);
  93. if (!defined(options.url)) {
  94. throw new DeveloperError("options.url is required.");
  95. }
  96. if (!defined(options.channel)) {
  97. throw new DeveloperError("options.channel is required.");
  98. }
  99. //>>includeEnd('debug');
  100. /**
  101. * The default alpha blending value of this provider, with 0.0 representing fully transparent and
  102. * 1.0 representing fully opaque.
  103. *
  104. * @type {Number|undefined}
  105. * @default undefined
  106. */
  107. this.defaultAlpha = undefined;
  108. /**
  109. * The default alpha blending value on the night side of the globe of this provider, with 0.0 representing fully transparent and
  110. * 1.0 representing fully opaque.
  111. *
  112. * @type {Number|undefined}
  113. * @default undefined
  114. */
  115. this.defaultNightAlpha = undefined;
  116. /**
  117. * The default alpha blending value on the day side of the globe of this provider, with 0.0 representing fully transparent and
  118. * 1.0 representing fully opaque.
  119. *
  120. * @type {Number|undefined}
  121. * @default undefined
  122. */
  123. this.defaultDayAlpha = undefined;
  124. /**
  125. * The default brightness of this provider. 1.0 uses the unmodified imagery color. Less than 1.0
  126. * makes the imagery darker while greater than 1.0 makes it brighter.
  127. *
  128. * @type {Number|undefined}
  129. * @default undefined
  130. */
  131. this.defaultBrightness = undefined;
  132. /**
  133. * The default contrast of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces
  134. * the contrast while greater than 1.0 increases it.
  135. *
  136. * @type {Number|undefined}
  137. * @default undefined
  138. */
  139. this.defaultContrast = undefined;
  140. /**
  141. * The default hue of this provider in radians. 0.0 uses the unmodified imagery color.
  142. *
  143. * @type {Number|undefined}
  144. * @default undefined
  145. */
  146. this.defaultHue = undefined;
  147. /**
  148. * The default saturation of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces the
  149. * saturation while greater than 1.0 increases it.
  150. *
  151. * @type {Number|undefined}
  152. * @default undefined
  153. */
  154. this.defaultSaturation = undefined;
  155. /**
  156. * The default gamma correction to apply to this provider. 1.0 uses the unmodified imagery color.
  157. *
  158. * @type {Number|undefined}
  159. * @default 1.9
  160. */
  161. this.defaultGamma = 1.9;
  162. /**
  163. * The default texture minification filter to apply to this provider.
  164. *
  165. * @type {TextureMinificationFilter}
  166. * @default undefined
  167. */
  168. this.defaultMinificationFilter = undefined;
  169. /**
  170. * The default texture magnification filter to apply to this provider.
  171. *
  172. * @type {TextureMagnificationFilter}
  173. * @default undefined
  174. */
  175. this.defaultMagnificationFilter = undefined;
  176. var url = options.url;
  177. var path = defaultValue(options.path, "/default_map");
  178. var resource = Resource.createIfNeeded(url).getDerivedResource({
  179. // We used to just append path to url, so now that we do proper URI resolution, removed the /
  180. url: path[0] === "/" ? path.substring(1) : path,
  181. });
  182. resource.appendForwardSlash();
  183. this._resource = resource;
  184. this._url = url;
  185. this._path = path;
  186. this._tileDiscardPolicy = options.tileDiscardPolicy;
  187. this._channel = options.channel;
  188. this._requestType = "ImageryMaps";
  189. this._credit = new Credit(
  190. '<a href="http://www.google.com/enterprise/mapsearth/products/earthenterprise.html"><img src="' +
  191. GoogleEarthEnterpriseMapsProvider.logoUrl +
  192. '" title="Google Imagery"/></a>'
  193. );
  194. this._tilingScheme = undefined;
  195. this._version = undefined;
  196. this._tileWidth = 256;
  197. this._tileHeight = 256;
  198. this._maximumLevel = options.maximumLevel;
  199. this._errorEvent = new Event();
  200. this._ready = false;
  201. this._readyPromise = when.defer();
  202. var metadataResource = resource.getDerivedResource({
  203. url: "query",
  204. queryParameters: {
  205. request: "Json",
  206. vars: "geeServerDefs",
  207. is2d: "t",
  208. },
  209. });
  210. var that = this;
  211. var metadataError;
  212. function metadataSuccess(text) {
  213. var data;
  214. // The Google Earth server sends malformed JSON data currently...
  215. try {
  216. // First, try parsing it like normal in case a future version sends correctly formatted JSON
  217. data = JSON.parse(text);
  218. } catch (e) {
  219. // Quote object strings manually, then try parsing again
  220. data = JSON.parse(
  221. text.replace(/([\[\{,])[\n\r ]*([A-Za-z0-9]+)[\n\r ]*:/g, '$1"$2":')
  222. );
  223. }
  224. var layer;
  225. for (var i = 0; i < data.layers.length; i++) {
  226. if (data.layers[i].id === that._channel) {
  227. layer = data.layers[i];
  228. break;
  229. }
  230. }
  231. var message;
  232. if (!defined(layer)) {
  233. message =
  234. "Could not find layer with channel (id) of " + that._channel + ".";
  235. metadataError = TileProviderError.handleError(
  236. metadataError,
  237. that,
  238. that._errorEvent,
  239. message,
  240. undefined,
  241. undefined,
  242. undefined,
  243. requestMetadata
  244. );
  245. throw new RuntimeError(message);
  246. }
  247. if (!defined(layer.version)) {
  248. message =
  249. "Could not find a version in channel (id) " + that._channel + ".";
  250. metadataError = TileProviderError.handleError(
  251. metadataError,
  252. that,
  253. that._errorEvent,
  254. message,
  255. undefined,
  256. undefined,
  257. undefined,
  258. requestMetadata
  259. );
  260. throw new RuntimeError(message);
  261. }
  262. that._version = layer.version;
  263. if (defined(data.projection) && data.projection === "flat") {
  264. that._tilingScheme = new GeographicTilingScheme({
  265. numberOfLevelZeroTilesX: 2,
  266. numberOfLevelZeroTilesY: 2,
  267. rectangle: new Rectangle(-Math.PI, -Math.PI, Math.PI, Math.PI),
  268. ellipsoid: options.ellipsoid,
  269. });
  270. // Default to mercator projection when projection is undefined
  271. } else if (!defined(data.projection) || data.projection === "mercator") {
  272. that._tilingScheme = new WebMercatorTilingScheme({
  273. numberOfLevelZeroTilesX: 2,
  274. numberOfLevelZeroTilesY: 2,
  275. ellipsoid: options.ellipsoid,
  276. });
  277. } else {
  278. message = "Unsupported projection " + data.projection + ".";
  279. metadataError = TileProviderError.handleError(
  280. metadataError,
  281. that,
  282. that._errorEvent,
  283. message,
  284. undefined,
  285. undefined,
  286. undefined,
  287. requestMetadata
  288. );
  289. throw new RuntimeError(message);
  290. }
  291. that._ready = true;
  292. that._readyPromise.resolve(true);
  293. TileProviderError.handleSuccess(metadataError);
  294. }
  295. function metadataFailure(e) {
  296. var message =
  297. "An error occurred while accessing " + metadataResource.url + ".";
  298. metadataError = TileProviderError.handleError(
  299. metadataError,
  300. that,
  301. that._errorEvent,
  302. message,
  303. undefined,
  304. undefined,
  305. undefined,
  306. requestMetadata
  307. );
  308. that._readyPromise.reject(new RuntimeError(message));
  309. }
  310. function requestMetadata() {
  311. var metadata = metadataResource.fetchText();
  312. when(metadata, metadataSuccess, metadataFailure);
  313. }
  314. requestMetadata();
  315. }
  316. Object.defineProperties(GoogleEarthEnterpriseMapsProvider.prototype, {
  317. /**
  318. * Gets the URL of the Google Earth MapServer.
  319. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  320. * @type {String}
  321. * @readonly
  322. */
  323. url: {
  324. get: function () {
  325. return this._url;
  326. },
  327. },
  328. /**
  329. * Gets the url path of the data on the Google Earth server.
  330. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  331. * @type {String}
  332. * @readonly
  333. */
  334. path: {
  335. get: function () {
  336. return this._path;
  337. },
  338. },
  339. /**
  340. * Gets the proxy used by this provider.
  341. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  342. * @type {Proxy}
  343. * @readonly
  344. */
  345. proxy: {
  346. get: function () {
  347. return this._resource.proxy;
  348. },
  349. },
  350. /**
  351. * Gets the imagery channel (id) currently being used.
  352. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  353. * @type {Number}
  354. * @readonly
  355. */
  356. channel: {
  357. get: function () {
  358. return this._channel;
  359. },
  360. },
  361. /**
  362. * Gets the width of each tile, in pixels. This function should
  363. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  364. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  365. * @type {Number}
  366. * @readonly
  367. */
  368. tileWidth: {
  369. get: function () {
  370. //>>includeStart('debug', pragmas.debug);
  371. if (!this._ready) {
  372. throw new DeveloperError(
  373. "tileWidth must not be called before the imagery provider is ready."
  374. );
  375. }
  376. //>>includeEnd('debug');
  377. return this._tileWidth;
  378. },
  379. },
  380. /**
  381. * Gets the height of each tile, in pixels. This function should
  382. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  383. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  384. * @type {Number}
  385. * @readonly
  386. */
  387. tileHeight: {
  388. get: function () {
  389. //>>includeStart('debug', pragmas.debug);
  390. if (!this._ready) {
  391. throw new DeveloperError(
  392. "tileHeight must not be called before the imagery provider is ready."
  393. );
  394. }
  395. //>>includeEnd('debug');
  396. return this._tileHeight;
  397. },
  398. },
  399. /**
  400. * Gets the maximum level-of-detail that can be requested. This function should
  401. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  402. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  403. * @type {Number|undefined}
  404. * @readonly
  405. */
  406. maximumLevel: {
  407. get: function () {
  408. //>>includeStart('debug', pragmas.debug);
  409. if (!this._ready) {
  410. throw new DeveloperError(
  411. "maximumLevel must not be called before the imagery provider is ready."
  412. );
  413. }
  414. //>>includeEnd('debug');
  415. return this._maximumLevel;
  416. },
  417. },
  418. /**
  419. * Gets the minimum level-of-detail that can be requested. This function should
  420. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  421. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  422. * @type {Number}
  423. * @readonly
  424. */
  425. minimumLevel: {
  426. get: function () {
  427. //>>includeStart('debug', pragmas.debug);
  428. if (!this._ready) {
  429. throw new DeveloperError(
  430. "minimumLevel must not be called before the imagery provider is ready."
  431. );
  432. }
  433. //>>includeEnd('debug');
  434. return 0;
  435. },
  436. },
  437. /**
  438. * Gets the tiling scheme used by this provider. This function should
  439. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  440. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  441. * @type {TilingScheme}
  442. * @readonly
  443. */
  444. tilingScheme: {
  445. get: function () {
  446. //>>includeStart('debug', pragmas.debug);
  447. if (!this._ready) {
  448. throw new DeveloperError(
  449. "tilingScheme must not be called before the imagery provider is ready."
  450. );
  451. }
  452. //>>includeEnd('debug');
  453. return this._tilingScheme;
  454. },
  455. },
  456. /**
  457. * Gets the version of the data used by this provider. This function should
  458. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  459. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  460. * @type {Number}
  461. * @readonly
  462. */
  463. version: {
  464. get: function () {
  465. //>>includeStart('debug', pragmas.debug);
  466. if (!this._ready) {
  467. throw new DeveloperError(
  468. "version must not be called before the imagery provider is ready."
  469. );
  470. }
  471. //>>includeEnd('debug');
  472. return this._version;
  473. },
  474. },
  475. /**
  476. * Gets the type of data that is being requested from the provider. This function should
  477. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  478. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  479. * @type {String}
  480. * @readonly
  481. */
  482. requestType: {
  483. get: function () {
  484. //>>includeStart('debug', pragmas.debug);
  485. if (!this._ready) {
  486. throw new DeveloperError(
  487. "requestType must not be called before the imagery provider is ready."
  488. );
  489. }
  490. //>>includeEnd('debug');
  491. return this._requestType;
  492. },
  493. },
  494. /**
  495. * Gets the rectangle, in radians, of the imagery provided by this instance. This function should
  496. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  497. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  498. * @type {Rectangle}
  499. * @readonly
  500. */
  501. rectangle: {
  502. get: function () {
  503. //>>includeStart('debug', pragmas.debug);
  504. if (!this._ready) {
  505. throw new DeveloperError(
  506. "rectangle must not be called before the imagery provider is ready."
  507. );
  508. }
  509. //>>includeEnd('debug');
  510. return this._tilingScheme.rectangle;
  511. },
  512. },
  513. /**
  514. * Gets the tile discard policy. If not undefined, the discard policy is responsible
  515. * for filtering out "missing" tiles via its shouldDiscardImage function. If this function
  516. * returns undefined, no tiles are filtered. This function should
  517. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  518. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  519. * @type {TileDiscardPolicy}
  520. * @readonly
  521. */
  522. tileDiscardPolicy: {
  523. get: function () {
  524. //>>includeStart('debug', pragmas.debug);
  525. if (!this._ready) {
  526. throw new DeveloperError(
  527. "tileDiscardPolicy must not be called before the imagery provider is ready."
  528. );
  529. }
  530. //>>includeEnd('debug');
  531. return this._tileDiscardPolicy;
  532. },
  533. },
  534. /**
  535. * Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
  536. * to the event, you will be notified of the error and can potentially recover from it. Event listeners
  537. * are passed an instance of {@link TileProviderError}.
  538. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  539. * @type {Event}
  540. * @readonly
  541. */
  542. errorEvent: {
  543. get: function () {
  544. return this._errorEvent;
  545. },
  546. },
  547. /**
  548. * Gets a value indicating whether or not the provider is ready for use.
  549. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  550. * @type {Boolean}
  551. * @readonly
  552. */
  553. ready: {
  554. get: function () {
  555. return this._ready;
  556. },
  557. },
  558. /**
  559. * Gets a promise that resolves to true when the provider is ready for use.
  560. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  561. * @type {Promise.<Boolean>}
  562. * @readonly
  563. */
  564. readyPromise: {
  565. get: function () {
  566. return this._readyPromise.promise;
  567. },
  568. },
  569. /**
  570. * Gets the credit to display when this imagery provider is active. Typically this is used to credit
  571. * the source of the imagery. This function should not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  572. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  573. * @type {Credit}
  574. * @readonly
  575. */
  576. credit: {
  577. get: function () {
  578. return this._credit;
  579. },
  580. },
  581. /**
  582. * Gets a value indicating whether or not the images provided by this imagery provider
  583. * include an alpha channel. If this property is false, an alpha channel, if present, will
  584. * be ignored. If this property is true, any images without an alpha channel will be treated
  585. * as if their alpha is 1.0 everywhere. When this property is false, memory usage
  586. * and texture upload time are reduced.
  587. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  588. * @type {Boolean}
  589. * @readonly
  590. */
  591. hasAlphaChannel: {
  592. get: function () {
  593. return true;
  594. },
  595. },
  596. });
  597. /**
  598. * Gets the credits to be displayed when a given tile is displayed.
  599. *
  600. * @param {Number} x The tile X coordinate.
  601. * @param {Number} y The tile Y coordinate.
  602. * @param {Number} level The tile level;
  603. * @returns {Credit[]} The credits to be displayed when the tile is displayed.
  604. *
  605. * @exception {DeveloperError} <code>getTileCredits</code> must not be called before the imagery provider is ready.
  606. */
  607. GoogleEarthEnterpriseMapsProvider.prototype.getTileCredits = function (
  608. x,
  609. y,
  610. level
  611. ) {
  612. return undefined;
  613. };
  614. /**
  615. * Requests the image for a given tile. This function should
  616. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  617. *
  618. * @param {Number} x The tile X coordinate.
  619. * @param {Number} y The tile Y coordinate.
  620. * @param {Number} level The tile level.
  621. * @param {Request} [request] The request object. Intended for internal use only.
  622. * @returns {Promise.<HTMLImageElement|HTMLCanvasElement>|undefined} A promise for the image that will resolve when the image is available, or
  623. * undefined if there are too many active requests to the server, and the request
  624. * should be retried later. The resolved image may be either an
  625. * Image or a Canvas DOM object.
  626. *
  627. * @exception {DeveloperError} <code>requestImage</code> must not be called before the imagery provider is ready.
  628. */
  629. GoogleEarthEnterpriseMapsProvider.prototype.requestImage = function (
  630. x,
  631. y,
  632. level,
  633. request
  634. ) {
  635. //>>includeStart('debug', pragmas.debug);
  636. if (!this._ready) {
  637. throw new DeveloperError(
  638. "requestImage must not be called before the imagery provider is ready."
  639. );
  640. }
  641. //>>includeEnd('debug');
  642. var resource = this._resource.getDerivedResource({
  643. url: "query",
  644. request: request,
  645. queryParameters: {
  646. request: this._requestType,
  647. channel: this._channel,
  648. version: this._version,
  649. x: x,
  650. y: y,
  651. z: level + 1, // Google Earth starts with a zoom level of 1, not 0
  652. },
  653. });
  654. return ImageryProvider.loadImage(this, resource);
  655. };
  656. /**
  657. * Picking features is not currently supported by this imagery provider, so this function simply returns
  658. * undefined.
  659. *
  660. * @param {Number} x The tile X coordinate.
  661. * @param {Number} y The tile Y coordinate.
  662. * @param {Number} level The tile level.
  663. * @param {Number} longitude The longitude at which to pick features.
  664. * @param {Number} latitude The latitude at which to pick features.
  665. * @return {Promise.<ImageryLayerFeatureInfo[]>|undefined} A promise for the picked features that will resolve when the asynchronous
  666. * picking completes. The resolved value is an array of {@link ImageryLayerFeatureInfo}
  667. * instances. The array may be empty if no features are found at the given location.
  668. * It may also be undefined if picking is not supported.
  669. */
  670. GoogleEarthEnterpriseMapsProvider.prototype.pickFeatures = function (
  671. x,
  672. y,
  673. level,
  674. longitude,
  675. latitude
  676. ) {
  677. return undefined;
  678. };
  679. GoogleEarthEnterpriseMapsProvider._logoUrl = undefined;
  680. Object.defineProperties(GoogleEarthEnterpriseMapsProvider, {
  681. /**
  682. * Gets or sets the URL to the Google Earth logo for display in the credit.
  683. * @memberof GoogleEarthEnterpriseMapsProvider
  684. * @type {String}
  685. */
  686. logoUrl: {
  687. get: function () {
  688. if (!defined(GoogleEarthEnterpriseMapsProvider._logoUrl)) {
  689. GoogleEarthEnterpriseMapsProvider._logoUrl = buildModuleUrl(
  690. "Assets/Images/google_earth_credit.png"
  691. );
  692. }
  693. return GoogleEarthEnterpriseMapsProvider._logoUrl;
  694. },
  695. set: function (value) {
  696. //>>includeStart('debug', pragmas.debug);
  697. Check.defined("value", value);
  698. //>>includeEnd('debug');
  699. GoogleEarthEnterpriseMapsProvider._logoUrl = value;
  700. },
  701. },
  702. });
  703. export default GoogleEarthEnterpriseMapsProvider;