For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.
Class DEMData
Index
Constructors
Properties
Methods
Constructors
constructor
- new DEMData(
uid: string | number,
data: ImageData | RGBAImage,
encoding: DEMEncoding,
redFactor?: number,
greenFactor?: number,
blueFactor?: number,
baseShift?: number,
): DEMDataConstructs a
DEMDataobjectParameters
- uid: string | number
the tile's unique id
- data: ImageData | RGBAImage
RGBAImage data has uniform 2px padding on all sides: square tile edge size defines stride // and dim is calculated as stride - 4.
- encoding: DEMEncoding
the encoding type of the data
OptionalredFactor: numberthe red channel factor used to unpack the data, used for
customencoding onlyOptionalgreenFactor: numberthe green channel factor used to unpack the data, used for
customencoding onlyOptionalblueFactor: numberthe blue channel factor used to unpack the data, used for
customencoding onlyOptionalbaseShift: numberthe base shift used to unpack the data, used for
customencoding only
Returns DEMData
- uid: string | number
Properties
baseShift
baseShift: number
blueFactor
blueFactor: number
data
data: Uint32Array
dim
dim: number
greenFactor
greenFactor: number
max
max: number
min
min: number
redFactor
redFactor: number
stride
stride: number
uid
uid: string | number
Methods
backfillBorder
Parameters
- borderTile: DEMData
- dx: number
- dy: number
Returns void
get
Parameters
- x: number
- y: number
Returns number
getPixels
Returns RGBAImage
getUnpackVector
Returns number[]
pack
Parameters
- v: number
Returns { b: number; g: number; r: number }
sampleBilinear
Parameters
- x: number
- y: number
Returns number
unpack
Parameters
- r: number
- g: number
- b: number
Returns number
DEMData is a data structure for decoding, backfilling, and storing elevation data for processing in the hillshade shaders data can be populated either from a png raw image tile or from serialized data sent back from a worker. When data is initially loaded from a image tile, we decode the pixel values using the appropriate decoding formula, but we store the elevation data as an Int32 value. we add 65536 (2^16) to eliminate negative values and enable the use of integer overflow when creating the texture used in the hillshadePrepare step.
DEMData also handles the backfilling of data from a tile's neighboring tiles. This is necessary because we use a pixel's 8 surrounding pixel values to compute the slope at that pixel, and we cannot accurately calculate the slope at pixels on a tile's edge without backfilling from neighboring tiles.