$ show georust/geo
This is the primary Rust geospatial geometry library (`georust/geo`), providing foundational data types (`Point`, `LineString`, `Polygon`, etc.) via `geo-types` and a comprehensive suite of computational geometry algorithms via the `geo` crate. The library implements OGC Simple Feature Access predicates (`Contains`, `Intersects`, `Covers`, `Within`), DE-9IM topological relationships (`Relate`), boolean operations (union, intersection, difference), convex/concave hulls, triangulation (ear-cutting, constrained Delaunay), simplification (Ramer-Douglas-Peucker, Visvalingam-Whyatt), distance calculations across multiple metric spaces (Euclidean, Haversine, Geodesic, Rhumb), spatial indexing (R-tree, ball tree, interval tree), clustering (DBSCAN, k-means), outlier detection (LOF), polygon repair, and validation. It is a library, not an applicationβno binary entry points, only examples and benchmarks. The codebase is characterized by a trait-oriented design, heavy use of macros to reduce boilerplate, generic numeric types (`GeoFloat`, `GeoNum`), and a metric-space abstraction that allows algorithms to be reused across coordinate systems. It has extensive test coverage including a JTS (Java Topology Suite) conformance test runner, fuzz testing, and criterion benchmarks. The architecture is modular with clear separation between types, traits, algorithms, and testing infrastructure. While generally well-maintained, some legacy modules (`old_sweep`) and deprecated traits exist, and the boolean operations depend on an external `i_overlay` crate.
The LLM identified 5 files worth highlighting for reuse:
Implements the `Distance` trait for the `Euclidean` metric space across all geometry type combinations. Uses macros (`symmetric_distance_impl!`, `impl_euclidean_distance_for_polygonlike_geometry!`) to exhaustively generate implementations, reducing boilerplate. Includes optimized strategies: bounding-box pruning for multi-geometry distance, a O(n log n) fast path for linearly separable geometries using 1D projection, and R*-tree nearest-neighbour search as a fallback. Demonstrates a reusable pattern for metric-space genericity and macro-driven type dispatch.
Provides `BooleanOps` trait with methods for union, intersection, difference, xor, and unary union on polygons. Delegates to the `i_overlay` crate via `BoolOpsCoord` newtype, but wraps it with a fill-rule parameter (`EvenOdd` by default) and handles coordinate type conversion. The RFC `rfcs/2022-05-24-boolean-ops.md` documents the underlying Martinez-Rueda-Feito algorithm and Bentley-Ottmann sweep design. This module is the entry point for boolean set operations and is tested against JTS/GEOS expected outputs.
Implements OGC Simple Feature Access polygon validity checks, including ring orientation, self-intersection, and interior connectivity. Uses `GeometryGraph` and union-find for non-trivial checks like `InteriorNotSimplyConnected`. Provides detailed error types (`InvalidPolygon`, `InvalidRing`, etc.) with `thiserror`. The implementation is compared against GDAL's validity documentation and JTS `IsValidOp`. Reusable as a standalone validation library for any polygon geometry.
A clean implementation of the Bentley-Ottmann sweep-line algorithm for detecting all segment intersections in a set of line segments. Produces an `Intersections` iterator that yields each intersection event with the two intersecting segments. Used internally by triangulation preprocessing and boolean operations. The module is well-documented with complexity notes and includes a comprehensive test suite covering degenerate cases (collinear, overlapping, endpoints). The new `sweep` replaces the legacy `old_sweep` module which used `unsafe` transmutes.
Defines generic geometry traits (`GeometryTrait`, `PointTrait`, `LineStringTrait`, etc.) that provide a type-erased interface to access geometric data without depending on concrete `geo-types` types. Includes `ToGeo` for converting from trait-backed types to `geo-types`. This enables interoperability with other geometry libraries (e.g., `geoarrow`) and supports zero-copy access patterns. The design is similar to the `geo`/`geo-types` separation but at a higher abstraction level, making it a reusable pattern for building generic geospatial tooling.