GoogleEarthEnterpriseMapsProvider.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  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 defer from "../Core/defer.js";
  6. import defined from "../Core/defined.js";
  7. import DeveloperError from "../Core/DeveloperError.js";
  8. import Event from "../Core/Event.js";
  9. import GeographicTilingScheme from "../Core/GeographicTilingScheme.js";
  10. import Rectangle from "../Core/Rectangle.js";
  11. import Resource from "../Core/Resource.js";
  12. import RuntimeError from "../Core/RuntimeError.js";
  13. import TileProviderError from "../Core/TileProviderError.js";
  14. import WebMercatorTilingScheme from "../Core/WebMercatorTilingScheme.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. * const 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. const url = options.url;
  177. const path = defaultValue(options.path, "/default_map");
  178. const 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="${GoogleEarthEnterpriseMapsProvider.logoUrl}" title="Google Imagery"/></a>`
  191. );
  192. this._tilingScheme = undefined;
  193. this._version = undefined;
  194. this._tileWidth = 256;
  195. this._tileHeight = 256;
  196. this._maximumLevel = options.maximumLevel;
  197. this._errorEvent = new Event();
  198. this._ready = false;
  199. this._readyPromise = defer();
  200. const metadataResource = resource.getDerivedResource({
  201. url: "query",
  202. queryParameters: {
  203. request: "Json",
  204. vars: "geeServerDefs",
  205. is2d: "t",
  206. },
  207. });
  208. const that = this;
  209. let metadataError;
  210. function metadataSuccess(text) {
  211. let data;
  212. // The Google Earth server sends malformed JSON data currently...
  213. try {
  214. // First, try parsing it like normal in case a future version sends correctly formatted JSON
  215. data = JSON.parse(text);
  216. } catch (e) {
  217. // Quote object strings manually, then try parsing again
  218. data = JSON.parse(
  219. text.replace(/([\[\{,])[\n\r ]*([A-Za-z0-9]+)[\n\r ]*:/g, '$1"$2":')
  220. );
  221. }
  222. let layer;
  223. for (let i = 0; i < data.layers.length; i++) {
  224. if (data.layers[i].id === that._channel) {
  225. layer = data.layers[i];
  226. break;
  227. }
  228. }
  229. let message;
  230. if (!defined(layer)) {
  231. message = `Could not find layer with channel (id) of ${that._channel}.`;
  232. metadataError = TileProviderError.handleError(
  233. metadataError,
  234. that,
  235. that._errorEvent,
  236. message,
  237. undefined,
  238. undefined,
  239. undefined,
  240. requestMetadata
  241. );
  242. throw new RuntimeError(message);
  243. }
  244. if (!defined(layer.version)) {
  245. message = `Could not find a version in channel (id) ${that._channel}.`;
  246. metadataError = TileProviderError.handleError(
  247. metadataError,
  248. that,
  249. that._errorEvent,
  250. message,
  251. undefined,
  252. undefined,
  253. undefined,
  254. requestMetadata
  255. );
  256. throw new RuntimeError(message);
  257. }
  258. that._version = layer.version;
  259. if (defined(data.projection) && data.projection === "flat") {
  260. that._tilingScheme = new GeographicTilingScheme({
  261. numberOfLevelZeroTilesX: 2,
  262. numberOfLevelZeroTilesY: 2,
  263. rectangle: new Rectangle(-Math.PI, -Math.PI, Math.PI, Math.PI),
  264. ellipsoid: options.ellipsoid,
  265. });
  266. // Default to mercator projection when projection is undefined
  267. } else if (!defined(data.projection) || data.projection === "mercator") {
  268. that._tilingScheme = new WebMercatorTilingScheme({
  269. numberOfLevelZeroTilesX: 2,
  270. numberOfLevelZeroTilesY: 2,
  271. ellipsoid: options.ellipsoid,
  272. });
  273. } else {
  274. message = `Unsupported projection ${data.projection}.`;
  275. metadataError = TileProviderError.handleError(
  276. metadataError,
  277. that,
  278. that._errorEvent,
  279. message,
  280. undefined,
  281. undefined,
  282. undefined,
  283. requestMetadata
  284. );
  285. throw new RuntimeError(message);
  286. }
  287. that._ready = true;
  288. that._readyPromise.resolve(true);
  289. TileProviderError.handleSuccess(metadataError);
  290. }
  291. function metadataFailure(e) {
  292. const message = defaultValue(
  293. e.message,
  294. `An error occurred while accessing ${metadataResource.url}.`
  295. );
  296. metadataError = TileProviderError.handleError(
  297. metadataError,
  298. that,
  299. that._errorEvent,
  300. message,
  301. undefined,
  302. undefined,
  303. undefined,
  304. requestMetadata
  305. );
  306. that._readyPromise.reject(new RuntimeError(message));
  307. }
  308. function requestMetadata() {
  309. metadataResource
  310. .fetchText()
  311. .then(function (text) {
  312. metadataSuccess(text);
  313. })
  314. .catch(function (e) {
  315. metadataFailure(e);
  316. });
  317. }
  318. requestMetadata();
  319. }
  320. Object.defineProperties(GoogleEarthEnterpriseMapsProvider.prototype, {
  321. /**
  322. * Gets the URL of the Google Earth MapServer.
  323. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  324. * @type {String}
  325. * @readonly
  326. */
  327. url: {
  328. get: function () {
  329. return this._url;
  330. },
  331. },
  332. /**
  333. * Gets the url path of the data on the Google Earth server.
  334. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  335. * @type {String}
  336. * @readonly
  337. */
  338. path: {
  339. get: function () {
  340. return this._path;
  341. },
  342. },
  343. /**
  344. * Gets the proxy used by this provider.
  345. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  346. * @type {Proxy}
  347. * @readonly
  348. */
  349. proxy: {
  350. get: function () {
  351. return this._resource.proxy;
  352. },
  353. },
  354. /**
  355. * Gets the imagery channel (id) currently being used.
  356. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  357. * @type {Number}
  358. * @readonly
  359. */
  360. channel: {
  361. get: function () {
  362. return this._channel;
  363. },
  364. },
  365. /**
  366. * Gets the width of each tile, in pixels. This function should
  367. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  368. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  369. * @type {Number}
  370. * @readonly
  371. */
  372. tileWidth: {
  373. get: function () {
  374. //>>includeStart('debug', pragmas.debug);
  375. if (!this._ready) {
  376. throw new DeveloperError(
  377. "tileWidth must not be called before the imagery provider is ready."
  378. );
  379. }
  380. //>>includeEnd('debug');
  381. return this._tileWidth;
  382. },
  383. },
  384. /**
  385. * Gets the height of each tile, in pixels. This function should
  386. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  387. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  388. * @type {Number}
  389. * @readonly
  390. */
  391. tileHeight: {
  392. get: function () {
  393. //>>includeStart('debug', pragmas.debug);
  394. if (!this._ready) {
  395. throw new DeveloperError(
  396. "tileHeight must not be called before the imagery provider is ready."
  397. );
  398. }
  399. //>>includeEnd('debug');
  400. return this._tileHeight;
  401. },
  402. },
  403. /**
  404. * Gets the maximum level-of-detail that can be requested. This function should
  405. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  406. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  407. * @type {Number|undefined}
  408. * @readonly
  409. */
  410. maximumLevel: {
  411. get: function () {
  412. //>>includeStart('debug', pragmas.debug);
  413. if (!this._ready) {
  414. throw new DeveloperError(
  415. "maximumLevel must not be called before the imagery provider is ready."
  416. );
  417. }
  418. //>>includeEnd('debug');
  419. return this._maximumLevel;
  420. },
  421. },
  422. /**
  423. * Gets the minimum level-of-detail that can be requested. This function should
  424. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  425. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  426. * @type {Number}
  427. * @readonly
  428. */
  429. minimumLevel: {
  430. get: function () {
  431. //>>includeStart('debug', pragmas.debug);
  432. if (!this._ready) {
  433. throw new DeveloperError(
  434. "minimumLevel must not be called before the imagery provider is ready."
  435. );
  436. }
  437. //>>includeEnd('debug');
  438. return 0;
  439. },
  440. },
  441. /**
  442. * Gets the tiling scheme used by this provider. This function should
  443. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  444. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  445. * @type {TilingScheme}
  446. * @readonly
  447. */
  448. tilingScheme: {
  449. get: function () {
  450. //>>includeStart('debug', pragmas.debug);
  451. if (!this._ready) {
  452. throw new DeveloperError(
  453. "tilingScheme must not be called before the imagery provider is ready."
  454. );
  455. }
  456. //>>includeEnd('debug');
  457. return this._tilingScheme;
  458. },
  459. },
  460. /**
  461. * Gets the version of the data used by this provider. This function should
  462. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  463. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  464. * @type {Number}
  465. * @readonly
  466. */
  467. version: {
  468. get: function () {
  469. //>>includeStart('debug', pragmas.debug);
  470. if (!this._ready) {
  471. throw new DeveloperError(
  472. "version must not be called before the imagery provider is ready."
  473. );
  474. }
  475. //>>includeEnd('debug');
  476. return this._version;
  477. },
  478. },
  479. /**
  480. * Gets the type of data that is being requested from the provider. This function should
  481. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  482. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  483. * @type {String}
  484. * @readonly
  485. */
  486. requestType: {
  487. get: function () {
  488. //>>includeStart('debug', pragmas.debug);
  489. if (!this._ready) {
  490. throw new DeveloperError(
  491. "requestType must not be called before the imagery provider is ready."
  492. );
  493. }
  494. //>>includeEnd('debug');
  495. return this._requestType;
  496. },
  497. },
  498. /**
  499. * Gets the rectangle, in radians, of the imagery provided by this instance. This function should
  500. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  501. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  502. * @type {Rectangle}
  503. * @readonly
  504. */
  505. rectangle: {
  506. get: function () {
  507. //>>includeStart('debug', pragmas.debug);
  508. if (!this._ready) {
  509. throw new DeveloperError(
  510. "rectangle must not be called before the imagery provider is ready."
  511. );
  512. }
  513. //>>includeEnd('debug');
  514. return this._tilingScheme.rectangle;
  515. },
  516. },
  517. /**
  518. * Gets the tile discard policy. If not undefined, the discard policy is responsible
  519. * for filtering out "missing" tiles via its shouldDiscardImage function. If this function
  520. * returns undefined, no tiles are filtered. This function should
  521. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  522. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  523. * @type {TileDiscardPolicy}
  524. * @readonly
  525. */
  526. tileDiscardPolicy: {
  527. get: function () {
  528. //>>includeStart('debug', pragmas.debug);
  529. if (!this._ready) {
  530. throw new DeveloperError(
  531. "tileDiscardPolicy must not be called before the imagery provider is ready."
  532. );
  533. }
  534. //>>includeEnd('debug');
  535. return this._tileDiscardPolicy;
  536. },
  537. },
  538. /**
  539. * Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
  540. * to the event, you will be notified of the error and can potentially recover from it. Event listeners
  541. * are passed an instance of {@link TileProviderError}.
  542. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  543. * @type {Event}
  544. * @readonly
  545. */
  546. errorEvent: {
  547. get: function () {
  548. return this._errorEvent;
  549. },
  550. },
  551. /**
  552. * Gets a value indicating whether or not the provider is ready for use.
  553. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  554. * @type {Boolean}
  555. * @readonly
  556. */
  557. ready: {
  558. get: function () {
  559. return this._ready;
  560. },
  561. },
  562. /**
  563. * Gets a promise that resolves to true when the provider is ready for use.
  564. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  565. * @type {Promise.<Boolean>}
  566. * @readonly
  567. */
  568. readyPromise: {
  569. get: function () {
  570. return this._readyPromise.promise;
  571. },
  572. },
  573. /**
  574. * Gets the credit to display when this imagery provider is active. Typically this is used to credit
  575. * the source of the imagery. This function should not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  576. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  577. * @type {Credit}
  578. * @readonly
  579. */
  580. credit: {
  581. get: function () {
  582. return this._credit;
  583. },
  584. },
  585. /**
  586. * Gets a value indicating whether or not the images provided by this imagery provider
  587. * include an alpha channel. If this property is false, an alpha channel, if present, will
  588. * be ignored. If this property is true, any images without an alpha channel will be treated
  589. * as if their alpha is 1.0 everywhere. When this property is false, memory usage
  590. * and texture upload time are reduced.
  591. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  592. * @type {Boolean}
  593. * @readonly
  594. */
  595. hasAlphaChannel: {
  596. get: function () {
  597. return true;
  598. },
  599. },
  600. });
  601. /**
  602. * Gets the credits to be displayed when a given tile is displayed.
  603. *
  604. * @param {Number} x The tile X coordinate.
  605. * @param {Number} y The tile Y coordinate.
  606. * @param {Number} level The tile level;
  607. * @returns {Credit[]} The credits to be displayed when the tile is displayed.
  608. *
  609. * @exception {DeveloperError} <code>getTileCredits</code> must not be called before the imagery provider is ready.
  610. */
  611. GoogleEarthEnterpriseMapsProvider.prototype.getTileCredits = function (
  612. x,
  613. y,
  614. level
  615. ) {
  616. return undefined;
  617. };
  618. /**
  619. * Requests the image for a given tile. This function should
  620. * not be called before {@link GoogleEarthEnterpriseMapsProvider#ready} returns true.
  621. *
  622. * @param {Number} x The tile X coordinate.
  623. * @param {Number} y The tile Y coordinate.
  624. * @param {Number} level The tile level.
  625. * @param {Request} [request] The request object. Intended for internal use only.
  626. * @returns {Promise.<ImageryTypes>|undefined} A promise for the image that will resolve when the image is available, or
  627. * undefined if there are too many active requests to the server, and the request should be retried later.
  628. *
  629. * @exception {DeveloperError} <code>requestImage</code> must not be called before the imagery provider is ready.
  630. */
  631. GoogleEarthEnterpriseMapsProvider.prototype.requestImage = function (
  632. x,
  633. y,
  634. level,
  635. request
  636. ) {
  637. //>>includeStart('debug', pragmas.debug);
  638. if (!this._ready) {
  639. throw new DeveloperError(
  640. "requestImage must not be called before the imagery provider is ready."
  641. );
  642. }
  643. //>>includeEnd('debug');
  644. const resource = this._resource.getDerivedResource({
  645. url: "query",
  646. request: request,
  647. queryParameters: {
  648. request: this._requestType,
  649. channel: this._channel,
  650. version: this._version,
  651. x: x,
  652. y: y,
  653. z: level + 1, // Google Earth starts with a zoom level of 1, not 0
  654. },
  655. });
  656. return ImageryProvider.loadImage(this, resource);
  657. };
  658. /**
  659. * Picking features is not currently supported by this imagery provider, so this function simply returns
  660. * undefined.
  661. *
  662. * @param {Number} x The tile X coordinate.
  663. * @param {Number} y The tile Y coordinate.
  664. * @param {Number} level The tile level.
  665. * @param {Number} longitude The longitude at which to pick features.
  666. * @param {Number} latitude The latitude at which to pick features.
  667. * @return {undefined} Undefined since picking is not supported.
  668. */
  669. GoogleEarthEnterpriseMapsProvider.prototype.pickFeatures = function (
  670. x,
  671. y,
  672. level,
  673. longitude,
  674. latitude
  675. ) {
  676. return undefined;
  677. };
  678. GoogleEarthEnterpriseMapsProvider._logoUrl = undefined;
  679. Object.defineProperties(GoogleEarthEnterpriseMapsProvider, {
  680. /**
  681. * Gets or sets the URL to the Google Earth logo for display in the credit.
  682. * @memberof GoogleEarthEnterpriseMapsProvider
  683. * @type {String}
  684. */
  685. logoUrl: {
  686. get: function () {
  687. if (!defined(GoogleEarthEnterpriseMapsProvider._logoUrl)) {
  688. GoogleEarthEnterpriseMapsProvider._logoUrl = buildModuleUrl(
  689. "Assets/Images/google_earth_credit.png"
  690. );
  691. }
  692. return GoogleEarthEnterpriseMapsProvider._logoUrl;
  693. },
  694. set: function (value) {
  695. //>>includeStart('debug', pragmas.debug);
  696. Check.defined("value", value);
  697. //>>includeEnd('debug');
  698. GoogleEarthEnterpriseMapsProvider._logoUrl = value;
  699. },
  700. },
  701. });
  702. export default GoogleEarthEnterpriseMapsProvider;