@gisatcz/deckgl-geolib 2.4.1-dev.1 → 2.5.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,7 +50,7 @@ declare class CogTiles {
50
50
  * @returns {number} The index of the image in the COG that best matches the specified zoom level.
51
51
  */
52
52
  getImageIndexForZoomLevel(zoom: number): number;
53
- getTileFromImage(tileX: number, tileY: number, zoom: number, fetchSize?: number): Promise<(Float32Array<ArrayBuffer> | Int8Array<ArrayBuffer> | Uint8Array<ArrayBuffer> | Int16Array<ArrayBuffer> | Uint16Array<ArrayBuffer> | Int32Array<ArrayBuffer> | Uint32Array<ArrayBuffer> | Float64Array<ArrayBuffer>)[] | import("geotiff").TypedArrayWithDimensions[]>;
53
+ getTileFromImage(tileX: number, tileY: number, zoom: number, fetchSize?: number): Promise<(Uint8Array<ArrayBuffer> | Float32Array<ArrayBuffer> | Int8Array<ArrayBuffer> | Int16Array<ArrayBuffer> | Uint16Array<ArrayBuffer> | Int32Array<ArrayBuffer> | Uint32Array<ArrayBuffer> | Float64Array<ArrayBuffer>)[] | import("geotiff").TypedArrayWithDimensions[]>;
54
54
  /**
55
55
  * Creates a blank tile buffer filled with the "No Data" value.
56
56
  * @param size The width/height of the square tile (e.g., 256 or 257)
@@ -81,6 +81,6 @@ declare class CogTiles {
81
81
  * @param {number} multiplier - Optional multiplier for interleaved buffers (e.g., numChannels).
82
82
  * @returns {TypedArray} A typed array buffer of length (tileSize * tileSize * multiplier).
83
83
  */
84
- createTileBuffer(dataType: string, tileSize: number, multiplier?: number): Float32Array<ArrayBuffer> | Int8Array<ArrayBuffer> | Uint8Array<ArrayBuffer> | Int16Array<ArrayBuffer> | Uint16Array<ArrayBuffer> | Int32Array<ArrayBuffer> | Uint32Array<ArrayBuffer> | Float64Array<ArrayBuffer>;
84
+ createTileBuffer(dataType: string, tileSize: number, multiplier?: number): Uint8Array<ArrayBuffer> | Float32Array<ArrayBuffer> | Int8Array<ArrayBuffer> | Int16Array<ArrayBuffer> | Uint16Array<ArrayBuffer> | Int32Array<ArrayBuffer> | Uint32Array<ArrayBuffer> | Float64Array<ArrayBuffer>;
85
85
  }
86
86
  export default CogTiles;
@@ -11,6 +11,27 @@ export default class GeoImage {
11
11
  bounds: Bounds;
12
12
  cellSizeMeters?: number;
13
13
  }, options: GeoImageOptions, meshMaxError: number): Promise<TileResult | null>;
14
+ /**
15
+ * Resolves the active visualization (coloring) mode after merging user options with defaults.
16
+ *
17
+ * Solves three key issues:
18
+ *
19
+ * 1. **Mutual exclusivity**: `DefaultGeoImageOptions` sets `useHeatMap: true`. If a user
20
+ * explicitly enables a coloring mode without explicitly setting `useHeatMap: false`,
21
+ * enforce that only the explicitly-enabled modes are active (all others forced to false).
22
+ * This prevents the default `useHeatMap: true` from interfering with user-chosen modes.
23
+ *
24
+ * 2. **Bitmap default**: for `type === 'image'` with no user-specified coloring mode,
25
+ * keep `useHeatMap: true` from defaults. This provides sensible data-driven visualization.
26
+ *
27
+ * 3. **Terrain default**: for `type === 'terrain'` with no user-specified coloring mode and
28
+ * no kernel-texture mode (`useSwissRelief` / `useSlope` / `useHillshade`), enable
29
+ * `useSingleColor` with `color = terrainColor`. This renders the mesh in the documented
30
+ * default colour (grey) without a data-driven texture overlay. When a kernel mode IS
31
+ * present but no coloring mode is specified, keep `useHeatMap: true` so the kernel output
32
+ * is still colourised.
33
+ */
34
+ static resolveVisualizationMode(mergedOptions: GeoImageOptions, userOptions: GeoImageOptions): GeoImageOptions;
14
35
  getHeightmap(input: string | {
15
36
  bounds: Bounds;
16
37
  width: number;
@@ -22,5 +43,7 @@ export default class GeoImage {
22
43
  width: number;
23
44
  height: number;
24
45
  rasters: any[];
46
+ bounds?: Bounds;
47
+ cellSizeMeters?: number;
25
48
  }, options: GeoImageOptions): Promise<TileResult>;
26
49
  }
