Class: HeightmapTerrainData

HeightmapTerrainData

new HeightmapTerrainData()

Single terrain tile data (stored in the form of a height map); A height map is a rectangular array composed of elevation values, arranged in main row order (data direction: north to south for row direction, west to east for column direction)

Name Type Default Description
options.buffer TypedArray

A buffer containing height data.

options.width Number

The width (longitude direction) of the altitude map, measured in samples.

options.height Number

The height (latitude direction) of the altitude map, measured in samples.

options.childTileMask Number 15 optional

A bit mask used to indicate whether the four sub tiles of the tile exist. If the corresponding bit of a sub tile is set to 1, the geometric data of that sub tile will be requested when needed; If the bit is 0, the child tile is not requested, but upsampled from the parent tile data. The corresponding bit values for each sub tile are as follows:

Bit PositionBit ValueChild Tile
01西南
12东南
24西北
38东北

options.structure Object optional

Describe objects with high data structures.

Name Type Default Description
heightScale Number 1.0 optional

Multiply the height sample to obtain the factor of height higher than the height offset, in meters. Add hightoffst to the results

heightOffset Number 0.0 optional

The offset added to the scaled height to obtain the final height (in meters). The offset is added after multiplying the height sample by the height scale.

elementsPerHeight Number 1 optional

The number of elements that make up a single height sample in the buffer. Usually 1, indicating that each element is a separate height sample. If it is greater than 1, the number of elements together form a height sample, which is calculated based on the structure.elementMultiplier and structure.isBigEndian attributes.

stride Number 1 optional

The number of elements to be skipped from the first element at one height to the first element at the next height. The number of elements to be skipped between the first element of the height and the first element of the next height.

elementMultiplier Number 256.0 optional

The multiplier used to calculate the height value when the stride attribute is greater than 1. For example, if stride is 4 and stride Multiplier is 256, the height calculation is as follows: height = buffer[index] + buffer[index + 1] * 256 + buffer[index + 2] * 256 * 256 + buffer[index + 3] * 256 * 256 * 256 This assumes that the isBigEndian attribute is false. If true, the order of the elements is reversed.

isBigEndian Boolean false optional

When the stride attribute is greater than 1, it indicates the byte order of the elements in the buffer. If the attribute is false, then the first element is a low order element. If true, then the first element is a higher-order element.

lowestEncodedHeight Number optional

The minimum value that can be stored in a height buffer. Any height below this value will be limited to that value after encoding with HighScale and HighOffset. For example, if the height buffer is Uint16Array, the value should be 0 because Uint16Array cannot store negative numbers. If this parameter is not specified, the minimum value will not be enforced.

highestEncodedHeight Number optional

The maximum value that can be stored in a height buffer. Any height higher than this value will be limited to this value after encoding with HighScale and HighOffset. For example, if the height buffer is Uint16Array, the value should be 256 * 256-1 or 65535 because Uint16Array cannot store numbers greater than 65535. If this parameter is not specified, the maximum value will not be enforced.

options.createdByUpsampling Boolean false optional

If this instance was created by upsampling another instance, it is true; Otherwise, it is false.

See:
Example
var buffer = ...
var heightBuffer = new Uint16Array(buffer, 0, that._heightmapWidth * that._heightmapWidth);
var childTileMask = new Uint8Array(buffer, heightBuffer.byteLength, 1)[0];
var waterMask = new Uint8Array(buffer, heightBuffer.byteLength + 1, buffer.byteLength - heightBuffer.byteLength - 1);
var terrainData = new SuperMap3D.HeightmapTerrainData({
  buffer : heightBuffer,
  width : 65,
  height : 65,
  childTileMask : childTileMask,
  waterMask : waterMask
});

Members

readonly creditsArray.<Credit>

The copyright statement for this tile.

readonly waterMaskUint8Array Image Canvas

The text water area mask contained in this terrain data. The water mask is a square Uint8Array or image with values between 0 and 255.

Methods

interpolateHeight(rectangle, longitude, latitude){Number}

Calculate the terrain height at the specified latitude and longitude.

Name Type Description
rectangle Rectangle

The rectangular area covered by the terrain data.

longitude Number

Longitude, measured in radians.

latitude Number

Latitude measured in radians.

Returns:
Type Description
Number The terrain height at the specified location. If the position is not within the rectangular range, this method will calculate the height, but for positions far outside the rectangular range, the calculated height is likely to be significantly larger than for positions far outside the rectangle, and the calculated height is likely to be vastly different.

isChildAvailable(thisX, thisY, childX, childY){Boolean}

Determine whether the given sub terrain map is available based on HeightmapTerrainData.childTileMask. The given sub topographic map coordinates are assumed to be one of the four sub topographic maps of the topographic map. If non sub topographic map coordinates are given, the availability of sub topographic maps in the southeast direction will be returned.

Name Type Description
thisX Number

The X coordinate of the tile (parent tile).

thisY Number

The Y coordinate of the tile (parent tile).

childX Number

Check the X coordinate of the available sub tiles.

childY Number

Check the Y coordinate of the available sub tiles.

Returns:
Type Description
Boolean If sub tiles are available, then true; Otherwise, it is false.

upsample(tilingScheme, thisX, thisY, thisLevel, descendantX, descendantY, descendantLevel){Promise.<HeightmapTerrainData>|undefined}

High sampling of terrain data for future tile use. The generated instance will contain a subset of the high samples in this instance, and interpolation will be performed if necessary.

Name Type Description
tilingScheme TilingScheme

The slicing scheme for the terrain data.

thisX Number

The X-coordinate of the tile in the slicing scheme.

thisY Number

The Y coordinate of the tile in the slicing scheme.

thisLevel Number

The level of the tile in the tile slicing scheme.

descendantX Number

The X-coordinate of the sub tiles to be upsampled in the slicing scheme.

descendantY Number

The Y coordinate of the sub tiles that require high sampling in the slicing scheme.

descendantLevel Number

The level of the tile in the slicing scheme.

Returns:
Type Description
Promise.<HeightmapTerrainData> | undefined Promise for high sampling terrain data of sub tiles; If there are too many asynchronous high sampling operations in progress and the request is delayed, it is undefined.

wasCreatedByUpsampling(){Boolean}

Get a value indicating whether the terrain data was created by upsampling low resolution terrain data. If the value is false, it indicates that the data was obtained from another source, such as downloading from a remote server. For the instance returned by calling HeightmapTerrainData # upsample, this method should return true.

Returns:
Type Description
Boolean If the instance was created through high sampling, it is true; Otherwise, it is false.