boost_geometry
A Rust port of Boost.Geometry following its philosophy: dimension-agnostic, coordinate-system-agnostic, bring-your-own-type, strategy-pluggable.
The library's algorithms are written against concept traits
(Point, Ring, Polygon, …), not concrete structs — so your own
domain types participate directly, exactly like
BOOST_GEOMETRY_REGISTER_* in C++.
- Edition: Rust 2024, MSRV 1.85
- Safety:
unsafe_code = "forbid"across the whole workspace - Docs: see
docs/for the architecture, the tag-dispatch pattern, and the overlay engine
Quick start — your own polygon type, buffered and validated
Add the dependency:
Register your own ring and polygon types with one macro declaration
each, run is_valid_polygon on them directly, and buffer
(runnable as cargo run --example parcel_buffer):
use ;
use ;
use ;
use *;
type P = ;
// Your own geometry types — no wrapper, no conversion trait.
// One declaration each and the library's algorithms accept them.
register_ring!;
register_polygon!;
Output:
parcel valid: Ok(())
buffered valid: Ok(())
area 4.000 -> 15.141
The buffered area matches the closed form for a square grown by distance d with round corners: s² + 4·s·d + π·d² = 4 + 8 + π ≈ 15.14.
What the example shows:
register_ring!/register_polygon!implement the concept traits for your structs (Rust's orphan rule forbids a blanket impl, so the macros mint it per type — the same coherence workaround theBOOST_GEOMETRY_REGISTER_*macros perform in C++). Defaults are closed, clockwise rings; both are overridable per type.is_valid_polygonchecks the OGC simple-feature rules — point count, closure, finite coordinates, spikes, self-intersections, ring orientation, hole containment — and reports the first failure as aValidityFailurevariant (Err(SelfIntersection),Err(WrongOrientation), …) rather than a barefalse.buffer_convex_polygongrows the polygon outward, rounding each corner with a circular arc (JoinStrategy::Mitergives sharp corners instead). v1 buffers points and convex polygons with positive distances.correctfixes ring closure and orientation in place — the Boostbg::correctcounterpart.
Workspace layout
Nineteen crates form a dependency spine from foundational tag/coords
crates up through traits, models, strategies, and algorithms to the
boost_geometry facade — plus adapters (nalgebra, geo-types), IO
(WKT, WKB, GeoJSON, SVG), an R-tree, overlay operations, and
projections. boost_geometry re-exports everything; depend on it alone
unless you need a slimmer build.
See docs/01-architecture.md
for the full map.
License
BSL-1.0 — see LICENSE.