@@ -1,5 +1,24 @@
1
1
  import { GeoImageOptions, TypedArray, TileResult } from '../types';
2
2
  export declare class BitmapGenerator {
3
+ /**
4
+ * Cache for Swiss relief color LUTs to avoid regenerating on every tile.
5
+ * Key: colorScale config + range, Value: pre-computed RGBA LUT
6
+ */
7
+ private static _swissColorLUTCache;
8
+ /**
9
+ * Cache for 8-bit (256-entry) color LUTs.
10
+ * Shared process-wide across all tiles and datasets when options are fixed (i.e. !useAutoRange).
11
+ * Key: serialised coloring options, Value: pre-computed 256×RGBA LUT
12
+ */
13
+ private static _8bitLUTCache;
14
+ /**
15
+ * Cache for float/16-bit (1024-entry) heatmap LUTs.
16
+ * Shared process-wide across all tiles and datasets when !useAutoRange.
17
+ * Key: serialised coloring options + range, Value: pre-computed 1024×RGBA LUT
18
+ */
19
+ private static _floatLUTCache;
20
+ /** Build a cache key that captures all options affecting LUT colour output. */
21
+ private static getLUTCacheKey;
3
22
  /**
4
23
  * Main entry point: Generates an ImageBitmap from raw raster data.
5
24
  */
@@ -8,7 +27,22 @@ export declare class BitmapGenerator {
8
27
  height: number;
9
28
  rasters: TypedArray[];
10
29
  }, options: GeoImageOptions): Promise<TileResult>;
11
- static getColorValue(dataArray: TypedArray | any[], options: GeoImageOptions, arrayLength: number, samplesPerPixel?: number): Uint8ClampedArray<ArrayBuffer>;
30
+ static getColorValue(dataArray: TypedArray | TypedArray[], options: GeoImageOptions, arrayLength: number, samplesPerPixel?: number): Uint8ClampedArray<ArrayBuffer>;
31
+ /**
32
+ * Generate relief glaze RGBA output.
33
+ * Maps relief mask (0-255) to pure black/white glaze with variable alpha.
34
+ * - reliefValue < 128: Pure black (0,0,0) darkens shadows
35
+ * - reliefValue > 128: Pure white (255,255,255) brightens highlights
36
+ * - reliefValue == 128: Transparent (no effect)
37
+ *
38
+ * High-performance implementation using pre-computed alpha LUT to avoid 65k Math.pow calls.
39
+ *
40
+ * @param rasters Array of [relief mask raster] (single raster expected)
41
+ * @param options GeoImageOptions (alpha used for opacity scaling)
42
+ * @param arrayLength Total RGBA array length
43
+ * @returns Uint8ClampedArray of RGBA values
44
+ */
45
+ static getReliefGlazeRGBA(rasters: TypedArray[], options: GeoImageOptions, arrayLength: number): Uint8ClampedArray;
12
46
  private static calculateSingleColor;
13
47
  private static findClassIndex;
14
48
  private static getDefaultColor;
@@ -7,6 +7,13 @@
7
7
  * Output: Float32Array of 256×256 computed values.
8
8
  */
9
9
  export declare class KernelGenerator {
10
+ /**
11
+ * Compute terrain gradients (dzdx, dzdy) using Horn's method.
12
+ * @param z1-z9 - 3×3 neighborhood elevation values (z5 is center)
13
+ * @param cellSizeFactor - Pre-computed 1 / (8 * cellSize)
14
+ * @param geographicConvention - If true, use north-minus-south for dzdy (hillshade). If false, use south-minus-north (slope).
15
+ */
16
+ private static computeGradients;
10
17
  /**
11
18
  * Calculates slope (0–90 degrees) for each pixel using Horn's method.
12
19
  *
@@ -28,4 +35,9 @@ export declare class KernelGenerator {
28
35
  * @param noDataValue Elevation value treated as noData; output is NaN for those pixels
29
36
  */
30
37
  static calculateHillshade(src: Float32Array, cellSize: number, azimuth?: number, altitude?: number, zFactor?: number, noDataValue?: number): Float32Array;
38
+ /**
39
+ * Calculates a weighted multi-directional hillshade (0–255).
40
+ * Combines three light sources to reveal structure in shadows.
41
+ */
42
+ static calculateMultiHillshade(src: Float32Array, cellSize: number, zFactor?: number, noDataValue?: number): Float32Array;
31
43
  }
