Methods
addStyle(name, fn, optionsopt) → {void}
Add a new style or update an existing one Supports two types of styles:
- Type 1 (Direct RGBA): Function returns [r, g, b, a] directly
- Type 2 (Gradient): Function returns [scalar, 0, 0, alpha] with colors/stops/domain in options
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Unique style name |
||||||||||||||||||
fn |
function | GPU.js kernel function that processes band data |
||||||||||||||||||
options |
Object |
<optional> |
{} | Configuration for gradient-based styles (Type 2) Properties
|
- Source:
Returns:
- Type
- void
Example
// Type 1: Direct RGBA
multiband.addStyle('True Color', function(data) {
const r = data[3][this.thread.y][this.thread.x] * 0.00003051757;
const g = data[2][this.thread.y][this.thread.x] * 0.00003051757;
const b = data[1][this.thread.y][this.thread.x] * 0.00003051757;
return [r, g, b, 0.8];
});
// Type 2: Gradient
multiband.addStyle('NDVI', function(data) {
const b4 = data[3][this.thread.y][this.thread.x];
const b8 = data[7][this.thread.y][this.thread.x];
const ndvi = (b8 - b4) / (b8 + b4);
return [ndvi, 0, 0, 0.8];
}, {
colors: ['#a50026', '#d73027', '#006837'],
stops: [-0.2, 0.0, 0.8],
domain: [-1.0, 1.0]
});
destroyLumaTextureRef(tileDataResult) → {void}
Destroy luma texture reference from tile data result
Parameters:
| Name | Type | Description |
|---|---|---|
tileDataResult |
Object | Tile data with _lumaTexture property |
- Source:
Returns:
- Type
- void
(async) geoKeysParser(geoKeys) → {Promise.<Object>|string|Object|string}
Parse GeoTIFF projection keys and transform to proj4 definition Extracts EPSG code from geoKeys and returns proj4-compatible CRS definition
Parameters:
| Name | Type | Description |
|---|---|---|
geoKeys |
Object | GeoTIFF geokeys object |
- Source:
Throws:
-
If geoKeys is invalid or no projection code found
- Type
- Error
Returns:
-
Promise resolving to CRS definition object
- Type
- Promise.<Object>
-
return.def - proj4 definition string (e.g., 'EPSG:4326')
- Type
- string
-
return.parsed - Parsed proj4 CRS object
- Type
- Object
-
return.coordinatesUnits - Units of the coordinate system
- Type
- string
getActiveStyle() → {string}
Get the name of the currently active style
- Source:
Returns:
Active style name
- Type
- string
getPixelValues(lngLat, target, layerIdopt) → {Object|null}
Sample pixel values from loaded tiles at clicked lngLat position Evaluates the active style at the sampled pixel location
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
lngLat |
Array.<number> | Object | Click position as [lng, lat] or {lng, lat} |
||
target |
Object | deck.gl instance or map-like object exposing __deck |
||
layerId |
string |
<optional> |
'cog-layer' | COGLayer id to sample from |
Properties:
| Name | Type | Description |
|---|---|---|
latlng |
Object | Clicked position {lat, lng} |
selectedstyle |
string | Active style name |
value |
* | Style function output at sampled pixel (Type 1: RGBA array, Type 2: scalar) |
bands |
Array.<number> | Raw band values at sampled pixel |
- Source:
Returns:
Sampled pixel data or null if sampling fails
- Type
- Object | null
getStyles() → {Array.<string>}
Get an array of all available style names Results are cached and only recomputed when styles are added/removed
- Source:
Returns:
Array of style names
- Type
- Array.<string>
(async) getTileData(image, optionsopt) → {Promise.<Object>}
Fetch and process tile data from a GeoTIFF for GPU rendering Converts raster data to band-major Float32Array format suitable for GPU.js
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
image |
Object | GeoTIFF image object with fetchTile method |
||||||||||||||||||||||
options |
Object |
<optional> |
{} | Fetch options Properties
|
Properties:
| Name | Type | Description |
|---|---|---|
data |
Float32Array | Band-major float32 raster data |
width |
number | Tile width in pixels |
height |
number | Tile height in pixels |
bandCount |
number | Number of bands |
device |
Object | WebGL device |
- Source:
Throws:
-
If raster array is missing from fetched tile
- Type
- Error
Returns:
Promise resolving to tile data
- Type
- Promise.<Object>
releaseBlitResources(gl) → {void}
Release all cached blit resources for a WebGL context Deletes framebuffers, VAOs, programs, and LUT textures
Parameters:
| Name | Type | Description |
|---|---|---|
gl |
WebGL2RenderingContext | WebGL context |
- Source:
Returns:
- Type
- void
removeStyle(name) → {void}
Remove a style from the collection The default style "Band 1 - grayscale" cannot be removed
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Style name to remove |
- Source:
Returns:
- Type
- void
renderTile(tileDataResult, multibandInstance) → {Array.<Object>}
Render a tile using the active style from the multiband instance Applies GPU-accelerated style kernel to raster data and returns RasterModule array
For Type 1 styles: Applies kernel directly to produce RGBA output For Type 2 styles: Applies kernel to produce scalar values, then maps through color LUT via GPU shader
Parameters:
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tileDataResult |
Object | The tile data with texture information Properties
|
||||||||||||||||||
multibandInstance |
Object | The multiband instance with GPU and style management |
- Source:
Throws:
-
If no active style or kernel is available
- Type
- Error
Returns:
Array of RasterModule objects backed by luma textures
- Type
- Array.<Object>
setActiveStyle(name, targetopt, layerIdopt) → {void}
Set the active rendering style and optionally refresh tiles If the style is not found, defaults to "Band 1 - grayscale"
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
name |
string | Style name to activate |
||
target |
Object |
<optional> |
deck.gl instance or map-like object exposing __deck; if provided, tiles are refreshed immediately |
|
layerId |
string |
<optional> |
'cog-layer' | COGLayer id used when refreshing tiles |
- Source:
Returns:
- Type
- void