Skip to main content

Class: OpacityDataUtils

Defined in: utils/data/OpacityDataUtils.ts:16

Extends

  • DataUtilsBase

Constructors

Constructor

new OpacityDataUtils(): OpacityDataUtils

Returns

OpacityDataUtils

Inherited from

DataUtilsBase.constructor

Methods

createUniformOpacityData()

static createUniformOpacityData(n, opacity, options?): Uint8Array

Defined in: utils/data/OpacityDataUtils.ts:209

Creates an opacity data buffer of the given size filled with a single opacity value.

Parameters

n

number

Number of elements

opacity

number

The opacity value (0–1) to fill with

options?

Optional buffer alignment and opacity scaling factor

align?

number

opacityFactor?

number

Returns

Uint8Array

A Uint8Array filled with the encoded opacity


encodeOpacity()

static encodeOpacity(opacity, options?): number

Defined in: utils/data/OpacityDataUtils.ts:243

Encodes an opacity value (0–1) into a Uint8Array-compatible integer (0–255), optionally scaled by an opacity factor.

Parameters

opacity

number

The opacity value (0–1)

options?

Optional opacity scaling factor (defaults to 1)

opacityFactor?

number

Returns

number

The encoded opacity as an integer in the range [0, 255]


fillDataFromTableGroups()

protected static fillDataFromTableGroups<TValue>(data, ids, column, defaultValue, loadTable, mapGroupToValue, encodeValue, options?): Promise<void>

Defined in: utils/data/DataUtilsBase.ts:84

Fills data by loading group keys from the configured table column and mapping them to values.

For each ID in ids, the corresponding row is looked up in the loaded table by ID. The raw cell value is JSON-stringified to produce a group key, which is then mapped to a value using mapGroupToValue. If the mapping fails, defaultValue is used instead.

Type Parameters

TValue

TValue

Parameters

data

TypedArray

Output typed array to fill

ids

number[]

Ordered list of item IDs

column

string

Name of the table column to load group keys from

defaultValue

TValue

Value used when the ID is missing or the group is unmapped

loadTable

(options?) => Promise<TableData>

Async function that loads the TableData

mapGroupToValue

(group) => TValue | undefined

Maps a JSON-stringified group key to TValue, or undefined

encodeValue

(value) => number

Converts TValue to the numeric representation stored in data

options?

Optional abort signal

signal?

AbortSignal

Returns

Promise<void>

Inherited from

DataUtilsBase.fillDataFromTableGroups


fillDataFromTableValues()

protected static fillDataFromTableValues<TValue>(data, ids, column, defaultValue, loadTable, parseTableValue, encodeValue, options?): Promise<void>

Defined in: utils/data/DataUtilsBase.ts:21

Fills data by loading values from the configured table column

For each ID in ids, the corresponding row is looked up in the loaded table by ID. The raw cell value is parsed by parseTableValue; if parsing fails, defaultValue is used instead.

Type Parameters

TValue

TValue

Parameters

data

TypedArray

Output typed array to fill

ids

number[]

Ordered list of item IDs

column

string

Name of the table column to load values from

defaultValue

TValue

Value used when the ID is missing or parsing fails

loadTable

(options?) => Promise<TableData>

Async function that loads the TableData

parseTableValue

(value, valueRange) => TValue | undefined

Converts a raw cell value to TValue, or undefined on failure

encodeValue

(value) => number

Converts TValue to the numeric representation stored in data

options?

Optional abort signal

signal?

AbortSignal

Returns

Promise<void>

Inherited from

DataUtilsBase.fillDataFromTableValues


loadOpacityData()

static loadOpacityData(ids, config, opacityMaps, defaultOpacity, loadTable, options?): Promise<Uint8Array<ArrayBufferLike>>

Defined in: utils/data/OpacityDataUtils.ts:31

Loads opacity data for a set of IDs based on the active opacity configuration source.

Dispatches to the appropriate loader (constant, from, or groupBy) depending on which configuration source is active.

Parameters

ids

number[]

Ordered list of item IDs

config

OpacityConfig

Opacity configuration specifying the data source

opacityMaps

DefaultMap<number>[]

Available opacity maps for groupBy lookups

defaultOpacity

number

Fallback opacity value (0–1) when no valid config or value is found

loadTable

(tableId, options?) => Promise<TableData>

Async function that loads a TableData by ID

options?

Optional abort signal, buffer alignment, table ID, and opacity scaling factor

align?

number

opacityFactor?

number

signal?

AbortSignal

table?

string

Returns

Promise<Uint8Array<ArrayBufferLike>>

A Uint8Array of encoded opacity values (0–255), one per ID


loadOpacityDataFromTableGroups()

static loadOpacityDataFromTableGroups(ids, config, opacityMaps, defaultOpacity, loadTable, options?): Promise<Uint8Array<ArrayBufferLike>>

Defined in: utils/data/OpacityDataUtils.ts:160

Loads opacity data by grouping IDs via a table column and mapping each group to an opacity value using an opacity map.

Parameters

ids

number[]

Ordered list of item IDs

config

GroupByConfig<true, unknown>

GroupBy configuration specifying the source column and map

opacityMaps

DefaultMap<number>[]

Available opacity maps for group-to-opacity lookups

defaultOpacity

number

Fallback opacity when the map is not found or a group is unmapped

loadTable

(options?) => Promise<TableData>

Async function that loads the TableData

options?

Optional abort signal, buffer alignment, and opacity scaling factor

align?

number

opacityFactor?

number

signal?

AbortSignal

Returns

Promise<Uint8Array<ArrayBufferLike>>

A Uint8Array of encoded opacity values


loadOpacityDataFromTableValues()

static loadOpacityDataFromTableValues(ids, config, defaultOpacity, loadTable, options?): Promise<Uint8Array<ArrayBufferLike>>

Defined in: utils/data/OpacityDataUtils.ts:122

Loads opacity data by reading numeric values from a table column.

Parameters

ids

number[]

Ordered list of item IDs

config

FromConfig<unknown>

From configuration specifying the source column

defaultOpacity

number

Fallback opacity when a value is missing or invalid

loadTable

(options?) => Promise<TableData>

Async function that loads the TableData

options?

Optional abort signal, buffer alignment, and opacity scaling factor

align?

number

opacityFactor?

number

signal?

AbortSignal

Returns

Promise<Uint8Array<ArrayBufferLike>>

A Uint8Array of encoded opacity values


loadUniformOpacityData()

static loadUniformOpacityData(ids, config, options?): Uint8Array

Defined in: utils/data/OpacityDataUtils.ts:99

Creates a uniform opacity data buffer filled with the configured constant opacity.

Parameters

ids

number[]

Ordered list of item IDs (only the length is used)

config

ConstantConfig<number, unknown>

Constant opacity configuration containing the opacity value

options?

Optional buffer alignment and opacity scaling factor

align?

number

opacityFactor?

number

Returns

Uint8Array

A Uint8Array filled with the encoded constant opacity


parseOpacityValue()

static parseOpacityValue(value): number | undefined

Defined in: utils/data/OpacityDataUtils.ts:227

Parses a raw value as an opacity number, clamped to the range [0, 1].

Parameters

value

unknown

The raw value to parse (must be a number)

Returns

number | undefined

The clamped opacity, or undefined if value is not a number