Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Latest commit

 

History

History
65 lines (46 loc) · 2.36 KB

README.md

File metadata and controls

65 lines (46 loc) · 2.36 KB

libgeos.zig

Zig bindings for the GEOS C library (libgeos)

GEOS (Geometry Engine, Open Source) is a C/C++ library for spatial computational geometry of the sort generally used by “geographic information systems” software. GEOS is a core dependency of PostGIS, QGIS, GDAL, and Shapely.

GEOS version

3.10.2-CAPI-1.16.0

Zig version

  • 0.9.1, 0.10.0-dev

Build

Requires only zig. Don't forget to clone/init the submodule!

git clone --recurse-submodules https://github.com/guidorice/libgeos.zig.git
cd libgeos.zig/
zig build

Tests

zig build test

Examples

$ zig build --help
$ zig build run-ex1
Geometry A:         POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))
Geometry B:         POLYGON((5 5, 15 5, 15 15, 5 15, 5 5))
Intersection(A, B): POLYGON ((10 10, 10 5, 5 5, 5 10, 10 10))

Known Issues

  • blocker: The libgeos library uses C++ std::runtime_error, which is not currently captured by the Zig wrapper code. As a result, there is no way to recover from some error conditions, for example, failing to parse some WKT formatted string. see issue #9

Roadmap

  • Minimal build.zig. Builds libgeos entirely using Zig compiler and build system.
  • Create example exe using this package as a Zig library.
  • Port libgeos C examples to Zig (from src/geos/examples)
    • Ex 1 Reads two WKT representations and calculates the intersection, prints it out, and cleans up.
    • Ex 1 (threadsafe)
    • Ex 2 Reads one geometry and does high-performance prepared geometry operations to place "random" points inside it.
    • Ex 3 Build a spatial index and search it for a nearest pair.
  • Solution for std:runtime_error conditions (see known issues)
  • New Zig idiomatic wrapper for libgeos C API? Alternatively: port to Zig-native.
  • New GeoJSON reader/writer which speaks libgeos types and full support for Feature properties. Reference: GEOS GeoJSON support notes here.
  • New Zig projects which utilize these Geospatial or Geometric primitives.

Notes

See also vendor/geos/README for how libgeos is updated within this repo.