nimgeos
Nim wrapper for the GEOS geometry engine (libgeos_c)
Wraps a native library — check OS Compatibility below for platform-specific linking notes.
Summary
| Latest Version | 1.0.0 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-11-21 14:04 |
Tags
Authors
- John Moutafis
Installation
nimble install nimgeos
choosenim install nimgeos
git clone https://github.com/JohnMoutafis/nimgeos
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| nimgeos | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 2.0.0 | No |
Source
| Repository | https://github.com/JohnMoutafis/nimgeos |
|---|---|
| Homepage | https://github.com/JohnMoutafis/nimgeos |
| Registry Source | nimble_official |
README
nimgeos
Nim wrapper for the GEOS geometry engine (libgeos_c).
Build and manipulate 2D/3D geometries — points, linestrings, polygons, multi-geometries and collections — using the battle-tested GEOS C library from idiomatic Nim. Deterministic memory management via ORC, nil-safe, and cross-platform (Linux, macOS, Windows).
Quick start
import nimgeos
var ctx = initGeosContext()
let p = ctx.createPoint(1.0, 2.0)
let ls = ctx.createLineString([(0.0, 0.0), (3.0, 4.0)])
echo p # Point (1.0 2.0)
echo ls # LineString(2 points)
echo ls.length() # 5.0
# Serialize to WKT
echo p.toWKT() # POINT (1 2)
# 3D geometries
let p3d = ctx.createPoint(1.0, 2.0, 3.0)
echo p3d # Point (1.0 2.0 3.0)
Documentation
Getting started
- Installation — Prerequisites,
nimble install, platform compatibility - Context lifecycle —
initGeosContext,withGeosContext, error handlers, thread safety
Geometry types
- Geometry overview — Type hierarchy, base procs (
type,isEmpty,area,length,distance,clone, etc.) - Point —
createPoint(2D/3D),x,y,z - LineString —
createLineString,numPoints,pointN,startPoint,endPoint - LinearRing —
createLinearRing, closed-ring requirement - Polygon —
createPolygon,exteriorRing, holes (numInteriorRings,interiorRingN) - Multi-geometries —
MultiPoint,MultiLineString,MultiPolygon,GeometryCollection,geomN, iterators - Prepared geometry —
preparefor fast repeated predicates - CoordSeq — Coordinate sequence API, getters/setters, iterators
Serialization
- WKT —
fromWKT,toWKT - WKB —
fromWKB,toWKB,toHexWKB,fromHexWKB, byte order - GeoJSON —
toGeoJSON,fromGeoJSON
Spatial operations
- Predicates —
equals,intersects,contains,touches,within,disjoint,crosses,overlaps - Spatial operations —
intersection,union,difference,buffer,simplify,convexHull,centroid,envelope,boundary,snap,topologyPreserveSimplify,unaryUnion,symmetricDifference
Edge cases & error handling
- Empty geometries —
isEmpty, per-operation behavior - Special floating-point values — NaN, infinity, Z on 2D geometries
- Error types —
GeosInitError,GeosGeomError,GeosParseError - Nil-safety — nil-handle guards and
$behavior
API reference
Online API documentation is available at the GitHub Pages site
Supported platforms
Minimum versions: Nim ≥ 2.0.0 · GEOS (libgeos_c) ≥ 3.8.
| Platform | Status | CI |
|---|---|---|
| Ubuntu | ✅ Supported | Full CI on every PR/push |
| macOS | ✅ Supported | Full CI on every PR/push |
| Windows | 🧪 Experimental | CI runs; failures non-blocking |
Nim versions: stable (required, CI-gated) and devel (CI runs but allow-failure).
Full support matrix, geometry expectations, and error/context guarantees: Support Policy.
See installation guide for platform-specific prerequisites and CONTRIBUTING.md for CI policy.
License
MIT