@@ -0,0 +1,28 @@
1
+ import { GeoImageOptions } from '../types';
2
+ /**
3
+ * Composes Swiss relief by combining slope and hillshade kernels via LUT.
4
+ * Outputs a single 0-255 relief mask suitable for baking into hypsometry (terrain)
5
+ * or creating transparent glaze overlays (bitmap).
6
+ */
7
+ export declare class ReliefCompositor {
8
+ /**
9
+ * Precompute and cache a 256x256 LUT for Swiss relief compositing.
10
+ * LUT[hillshade][slope] = (hillshade * (1.0 - (slope * weight)))
11
+ * All values normalized to [0,1].
12
+ * Only computed on first use of Swiss relief mode.
13
+ */
14
+ private static _swissReliefLUT;
15
+ private static _lastWeight;
16
+ static getSwissReliefLUT(weight?: number): Float32Array;
17
+ /**
18
+ * Compute Swiss relief compositing: slope + hillshade → 0-255 relief mask.
19
+ *
20
+ * @param elevation - Padded elevation raster (258×258 for kernel input)
21
+ * @param options - GeoImageOptions (must include zFactor, noDataValue, swissSlopeWeight)
22
+ * @param cellSize - Grid cell size in meters
23
+ * @param width - Output width (typically 256)
24
+ * @param height - Output height (typically 256)
25
+ * @returns Uint8ClampedArray of 0-255 relief values
26
+ */
27
+ static composeSwissRelief(elevation: Float32Array, options: GeoImageOptions, cellSize: number, width: number, height: number): Uint8ClampedArray;
28
+ }
@@ -7,9 +7,14 @@ export declare class TerrainGenerator {
7
7
  bounds: Bounds;
8
8
  cellSizeMeters?: number;
9
9
  }, options: GeoImageOptions, meshMaxError: number): Promise<TileResult>;
10
- /** Extracts rows 1–257, cols 1–257 from a 258×258 terrain array → 257×257 for mesh generation. */
11
10
  private static extractMeshRaster;
12
11
  private static hasVisualizationOptions;
12
+ /**
13
+ * Preserve noData values in a separate raster for kernel computation.
14
+ * If the source raster marks a sample as noData, keep it as noData.
15
+ * Otherwise, use the processed terrain elevation value.
16
+ */
17
+ private static preserveNoDataForKernel;
13
18
  private static cropRaster;
14
19
  /**
15
20
  * Decodes raw raster data into a Float32Array of elevation values.
@@ -41,7 +41,10 @@ export type GeoImageOptions = {
41
41
  colorScaleValueRange?: number[];
42
42
  colorsBasedOnValues?: Array<[number, ChromaColorInput]>;
43
43
  colorClasses?: Array<[ChromaColorInput, [number, number], [boolean?, boolean?]?]>;
44
+ /** General layer opacity (0-100). Used for all rendering modes except glaze. */
44
45
  alpha?: number;
46
+ /** Intensity ceiling for the relief glaze (0-255). 0 is fully transparent; 255 is maximum theoretical opacity. Recommended range for satellite overlays: 120-160. Only used with useReliefGlaze. */
47
+ maxGlazeAlpha?: number;
45
48
  nullColor?: ChromaColorInput;
46
49
  unidentifiedColor?: ChromaColorInput;
47
50
  clippedColor?: ChromaColorInput;
@@ -51,6 +54,10 @@ export type GeoImageOptions = {
51
54
  hillshadeAzimuth?: number;
52
55
  hillshadeAltitude?: number;
53
56
  zFactor?: number;
57
+ useSwissRelief?: boolean;
58
+ swissSlopeWeight?: number;
59
+ useReliefGlaze?: boolean;
60
+ disableLighting?: boolean;
54
61
  };
55
62
  export declare const DefaultGeoImageOptions: GeoImageOptions;
56
63
  export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
@@ -74,4 +81,6 @@ export interface TileResult {
74
81
  width: number;
75
82
  height: number;
76
83
  texture?: ImageBitmap;
84
+ /** Optional: grayscale or color bitmap for Swiss relief or other overlays */
85
+ bitmap?: Uint8ClampedArray | ImageBitmap;
77
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisatcz/deckgl-geolib",
3
- "version": "2.4.1-dev.1",
3
+ "version": "2.5.0-dev.2",
4
4
  "description": "Deck.gl extension for rendering Cloud-Optimized GeoTIFF (COG) data",
5
5
  "keywords": [
6
6
  "deck.gl",