TerrainData.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import DeveloperError from "./DeveloperError.js";
  2. /**
  3. * Terrain data for a single tile. This type describes an
  4. * interface and is not intended to be instantiated directly.
  5. *
  6. * @alias TerrainData
  7. * @constructor
  8. *
  9. * @see HeightmapTerrainData
  10. * @see QuantizedMeshTerrainData
  11. * @see GoogleEarthEnterpriseTerrainData
  12. */
  13. function TerrainData() {
  14. DeveloperError.throwInstantiationError();
  15. }
  16. Object.defineProperties(TerrainData.prototype, {
  17. /**
  18. * An array of credits for this tile.
  19. * @memberof TerrainData.prototype
  20. * @type {Credit[]}
  21. */
  22. credits: {
  23. get: DeveloperError.throwInstantiationError,
  24. },
  25. /**
  26. * The water mask included in this terrain data, if any. A water mask is a rectangular
  27. * Uint8Array or image where a value of 255 indicates water and a value of 0 indicates land.
  28. * Values in between 0 and 255 are allowed as well to smoothly blend between land and water.
  29. * @memberof TerrainData.prototype
  30. * @type {Uint8Array|HTMLImageElement|HTMLCanvasElement}
  31. */
  32. waterMask: {
  33. get: DeveloperError.throwInstantiationError,
  34. },
  35. });
  36. /**
  37. * Computes the terrain height at a specified longitude and latitude.
  38. * @function
  39. *
  40. * @param {Rectangle} rectangle The rectangle covered by this terrain data.
  41. * @param {number} longitude The longitude in radians.
  42. * @param {number} latitude The latitude in radians.
  43. * @returns {number} The terrain height at the specified position. If the position
  44. * is outside the rectangle, this method will extrapolate the height, which is likely to be wildly
  45. * incorrect for positions far outside the rectangle.
  46. */
  47. TerrainData.prototype.interpolateHeight =
  48. DeveloperError.throwInstantiationError;
  49. /**
  50. * Determines if a given child tile is available, based on the
  51. * {@link TerrainData#childTileMask}. The given child tile coordinates are assumed
  52. * to be one of the four children of this tile. If non-child tile coordinates are
  53. * given, the availability of the southeast child tile is returned.
  54. * @function
  55. *
  56. * @param {number} thisX The tile X coordinate of this (the parent) tile.
  57. * @param {number} thisY The tile Y coordinate of this (the parent) tile.
  58. * @param {number} childX The tile X coordinate of the child tile to check for availability.
  59. * @param {number} childY The tile Y coordinate of the child tile to check for availability.
  60. * @returns {boolean} True if the child tile is available; otherwise, false.
  61. */
  62. TerrainData.prototype.isChildAvailable = DeveloperError.throwInstantiationError;
  63. /**
  64. * Creates a {@link TerrainMesh} from this terrain data.
  65. * @function
  66. *
  67. * @private
  68. *
  69. * @param {object} options Object with the following properties:
  70. * @param {TilingScheme} options.tilingScheme The tiling scheme to which this tile belongs.
  71. * @param {number} options.x The X coordinate of the tile for which to create the terrain data.
  72. * @param {number} options.y The Y coordinate of the tile for which to create the terrain data.
  73. * @param {number} options.level The level of the tile for which to create the terrain data.
  74. * @param {number} [options.exaggeration=1.0] The scale used to exaggerate the terrain.
  75. * @param {number} [options.exaggerationRelativeHeight=0.0] The height relative to which terrain is exaggerated.
  76. * @param {boolean} [options.throttle=true] If true, indicates that this operation will need to be retried if too many asynchronous mesh creations are already in progress.
  77. * @returns {Promise<TerrainMesh>|undefined} A promise for the terrain mesh, or undefined if too many
  78. * asynchronous mesh creations are already in progress and the operation should
  79. * be retried later.
  80. */
  81. TerrainData.prototype.createMesh = DeveloperError.throwInstantiationError;
  82. /**
  83. * Upsamples this terrain data for use by a descendant tile.
  84. * @function
  85. *
  86. * @param {TilingScheme} tilingScheme The tiling scheme of this terrain data.
  87. * @param {number} thisX The X coordinate of this tile in the tiling scheme.
  88. * @param {number} thisY The Y coordinate of this tile in the tiling scheme.
  89. * @param {number} thisLevel The level of this tile in the tiling scheme.
  90. * @param {number} descendantX The X coordinate within the tiling scheme of the descendant tile for which we are upsampling.
  91. * @param {number} descendantY The Y coordinate within the tiling scheme of the descendant tile for which we are upsampling.
  92. * @param {number} descendantLevel The level within the tiling scheme of the descendant tile for which we are upsampling.
  93. * @returns {Promise<TerrainData>|undefined} A promise for upsampled terrain data for the descendant tile,
  94. * or undefined if too many asynchronous upsample operations are in progress and the request has been
  95. * deferred.
  96. */
  97. TerrainData.prototype.upsample = DeveloperError.throwInstantiationError;
  98. /**
  99. * Gets a value indicating whether or not this terrain data was created by upsampling lower resolution
  100. * terrain data. If this value is false, the data was obtained from some other source, such
  101. * as by downloading it from a remote server. This method should return true for instances
  102. * returned from a call to {@link TerrainData#upsample}.
  103. * @function
  104. *
  105. * @returns {boolean} True if this instance was created by upsampling; otherwise, false.
  106. */
  107. TerrainData.prototype.wasCreatedByUpsampling =
  108. DeveloperError.throwInstantiationError;
  109. /**
  110. * The maximum number of asynchronous tasks used for terrain processing.
  111. *
  112. * @type {number}
  113. * @private
  114. */
  115. TerrainData.maximumAsynchronousTasks = 5;
  116. export default TerrainData;