This library is a direct port of rveciana's raster-marching-squares to WebAssembly by way of C. The algorithm is implemented in C and currently generates GeoJSON isolines given raw data from a GeoTIFF file. Isobands will be supported in the future.
Import the library;
import loadWasmMarchingSquaresModule from 'wasm-marching-squares';
Load the WASM library asyncronously:
const WasmMarchingSquares = await loadWasmMarchingSquaresModule();
Create some isolines!
/**
* rasterMatrix: number[][]
* intervals: number[]
* transform: number[] (six values -> please see https://gdal.org/user/raster_data_model.html#affine-geotransform)
**/
const isolines = WasmMarchingSquares.generateIsolines(rasterMatrix, intervals, transform);- Need to add a cleaner external API for ease of use.
- Isoband generation is not implemented yet
To properly build, you will need to download the Emscripten SDK.
-
Compile the Jansson C JSON library using
emcc- Remove CMakeCache.txt from `include/jansson-2.13.1 if it exists
cd include/jansson-2.13.1 && emcmake cmake -DCMAKE_INSTALL_PREFIX:PATH=./emcc-lib .emmake make VERBOSE=1emmake make checkemmake make install
-
Generate the WASM code and JavaScript 'glue' code
./build-
Compile the Jansson C JSON library using cmake
- Remove CMakeCache.txt from `include/jansson-2.13.1 if it exists
cd include/jansson-2.13.1 && cmake .emmake make VERBOSE=1emmake make checkemmake make install
-
Compile and run the unit tests
cd test && ./test- Start a webserver and serve the
testdirectory - Navigate to the
index.htmland clickTest GeoJSON - You can test the
vardah.tiffile or thesfctmp.tiffile by altering thetest/map.jsfile.
- Implement Isoband generation
- Speed up lookups using a Quadtree