GoogleEarthEnterpriseMapsProvider.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  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 deprecationWarning from "../Core/deprecationWarning.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. Deprecated.
  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. * Used to track creation details while fetching initial metadata
  50. *
  51. * @constructor
  52. * @private
  53. *
  54. * @param {GoogleEarthEnterpriseMapsProvider.ConstructorOptions} options An object describing initialization options
  55. */
  56. function ImageryProviderBuilder(options) {
  57. this.channel = options.channel;
  58. this.ellipsoid = options.ellipsoid;
  59. this.tilingScheme = undefined;
  60. this.version = undefined;
  61. }
  62. /**
  63. * Complete GoogleEarthEnterpriseMapsProvider creation based on builder values.
  64. *
  65. * @private
  66. *
  67. * @param {GoogleEarthEnterpriseMapsProvider} provider
  68. */
  69. ImageryProviderBuilder.prototype.build = function (provider) {
  70. provider._channel = this.channel;
  71. provider._version = this.version;
  72. provider._tilingScheme = this.tilingScheme;
  73. };
  74. function metadataSuccess(text, imageryProviderBuilder) {
  75. let data;
  76. // The Google Earth server sends malformed JSON data currently...
  77. try {
  78. // First, try parsing it like normal in case a future version sends correctly formatted JSON
  79. data = JSON.parse(text);
  80. } catch (e) {
  81. // Quote object strings manually, then try parsing again
  82. data = JSON.parse(
  83. text.replace(/([\[\{,])[\n\r ]*([A-Za-z0-9]+)[\n\r ]*:/g, '$1"$2":')
  84. );
  85. }
  86. let layer;
  87. for (let i = 0; i < data.layers.length; i++) {
  88. if (data.layers[i].id === imageryProviderBuilder.channel) {
  89. layer = data.layers[i];
  90. break;
  91. }
  92. }
  93. if (!defined(layer)) {
  94. const message = `Could not find layer with channel (id) of ${imageryProviderBuilder.channel}.`;
  95. throw new RuntimeError(message);
  96. }
  97. if (!defined(layer.version)) {
  98. const message = `Could not find a version in channel (id) ${imageryProviderBuilder.channel}.`;
  99. throw new RuntimeError(message);
  100. }
  101. imageryProviderBuilder.version = layer.version;
  102. if (defined(data.projection) && data.projection === "flat") {
  103. imageryProviderBuilder.tilingScheme = new GeographicTilingScheme({
  104. numberOfLevelZeroTilesX: 2,
  105. numberOfLevelZeroTilesY: 2,
  106. rectangle: new Rectangle(-Math.PI, -Math.PI, Math.PI, Math.PI),
  107. ellipsoid: imageryProviderBuilder.ellipsoid,
  108. });
  109. // Default to mercator projection when projection is undefined
  110. } else if (!defined(data.projection) || data.projection === "mercator") {
  111. imageryProviderBuilder.tilingScheme = new WebMercatorTilingScheme({
  112. numberOfLevelZeroTilesX: 2,
  113. numberOfLevelZeroTilesY: 2,
  114. ellipsoid: imageryProviderBuilder.ellipsoid,
  115. });
  116. } else {
  117. const message = `Unsupported projection ${data.projection}.`;
  118. throw new RuntimeError(message);
  119. }
  120. return true;
  121. }
  122. function metadataFailure(error, metadataResource, provider) {
  123. let message = `An error occurred while accessing ${metadataResource.url}.`;
  124. if (defined(error) && defined(error.message)) {
  125. message += `: ${error.message}`;
  126. }
  127. TileProviderError.reportError(
  128. undefined,
  129. provider,
  130. defined(provider) ? provider._errorEvent : undefined,
  131. message
  132. );
  133. throw new RuntimeError(message);
  134. }
  135. async function requestMetadata(
  136. metadataResource,
  137. imageryProviderBuilder,
  138. provider
  139. ) {
  140. try {
  141. const text = await metadataResource.fetchText();
  142. metadataSuccess(text, imageryProviderBuilder);
  143. } catch (error) {
  144. metadataFailure(error, metadataResource, provider);
  145. }
  146. }
  147. /**
  148. * <div class="notice">
  149. * To construct a GoogleEarthEnterpriseMapsProvider, call {@link GoogleEarthEnterpriseImageryProvider.fromUrl}. Do not call the constructor directly.
  150. * </div>
  151. *
  152. * Provides tiled imagery using the Google Earth Imagery API.
  153. *
  154. * Notes: This imagery provider does not work with the public Google Earth servers. It works with the
  155. * Google Earth Enterprise Server.
  156. *
  157. * By default the Google Earth Enterprise server does not set the
  158. * {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing} headers. You can either
  159. * use a proxy server which adds these headers, or in the /opt/google/gehttpd/conf/gehttpd.conf
  160. * and add the 'Header set Access-Control-Allow-Origin "*"' option to the '&lt;Directory /&gt;' and
  161. * '&lt;Directory "/opt/google/gehttpd/htdocs"&gt;' directives.
  162. *
  163. * This provider is for use with 2D Maps API as part of Google Earth Enterprise. For 3D Earth API uses, it
  164. * is necessary to use {@link GoogleEarthEnterpriseImageryProvider}
  165. *
  166. * @alias GoogleEarthEnterpriseMapsProvider
  167. * @constructor
  168. *
  169. * @param {GoogleEarthEnterpriseMapsProvider.ConstructorOptions} options Object describing initialization options
  170. *
  171. * @exception {RuntimeError} Could not find layer with channel (id) of <code>options.channel</code>.
  172. * @exception {RuntimeError} Could not find a version in channel (id) <code>options.channel</code>.
  173. * @exception {RuntimeError} Unsupported projection <code>data.projection</code>.
  174. *
  175. * @see ArcGisMapServerImageryProvider
  176. * @see BingMapsImageryProvider
  177. * @see OpenStreetMapImageryProvider
  178. * @see SingleTileImageryProvider
  179. * @see TileMapServiceImageryProvider
  180. * @see WebMapServiceImageryProvider
  181. * @see WebMapTileServiceImageryProvider
  182. * @see UrlTemplateImageryProvider
  183. *
  184. *
  185. * @example
  186. * const google = await Cesium.GoogleEarthEnterpriseMapsProvider.fromUrl("https://earth.localdomain", 1008);
  187. *
  188. * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
  189. */
  190. function GoogleEarthEnterpriseMapsProvider(options) {
  191. options = defaultValue(options, {});
  192. this._defaultAlpha = undefined;
  193. this._defaultNightAlpha = undefined;
  194. this._defaultDayAlpha = undefined;
  195. this._defaultBrightness = undefined;
  196. this._defaultContrast = undefined;
  197. this._defaultHue = undefined;
  198. this._defaultSaturation = undefined;
  199. this._defaultGamma = 1.9;
  200. this._defaultMinificationFilter = undefined;
  201. this._defaultMagnificationFilter = undefined;
  202. this._tileDiscardPolicy = options.tileDiscardPolicy;
  203. this._channel = options.channel;
  204. this._requestType = "ImageryMaps";
  205. this._credit = new Credit(
  206. `<a href="http://www.google.com/enterprise/mapsearth/products/earthenterprise.html"><img src="${GoogleEarthEnterpriseMapsProvider.logoUrl}" title="Google Imagery"/></a>`
  207. );
  208. this._tilingScheme = undefined;
  209. this._version = undefined;
  210. this._tileWidth = 256;
  211. this._tileHeight = 256;
  212. this._maximumLevel = options.maximumLevel;
  213. this._errorEvent = new Event();
  214. if (defined(options.url) || defined(options.channel)) {
  215. //>>includeStart('debug', pragmas.debug);
  216. if (!defined(options.url)) {
  217. throw new DeveloperError("options.url is required.");
  218. }
  219. if (!defined(options.channel)) {
  220. throw new DeveloperError("options.channel is required.");
  221. }
  222. //>>includeEnd('debug');
  223. deprecationWarning(
  224. "GoogleEarthEnterpriseMapsProvider.url",
  225. "GoogleEarthEnterpriseMapsProvider.url and GoogleEarthEnterpriseMapsProvider.channel were deprecated in CesiumJS 1.104. They will be in CesiumJS 1.107. Use GoogleEarthEnterpriseMapsProvider.fromUrl instead."
  226. );
  227. const url = options.url;
  228. const path = defaultValue(options.path, "/default_map");
  229. const resource = Resource.createIfNeeded(url).getDerivedResource({
  230. // We used to just append path to url, so now that we do proper URI resolution, removed the /
  231. url: path[0] === "/" ? path.substring(1) : path,
  232. });
  233. resource.appendForwardSlash();
  234. this._resource = resource;
  235. this._url = url;
  236. this._path = path;
  237. this._ready = false;
  238. const metadataResource = resource.getDerivedResource({
  239. url: "query",
  240. queryParameters: {
  241. request: "Json",
  242. vars: "geeServerDefs",
  243. is2d: "t",
  244. },
  245. });
  246. const imageryProviderBuilder = new ImageryProviderBuilder(options);
  247. this._readyPromise = requestMetadata(
  248. metadataResource,
  249. imageryProviderBuilder,
  250. this
  251. ).then(() => {
  252. imageryProviderBuilder.build(this);
  253. this._ready = true;
  254. return true;
  255. });
  256. }
  257. }
  258. Object.defineProperties(GoogleEarthEnterpriseMapsProvider.prototype, {
  259. /**
  260. * Gets the URL of the Google Earth MapServer.
  261. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  262. * @type {string}
  263. * @readonly
  264. */
  265. url: {
  266. get: function () {
  267. return this._url;
  268. },
  269. },
  270. /**
  271. * Gets the url path of the data on the Google Earth server.
  272. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  273. * @type {string}
  274. * @readonly
  275. */
  276. path: {
  277. get: function () {
  278. return this._path;
  279. },
  280. },
  281. /**
  282. * Gets the proxy used by this provider.
  283. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  284. * @type {Proxy}
  285. * @readonly
  286. */
  287. proxy: {
  288. get: function () {
  289. return this._resource.proxy;
  290. },
  291. },
  292. /**
  293. * Gets the imagery channel (id) currently being used.
  294. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  295. * @type {number}
  296. * @readonly
  297. */
  298. channel: {
  299. get: function () {
  300. return this._channel;
  301. },
  302. },
  303. /**
  304. * Gets the width of each tile, in pixels.
  305. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  306. * @type {number}
  307. * @readonly
  308. */
  309. tileWidth: {
  310. get: function () {
  311. return this._tileWidth;
  312. },
  313. },
  314. /**
  315. * Gets the height of each tile, in pixels.
  316. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  317. * @type {number}
  318. * @readonly
  319. */
  320. tileHeight: {
  321. get: function () {
  322. return this._tileHeight;
  323. },
  324. },
  325. /**
  326. * Gets the maximum level-of-detail that can be requested.
  327. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  328. * @type {number|undefined}
  329. * @readonly
  330. */
  331. maximumLevel: {
  332. get: function () {
  333. return this._maximumLevel;
  334. },
  335. },
  336. /**
  337. * Gets the minimum level-of-detail that can be requested.
  338. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  339. * @type {number}
  340. * @readonly
  341. */
  342. minimumLevel: {
  343. get: function () {
  344. return 0;
  345. },
  346. },
  347. /**
  348. * Gets the tiling scheme used by this provider.
  349. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  350. * @type {TilingScheme}
  351. * @readonly
  352. */
  353. tilingScheme: {
  354. get: function () {
  355. return this._tilingScheme;
  356. },
  357. },
  358. /**
  359. * Gets the version of the data used by this provider.
  360. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  361. * @type {number}
  362. * @readonly
  363. */
  364. version: {
  365. get: function () {
  366. return this._version;
  367. },
  368. },
  369. /**
  370. * Gets the type of data that is being requested from the provider.
  371. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  372. * @type {string}
  373. * @readonly
  374. */
  375. requestType: {
  376. get: function () {
  377. return this._requestType;
  378. },
  379. },
  380. /**
  381. * Gets the rectangle, in radians, of the imagery provided by this instance.
  382. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  383. * @type {Rectangle}
  384. * @readonly
  385. */
  386. rectangle: {
  387. get: function () {
  388. return this._tilingScheme.rectangle;
  389. },
  390. },
  391. /**
  392. * Gets the tile discard policy. If not undefined, the discard policy is responsible
  393. * for filtering out "missing" tiles via its shouldDiscardImage function. If this function
  394. * returns undefined, no tiles are filtered.
  395. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  396. * @type {TileDiscardPolicy}
  397. * @readonly
  398. */
  399. tileDiscardPolicy: {
  400. get: function () {
  401. return this._tileDiscardPolicy;
  402. },
  403. },
  404. /**
  405. * Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
  406. * to the event, you will be notified of the error and can potentially recover from it. Event listeners
  407. * are passed an instance of {@link TileProviderError}.
  408. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  409. * @type {Event}
  410. * @readonly
  411. */
  412. errorEvent: {
  413. get: function () {
  414. return this._errorEvent;
  415. },
  416. },
  417. /**
  418. * Gets a value indicating whether or not the provider is ready for use.
  419. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  420. * @type {boolean}
  421. * @readonly
  422. * @deprecated
  423. */
  424. ready: {
  425. get: function () {
  426. deprecationWarning(
  427. "GoogleEarthEnterpriseMapsProvider.ready",
  428. "GoogleEarthEnterpriseMapsProvider.ready was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use GoogleEarthEnterpriseMapsProvider.fromUrl instead."
  429. );
  430. return this._ready;
  431. },
  432. },
  433. /**
  434. * Gets a promise that resolves to true when the provider is ready for use.
  435. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  436. * @type {Promise<boolean>}
  437. * @readonly
  438. * @deprecated
  439. */
  440. readyPromise: {
  441. get: function () {
  442. deprecationWarning(
  443. "GoogleEarthEnterpriseMapsProvider.readyPromise",
  444. "GoogleEarthEnterpriseMapsProvider.readyPromise was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use GoogleEarthEnterpriseMapsProvider.fromUrl instead."
  445. );
  446. return this._readyPromise;
  447. },
  448. },
  449. /**
  450. * Gets the credit to display when this imagery provider is active. Typically this is used to credit
  451. * the source of the imagery.
  452. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  453. * @type {Credit}
  454. * @readonly
  455. */
  456. credit: {
  457. get: function () {
  458. return this._credit;
  459. },
  460. },
  461. /**
  462. * Gets a value indicating whether or not the images provided by this imagery provider
  463. * include an alpha channel. If this property is false, an alpha channel, if present, will
  464. * be ignored. If this property is true, any images without an alpha channel will be treated
  465. * as if their alpha is 1.0 everywhere. When this property is false, memory usage
  466. * and texture upload time are reduced.
  467. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  468. * @type {boolean}
  469. * @readonly
  470. */
  471. hasAlphaChannel: {
  472. get: function () {
  473. return true;
  474. },
  475. },
  476. /**
  477. * The default alpha blending value of this provider, with 0.0 representing fully transparent and
  478. * 1.0 representing fully opaque.
  479. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  480. * @type {Number|undefined}
  481. * @deprecated
  482. */
  483. defaultAlpha: {
  484. get: function () {
  485. deprecationWarning(
  486. "GoogleEarthEnterpriseMapsProvider.defaultAlpha",
  487. "GoogleEarthEnterpriseMapsProvider.defaultAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.alpha instead."
  488. );
  489. return this._defaultAlpha;
  490. },
  491. set: function (value) {
  492. deprecationWarning(
  493. "GoogleEarthEnterpriseMapsProvider.defaultAlpha",
  494. "GoogleEarthEnterpriseMapsProvider.defaultAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.alpha instead."
  495. );
  496. this._defaultAlpha = value;
  497. },
  498. },
  499. /**
  500. * The default alpha blending value on the night side of the globe of this provider, with 0.0 representing fully transparent and
  501. * 1.0 representing fully opaque.
  502. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  503. * @type {Number|undefined}
  504. * @deprecated
  505. */
  506. defaultNightAlpha: {
  507. get: function () {
  508. deprecationWarning(
  509. "GoogleEarthEnterpriseMapsProvider.defaultNightAlpha",
  510. "GoogleEarthEnterpriseMapsProvider.defaultNightAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.nightAlpha instead."
  511. );
  512. return this.defaultNightAlpha;
  513. },
  514. set: function (value) {
  515. deprecationWarning(
  516. "GoogleEarthEnterpriseMapsProvider.defaultNightAlpha",
  517. "GoogleEarthEnterpriseMapsProvider.defaultNightAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.nightAlpha instead."
  518. );
  519. this.defaultNightAlpha = value;
  520. },
  521. },
  522. /**
  523. * The default alpha blending value on the day side of the globe of this provider, with 0.0 representing fully transparent and
  524. * 1.0 representing fully opaque.
  525. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  526. * @type {Number|undefined}
  527. * @deprecated
  528. */
  529. defaultDayAlpha: {
  530. get: function () {
  531. deprecationWarning(
  532. "GoogleEarthEnterpriseMapsProvider.defaultDayAlpha",
  533. "GoogleEarthEnterpriseMapsProvider.defaultDayAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.dayAlpha instead."
  534. );
  535. return this._defaultDayAlpha;
  536. },
  537. set: function (value) {
  538. deprecationWarning(
  539. "GoogleEarthEnterpriseMapsProvider.defaultDayAlpha",
  540. "GoogleEarthEnterpriseMapsProvider.defaultDayAlpha was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.dayAlpha instead."
  541. );
  542. this._defaultDayAlpha = value;
  543. },
  544. },
  545. /**
  546. * The default brightness of this provider. 1.0 uses the unmodified imagery color. Less than 1.0
  547. * makes the imagery darker while greater than 1.0 makes it brighter.
  548. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  549. * @type {Number|undefined}
  550. * @deprecated
  551. */
  552. defaultBrightness: {
  553. get: function () {
  554. deprecationWarning(
  555. "GoogleEarthEnterpriseMapsProvider.defaultBrightness",
  556. "GoogleEarthEnterpriseMapsProvider.defaultBrightness was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.brightness instead."
  557. );
  558. return this._defaultBrightness;
  559. },
  560. set: function (value) {
  561. deprecationWarning(
  562. "GoogleEarthEnterpriseMapsProvider.defaultBrightness",
  563. "GoogleEarthEnterpriseMapsProvider.defaultBrightness was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.brightness instead."
  564. );
  565. this._defaultBrightness = value;
  566. },
  567. },
  568. /**
  569. * The default contrast of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces
  570. * the contrast while greater than 1.0 increases it.
  571. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  572. * @type {Number|undefined}
  573. * @deprecated
  574. */
  575. defaultContrast: {
  576. get: function () {
  577. deprecationWarning(
  578. "GoogleEarthEnterpriseMapsProvider.defaultContrast",
  579. "GoogleEarthEnterpriseMapsProvider.defaultContrast was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.contrast instead."
  580. );
  581. return this._defaultContrast;
  582. },
  583. set: function (value) {
  584. deprecationWarning(
  585. "GoogleEarthEnterpriseMapsProvider.defaultContrast",
  586. "GoogleEarthEnterpriseMapsProvider.defaultContrast was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.contrast instead."
  587. );
  588. this._defaultContrast = value;
  589. },
  590. },
  591. /**
  592. * The default hue of this provider in radians. 0.0 uses the unmodified imagery color.
  593. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  594. * @type {Number|undefined}
  595. * @deprecated
  596. */
  597. defaultHue: {
  598. get: function () {
  599. deprecationWarning(
  600. "GoogleEarthEnterpriseMapsProvider.defaultHue",
  601. "GoogleEarthEnterpriseMapsProvider.defaultHue was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.hue instead."
  602. );
  603. return this._defaultHue;
  604. },
  605. set: function (value) {
  606. deprecationWarning(
  607. "GoogleEarthEnterpriseMapsProvider.defaultHue",
  608. "GoogleEarthEnterpriseMapsProvider.defaultHue was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.hue instead."
  609. );
  610. this._defaultHue = value;
  611. },
  612. },
  613. /**
  614. * The default saturation of this provider. 1.0 uses the unmodified imagery color. Less than 1.0 reduces the
  615. * saturation while greater than 1.0 increases it.
  616. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  617. * @type {Number|undefined}
  618. * @deprecated
  619. */
  620. defaultSaturation: {
  621. get: function () {
  622. deprecationWarning(
  623. "GoogleEarthEnterpriseMapsProvider.defaultSaturation",
  624. "GoogleEarthEnterpriseMapsProvider.defaultSaturation was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.saturation instead."
  625. );
  626. return this._defaultSaturation;
  627. },
  628. set: function (value) {
  629. deprecationWarning(
  630. "GoogleEarthEnterpriseMapsProvider.defaultSaturation",
  631. "GoogleEarthEnterpriseMapsProvider.defaultSaturation was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.saturation instead."
  632. );
  633. this._defaultSaturation = value;
  634. },
  635. },
  636. /**
  637. * The default gamma correction to apply to this provider. 1.0 uses the unmodified imagery color.
  638. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  639. * @type {Number|undefined}
  640. * @deprecated
  641. */
  642. defaultGamma: {
  643. get: function () {
  644. deprecationWarning(
  645. "GoogleEarthEnterpriseMapsProvider.defaultGamma",
  646. "GoogleEarthEnterpriseMapsProvider.defaultGamma was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.gamma instead."
  647. );
  648. return this._defaultGamma;
  649. },
  650. set: function (value) {
  651. deprecationWarning(
  652. "GoogleEarthEnterpriseMapsProvider.defaultGamma",
  653. "GoogleEarthEnterpriseMapsProvider.defaultGamma was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.gamma instead."
  654. );
  655. this._defaultGamma = value;
  656. },
  657. },
  658. /**
  659. * The default texture minification filter to apply to this provider.
  660. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  661. * @type {TextureMinificationFilter}
  662. * @deprecated
  663. */
  664. defaultMinificationFilter: {
  665. get: function () {
  666. deprecationWarning(
  667. "GoogleEarthEnterpriseMapsProvider.defaultMinificationFilter",
  668. "GoogleEarthEnterpriseMapsProvider.defaultMinificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.minificationFilter instead."
  669. );
  670. return this._defaultMinificationFilter;
  671. },
  672. set: function (value) {
  673. deprecationWarning(
  674. "GoogleEarthEnterpriseMapsProvider.defaultMinificationFilter",
  675. "GoogleEarthEnterpriseMapsProvider.defaultMinificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.minificationFilter instead."
  676. );
  677. this._defaultMinificationFilter = value;
  678. },
  679. },
  680. /**
  681. * The default texture magnification filter to apply to this provider.
  682. * @memberof GoogleEarthEnterpriseMapsProvider.prototype
  683. * @type {TextureMagnificationFilter}
  684. * @deprecated
  685. */
  686. defaultMagnificationFilter: {
  687. get: function () {
  688. deprecationWarning(
  689. "GoogleEarthEnterpriseMapsProvider.defaultMagnificationFilter",
  690. "GoogleEarthEnterpriseMapsProvider.defaultMagnificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.magnificationFilter instead."
  691. );
  692. return this._defaultMagnificationFilter;
  693. },
  694. set: function (value) {
  695. deprecationWarning(
  696. "GoogleEarthEnterpriseMapsProvider.defaultMagnificationFilter",
  697. "GoogleEarthEnterpriseMapsProvider.defaultMagnificationFilter was deprecated in CesiumJS 1.104. It will be in CesiumJS 1.107. Use ImageryLayer.magnificationFilter instead."
  698. );
  699. this._defaultMagnificationFilter = value;
  700. },
  701. },
  702. });
  703. /**
  704. * Creates a tiled imagery provider using the Google Earth Imagery API.
  705. *
  706. * @param {Resource|String} url The url of the Google Earth server hosting the imagery.
  707. * @param {GoogleEarthEnterpriseMapsProvider.ConstructorOptions} [options] Object describing initialization options
  708. * @returns {Promise<GoogleEarthEnterpriseMapsProvider>} The created GoogleEarthEnterpriseMapsProvider.
  709. *
  710. * @exception {RuntimeError} Could not find layer with channel (id) of <code>options.channel</code>.
  711. * @exception {RuntimeError} Could not find a version in channel (id) <code>options.channel</code>.
  712. * @exception {RuntimeError} Unsupported projection <code>data.projection</code>.
  713. *
  714. * @example
  715. * const google = await Cesium.GoogleEarthEnterpriseMapsProvider.fromUrl("https://earth.localdomain", 1008);
  716. */
  717. GoogleEarthEnterpriseMapsProvider.fromUrl = async function (
  718. url,
  719. channel,
  720. options
  721. ) {
  722. //>>includeStart('debug', pragmas.debug);
  723. Check.defined("url", url);
  724. Check.defined("channel", channel);
  725. //>>includeEnd('debug');
  726. options = defaultValue(options, {});
  727. const path = defaultValue(options.path, "/default_map");
  728. const resource = Resource.createIfNeeded(url).getDerivedResource({
  729. // We used to just append path to url, so now that we do proper URI resolution, removed the /
  730. url: path[0] === "/" ? path.substring(1) : path,
  731. });
  732. resource.appendForwardSlash();
  733. const metadataResource = resource.getDerivedResource({
  734. url: "query",
  735. queryParameters: {
  736. request: "Json",
  737. vars: "geeServerDefs",
  738. is2d: "t",
  739. },
  740. });
  741. const imageryProviderBuilder = new ImageryProviderBuilder(options);
  742. imageryProviderBuilder.channel = channel;
  743. await requestMetadata(metadataResource, imageryProviderBuilder);
  744. const provider = new GoogleEarthEnterpriseMapsProvider(options);
  745. imageryProviderBuilder.build(provider);
  746. provider._readyPromise = Promise.resolve(true);
  747. provider._ready = true;
  748. provider._resource = resource;
  749. provider._url = url;
  750. provider._path = path;
  751. return provider;
  752. };
  753. /**
  754. * Gets the credits to be displayed when a given tile is displayed.
  755. *
  756. * @param {number} x The tile X coordinate.
  757. * @param {number} y The tile Y coordinate.
  758. * @param {number} level The tile level;
  759. * @returns {Credit[]} The credits to be displayed when the tile is displayed.
  760. */
  761. GoogleEarthEnterpriseMapsProvider.prototype.getTileCredits = function (
  762. x,
  763. y,
  764. level
  765. ) {
  766. return undefined;
  767. };
  768. /**
  769. * Requests the image for a given tile.
  770. *
  771. * @param {number} x The tile X coordinate.
  772. * @param {number} y The tile Y coordinate.
  773. * @param {number} level The tile level.
  774. * @param {Request} [request] The request object. Intended for internal use only.
  775. * @returns {Promise<ImageryTypes>|undefined} A promise for the image that will resolve when the image is available, or
  776. * undefined if there are too many active requests to the server, and the request should be retried later.
  777. */
  778. GoogleEarthEnterpriseMapsProvider.prototype.requestImage = function (
  779. x,
  780. y,
  781. level,
  782. request
  783. ) {
  784. const resource = this._resource.getDerivedResource({
  785. url: "query",
  786. request: request,
  787. queryParameters: {
  788. request: this._requestType,
  789. channel: this._channel,
  790. version: this._version,
  791. x: x,
  792. y: y,
  793. z: level + 1, // Google Earth starts with a zoom level of 1, not 0
  794. },
  795. });
  796. return ImageryProvider.loadImage(this, resource);
  797. };
  798. /**
  799. * Picking features is not currently supported by this imagery provider, so this function simply returns
  800. * undefined.
  801. *
  802. * @param {number} x The tile X coordinate.
  803. * @param {number} y The tile Y coordinate.
  804. * @param {number} level The tile level.
  805. * @param {number} longitude The longitude at which to pick features.
  806. * @param {number} latitude The latitude at which to pick features.
  807. * @return {undefined} Undefined since picking is not supported.
  808. */
  809. GoogleEarthEnterpriseMapsProvider.prototype.pickFeatures = function (
  810. x,
  811. y,
  812. level,
  813. longitude,
  814. latitude
  815. ) {
  816. return undefined;
  817. };
  818. GoogleEarthEnterpriseMapsProvider._logoUrl = undefined;
  819. Object.defineProperties(GoogleEarthEnterpriseMapsProvider, {
  820. /**
  821. * Gets or sets the URL to the Google Earth logo for display in the credit.
  822. * @memberof GoogleEarthEnterpriseMapsProvider
  823. * @type {string}
  824. */
  825. logoUrl: {
  826. get: function () {
  827. if (!defined(GoogleEarthEnterpriseMapsProvider._logoUrl)) {
  828. GoogleEarthEnterpriseMapsProvider._logoUrl = buildModuleUrl(
  829. "Assets/Images/google_earth_credit.png"
  830. );
  831. }
  832. return GoogleEarthEnterpriseMapsProvider._logoUrl;
  833. },
  834. set: function (value) {
  835. //>>includeStart('debug', pragmas.debug);
  836. Check.defined("value", value);
  837. //>>includeEnd('debug');
  838. GoogleEarthEnterpriseMapsProvider._logoUrl = value;
  839. },
  840. },
  841. });
  842. export default GoogleEarthEnterpriseMapsProvider;