How libgeos/geos works
GEOS is a C++ library for two-dimensional vector geometry, with a stable C interface and a CLI for invoking operations. The typical client workflow is to supply geometries, run a spatial operation, and receive a geometry or predicate result; the C wrapper delegates operations to the C++ implementation. Its major capabilities include geometry I/O, spatial predicates and overlay, buffering, coverage processing, and geometric algorithms. The source excerpts show some specific delegation, but not most runtime wiring, so uncertain internal links are dashed and have no evidence path.
Main entry points: Geometry.h Geometry model · CoverageCleaner.cpp Coverage cleaning · geos_c.cpp C API · OverlayNG.h Overlay
Components 18
Client interfaces
- C++ API
include/geos.h - C API
capi/geos_c.cpp - geosop CLI
util/geosop/GeometryOp.cpp - WKT I/O
src/io/WKTReader.cpp
Geometry model
- Geometry model
include/geos/geom/Geometry.h - Geometry factory
src/geom/GeometryFactory.cpp
Spatial operations
- Predicates
include/geos/operation/relateng/RelateNG.h - Overlay
include/geos/operation/overlayng/OverlayNG.h - Buffering
include/geos/operation/buffer/BufferOp.h - Coverage union
src/operation/overlayng/CoverageUnion.cpp - Coverage cleaning
src/coverage/CoverageCleaner.cpp - Coverage validation
src/coverage/CoveragePolygonValidator.cpp
Algorithms and indexing
- Geometry algorithms
include/geos/algorithm/Distance.h - Noding
src/noding/GeometryNoder.cpp - Spatial indexes
src/index/strtree/STRtree.cpp - Prepared geometry
src/geom/prep/AbstractPreparedPolygonContains.cpp
Other components
- C++ client
- C client
Connections 19
- C++ client → C++ API: uses
README.md - C client → C API: uses
README.md - C++ API → Geometry model: operates on
- C API → Geometry model: reads geometry
- C API → Overlay: calls overlay
- geosop CLI → Geometry model: operates on
- C++ client → WKT I/O: uses
- WKT I/O → Geometry factory: creates geometries
- Geometry factory → Geometry model: creates geometries
- Geometry model → Predicates: input to
- Geometry model → Overlay: input to
- Geometry model → Buffering: input to
- Geometry model → Geometry algorithms: input to
- Coverage union → Overlay: delegates to
src/operation/overlayng/CoverageUnion.cpp - Coverage cleaning → Noding: snaps segments
src/coverage/CoverageCleaner.cpp - Coverage cleaning → Coverage validation: cleans coverage
- Coverage cleaning → Coverage union: uses union
- Predicates → Spatial indexes: uses indexes
- Prepared geometry → Spatial indexes: uses indexes