![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@charto/spatialite
Advanced tools
Statically linked cross-platform SpatiaLite 4.0 binding for node.js. The goal of this project is to have a completely standalone build of SpatiaLite that doesn't require any system dependencies (no need to apt-get install ...
other than the ones required to build native node.js modules. The result is a consistent build across platforms with a guarantee of functionality and the versions of the dependencies. There are number of ways to get SpatiaLite binaries on the various platforms, but none of them include all of the features in a consistent way. This project contains a complete gyp build system for SpatiaLite - so someone might find it useful for other things outside of nodejs also.
If you're familiar with SQL, this is a great way to get easy access to the power of GEOS, Proj4, and SQL without needing a full PostGIS server.
$ npm install spatialite
This module simply exposes node-sqlite3 with an additional method on the Database
object to enable SpatiaLite. I opted to re-use this awesome library and dynamically load the extension so you can still use the node-sqlite3
API without SpatiaLite if you like.
Here is a simple example that shows the usage of GEOS-enabled Centroid
.
var sqlite = require('spatialite');
var db = new sqlite.Database(':memory:');
var query = "SELECT AsGeoJSON(Centroid(GeomFromText('POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))'))) AS geojson;";
db.spatialite(function(err) {
db.each(query, function(err, row) {
console.log(row.geojson);
});
});
GEOS_TRUNK
flag so all of the latest functions are available:
DelaunayTriangulation
VoronojDiagram
ConcaveHull
MakeValid
MakeValidDiscarded
Segmentize
Split
SplitLeft
SplitRight
Azimuth
SnapToGrid
GeoHash
AsX3D
MaxDistance
3DDistance
3DMaxDistance
There's a lot of code in these dependencies and the build scripts are fairly complex. If it doesn't work, submit an issue!
To build the shared library, you will need to first install node-gyp
.
$ npm install -g node-gyp
Build it:
$ node-gyp configure build
Compiling on Windows is a bit more involved. You will need to install these in this order. This should give you a working environment to compile native node.js bindings. The node-gyp repo also has some documentation on getting things working with Windows. It's possible it will also work with VS2012, but it's untested. I use veewee for testing with clean versions of Windows and this process does work. If you have problems, it's most likely something else that's installed conflicting with the build environment. This information was taken from here.
A lot of this was inspired by @TooTallNate's post on embedding dependencies in node modules.
http://n8.io/converting-a-c-library-to-gyp
This module is BSD licensed. The dependencies have their own licenses which are available in their directories.
FAQs
SpatiaLite for node
The npm package @charto/spatialite receives a total of 1 weekly downloads. As such, @charto/spatialite popularity was classified as not popular.
We found that @charto/spatialite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.