SpatiaLite for Windows
v5.1.0WindowsSpatiaLite 5.1.0 for native Node.js addons on Windows, precompiled for x64 and arm64, Windows 10 or later as @crossbind/port-spatialite-win32.
Install
The addons and their loader land in dist; the Node.js playbook has the whole flow.
Usage
The examples the WebAssembly page runs, as Windows compiles them: the same headers and the same calls. They are checked on the WebAssembly build.
Store points and measure the distance between them
The calls every SpatiaLite program starts with: spatialite_alloc_connection and spatialite_init_ex register the spatial SQL functions on a SQLite connection, InitSpatialMetaData creates the metadata tables and AddGeometryColumn adds a geometry column. GeomFromText reads WKT, and ST_Distance(a, b, 1) measures on the WGS 84 ellipsoid.
Find places in a map view and the nearest ones with a spatial index
CreateSpatialIndex keeps an R*Tree of the bounding boxes of a geometry column, and queries reach it through virtual tables: SpatialIndex returns the rows inside a box such as the map view, and KNN2 the rows nearest to a point with their distance in metres.
Measure areas and distances in metres
SpatiaLite measures in the units of the coordinates, so ST_Area of a longitude/latitude polygon comes out in square degrees. ST_Transform to a projected CRS, here UTM zone 35N (EPSG:32635), gives square metres and metres, stretched the further a shape lies from the zone; ST_Distance(a, b, 1) measures on the ellipsoid with no projection at all.
Reproject coordinates between EPSG codes
ST_Transform moves a geometry to another reference system through PROJ, which reads the proj.db the build preloads. InitSpatialMetaData(1) registers the 6,559 EPSG codes SpatiaLite knows in spatial_ref_sys, where their names are too.
Read GeoJSON in and write a FeatureCollection out
GeomFromGeoJSON reads a GeoJSON geometry into a SpatiaLite geometry, and AsGeoJSON writes one back rounded to the decimals you ask for. SQLite's JSON functions wrap the rows into a FeatureCollection that Leaflet, MapLibre or OpenLayers load as it is.
What is different on Windows
crossbind build -p win32links one.nodeaddon per architecture intodist, next to a loader,dist/<name>.native.cjs, thatrequireandimportboth load. A plaincrossbind buildskips it.await initNative()once, then call the classes: calls are synchronous, and no Worker is involved.- The library and the C++ runtime are linked into the addon statically; it needs Windows 10 or later and only DLLs that ship with Windows.
- There is no
m.FS: the C++ reads real paths, and data such asGDAL_DATAorproj.dbis copied todist/data. - The build runs in Docker on any host, a Mac included.
worker_threadsare not supported yet.
Other platforms
- SpatiaLite overview: the apps, every platform's setup and the packages.
- SpatiaLite for WebAssembly: browsers, Node.js and edge runtimes.
- SpatiaLite for Android: React Native apps on Android.
- SpatiaLite for iOS: React Native apps on iOS.
- SpatiaLite for macOS: native Node.js addons and Electron on macOS.
- SpatiaLite for Linux: native Node.js addons on Linux.
- SpatiaLite for WASI: command-line programs under wasmtime.
Facts on this page come from the port manifests in the repository and from what npm served on beta when the site was built. See the Libraries guide for the full consumer flow.