OpenZenith Core — WASM Decoder Demo
Loading WASM...
Benchmarks
| Operation | Time | Details |
|---|
D8 Flow Direction (3×3 pit DEM)
Direction colours: White=E, LightBlue=SE, Cyan=S, Green=SW, Lime=W, Yellow=NW, Orange=N, Red=NE. Pit cell (top-left) = black. DEMs use -32768 as their nodata sentinel and flow direction reports 255 (mapped to -1 for accumulation) where no downslope neighbour exists.
Flow Accumulation (3×3 pit DEM)
Upstream cell count. White = no upstream (peaks/ridges). Red = high accumulation (streams).
Viewshed — Mt. Everest (30×30 synthetic DEM)
Observer at the yellow cell (2m eye height). Green = visible, Brown = hidden.
Exported Functions
// Load the module from the pkg directory
import init, { decode_ozt2 } from '/pkg/openzenith_core.js';
const wasm = await init('/pkg/openzenith_core_bg.wasm');
// D8 flow direction — Uint8Array of 0-7 direction codes, 255 = no flow
const fd = d8_flow_direction_wasm(demPtr, len, rows, cols, -32768);
// Flow accumulation — Uint32Array of upstream counts (takes the signed grid)
const acc = flow_accumulation_wasm(fdPtr, len, rows, cols, -1);
// Stream order from accumulated flow — Uint8Array of Strahler orders
const order = stream_order_wasm(streamsPtr, fdPtr, len, rows, cols, -1);
// Gradient prediction — Int16Array of OZT2 residuals
const residuals = gradient_predict_wasm(elevPtr, len, rows, cols, -32768);
// Viewshed — Uint8Array of 0/1 visibility, null = no distance cap
const vis = viewshed_wasm(demPtr, len, rows, cols, obsRow, obsCol,
obsHeight, cellSize, -32768, null);
// Full OZT2 tile decode (header parsing + decompress callback + reconstruct).
// The callback receives the header's compressor code:
// 0 = brotli, 1 = zstd, 2 = zlib, 3 = none — route accordingly.
const { elevations, metadata } = decode_ozt2(tileBytes, decompressOZT2);