Configuration
Two layers of configuration: how the module boots (initCppJs), and how GDAL behaves once it's running (config options).
initCppJs options
const Module = await initCppJs({
useWorker: true, // run GDAL in a Web Worker (browser)
fs: { opfs: true }, // back the virtual FS with OPFS (browser)
});
| OPTION | DEFAULT | WHAT IT DOES |
|---|---|---|
useWorker | false | Boots the wasm module inside a Web Worker and returns proxied objects, so conversions never block the UI thread. See workers. |
fs.opfs | false | Mounts the Origin Private File System at /opfs. Files placed there persist across page reloads. See VFS. |
On Node and React Native, initCppJs() needs no options. GDAL works against the host filesystem.
GDAL config options
Anything you'd set with --config KEY VALUE on the CLI is available at runtime:
await Gdal.setConfigOption("OGR_ORGANIZE_POLYGONS", "SKIP"); // issue #101's fix
await Gdal.setConfigOption("OSM_USE_CUSTOM_INDEXING", "NO"); // issue #87's fix
const v = await Gdal.getConfigOption("OGR_ORGANIZE_POLYGONS", "");
Related calls, straight from the bound GDAL API: setThreadLocalConfigOption, getGlobalConfigOption, getConfigOptions, and path-scoped variants (setPathSpecificOption, getPathSpecificOption, clearPathSpecificOptions). The full catalogue of keys is in the GDAL configuration options documentation.
Driver-specific open options (the CLI's -oo) go through Gdal.openEx(path, flags, allowedDrivers, openOptions, siblingFiles) instead.
PROJ data
The PROJ database (proj.db) ships inside the data bundle and is found automatically. If you relocate it, point PROJ at the new directory with Gdal.setProjDataPath(path).
Raster block cache
await Gdal.setCacheMax(64 * 1024 * 1024); // bytes
const used = await Gdal.getCacheUsed();
const max = await Gdal.getCacheMax();
GDAL's raster block cache trades memory for speed. In memory-constrained tabs (mobile browsers especially), lowering it helps. See memory.
v2 equivalents
| V2 | V3 |
|---|---|
initGdalJs({ path, paths }) | Not needed: the bundler plugin resolves assets |
initGdalJs({ env: {…} }) | Gdal.setConfigOption(key, value) |
initGdalJs({ dest }) | Pass the output path directly to each program call |
logHandler / errorHandler | Error-state API |