GEOS for Linux
v3.15.0LinuxGEOS 3.15.0 for native Node.js addons on Linux, precompiled for x64 and arm64, glibc 2.28 or later as @crossbind/port-geos-linux.
npm install @crossbind/port-geos-linux@betaInstall
The addons and their loader land in dist; the Node.js playbook has the whole flow.
Usage
The examples the WebAssembly page runs, as Linux compiles them: the same headers and the same calls. They are checked on the WebAssembly build.
Intersect, unite and subtract two polygons
Overlay is the most used part of GEOS: GEOSIntersection_r, GEOSUnion_r and GEOSDifference_r on shapes read from WKT, with GEOSArea_r to measure the result.
3.15.0-CAPI-1.21.0 POLYGON ((5 5, 5 10, 10 10, 10 5, 5 5)) 25 175 75
Test points against a prepared polygon
Point in polygon is the most common spatial question. GEOSPrepare_r indexes the polygon once; GEOSPreparedContainsXY_r and GEOSPreparedIntersectsXY_r then answer per point and differ only on the boundary, and GEOSPreparedRelate_r gives the full DE-9IM matrix.
2 2: contains true, intersects true 5 5: contains false, intersects false 10 5: contains false, intersects true 12 5: contains false, intersects false 212101212
Measure area, length and distance
GEOSArea_r, GEOSLength_r and GEOSDistance_r in the units of the coordinates, GEOSNearestPoints_r for where two shapes come closest, and GEOSGetCentroid_r. GEOS works in the plane, so project longitude and latitude before measuring.
1200 140 60 15 LINESTRING (40 30, 52 39) POINT (20 15)
Buffer points, lines and polygons
GEOSBuffer_r turns a point into a circle of straight segments, GEOSBufferWithStyle_r sets the caps and joins of a line's corridor, a negative distance shrinks a polygon, and GEOSOffsetCurve_r draws a parallel line.
312.1445 1000 1078.0361 POLYGON ((2 2, 2 18, 18 18, 18 2, 2 2)) 256 LINESTRING (0 5, 100 5)
Find why a polygon is invalid and repair it
GEOSisValid_r and GEOSisValidReason_r say whether a shape breaks the OGC rules, what is wrong and where. GEOSMakeValidWithParams_r repairs it two ways, which agree on a bowtie and differ on a hole that leaks out of its shell.
false Self-intersection[5 5] MULTIPOLYGON (((5 5, 10 10, 10 0, 5 5)), ((0 0, 0 10, 5 5, 0 0))) true 50 Self-intersection[5 10] linework 150 structure 75
What is different on Linux
crossbind build -p linuxlinks 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 runs on glibc 2.28 or later (RHEL 8, Debian 10, Ubuntu 20.04 and newer), not on musl distributions such as Alpine.
- 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
- GEOS overview: the apps, every platform's setup and the packages.
- GEOS for WebAssembly: browsers, Node.js and edge runtimes.
- GEOS for Android: React Native apps on Android.
- GEOS for iOS: React Native apps on iOS.
- GEOS for macOS: native Node.js addons and Electron on macOS.
- GEOS for Windows: native Node.js addons on Windows.
- GEOS 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.