Skip to main content

Crate wbtopology

Crate wbtopology 

Source
Expand description

§wbtopology

A pure-Rust topology suite inspired by JTS. The crate is dependency-light (currently zero external dependencies), avoids unsafe code, and focuses on predictable performance for core geometry predicates and operations.

§Selected APIs

§buffer_polygon_multi Example

use wbtopology::{buffer_polygon_multi, BufferOptions, Coord, LinearRing, Polygon};

let poly = Polygon::new(
    LinearRing::new(vec![
        Coord::xy(0.0, 0.0),
        Coord::xy(10.0, 0.0),
        Coord::xy(10.0, 10.0),
        Coord::xy(0.0, 10.0),
    ]),
    vec![],
);

let parts = buffer_polygon_multi(&poly, -1.0, BufferOptions::default());
assert!(!parts.is_empty());

§SpatialIndex Remove vs Compact Semantics

use wbtopology::{Coord, Geometry, SpatialIndex};

let geoms = vec![
    Geometry::Point(Coord::xy(0.0, 0.0)), // id 0
    Geometry::Point(Coord::xy(5.0, 0.0)), // id 1
    Geometry::Point(Coord::xy(9.0, 0.0)), // id 2
];
let mut idx = SpatialIndex::from_geometries(&geoms);

idx.remove(1);
let ids_after_remove: Vec<usize> = idx.all_entries().map(|e| e.id).collect();
assert_eq!(ids_after_remove, vec![0, 2]);

// Compaction reassigns dense ids.
idx.compact();
let ids_after_compact: Vec<usize> = idx.all_entries().map(|e| e.id).collect();
assert_eq!(ids_after_compact, vec![0, 1]);

Re-exports§

pub use error::Result;
pub use error::TopologyError;
pub use fixed_radius_search::DistanceMetric;
pub use fixed_radius_search::FixedRadiusSearch2D;
pub use constructive::buffer_linestring;
pub use constructive::buffer_linestring_curve_set;
pub use constructive::buffer_linestring_with_precision;
pub use constructive::buffer_polygon;
pub use constructive::buffer_polygon_multi;
pub use constructive::buffer_polygon_with_precision;
pub use constructive::buffer_point;
pub use constructive::buffer_point_with_precision;
pub use constructive::offset_linestring;
pub use constructive::make_valid_geometry;
pub use constructive::make_valid_polygon;
pub use constructive::polygonize_linework;
pub use constructive::polygonize_closed_linestrings;
pub use constructive::BufferBuilder;
pub use constructive::BufferCapStyle;
pub use constructive::BufferPipelineStrategy;
pub use constructive::BufferJoinStyle;
pub use constructive::BufferOptions;
pub use constructive::GeometryFixMode;
pub use constructive::GeometryFixOptions;
pub use constructive::OffsetCurveOptions;
pub use constructive::OffsetSide;
pub use constructive::PolygonizeOptions;
pub use constructive::PolygonizeResult;
pub use algorithms::distance::coord_dist;
pub use algorithms::distance::geometry_distance;
pub use algorithms::distance::is_within_distance;
pub use algorithms::distance::nearest_points;
pub use algorithms::measurements::geometry_area;
pub use algorithms::measurements::geometry_centroid;
pub use algorithms::measurements::geometry_length;
pub use algorithms::measurements::linestring_length;
pub use algorithms::measurements::polygon_area;
pub use algorithms::measurements::polygon_centroid;
pub use algorithms::measurements::ring_signed_area;
pub use algorithms::simplify::simplify_geometry;
pub use algorithms::simplify::simplify_polygon_coverage_topology_preserving;
pub use algorithms::simplify::simplify_geometry_topology_preserving;
pub use algorithms::simplify::simplify_linestring;
pub use algorithms::simplify::simplify_linestring_topology_preserving;
pub use algorithms::simplify::simplify_polygon;
pub use algorithms::simplify::simplify_polygon_topology_preserving;
pub use algorithms::simplify::simplify_ring;
pub use algorithms::simplify::simplify_ring_topology_preserving;
pub use algorithms::transform::rotate;
pub use algorithms::transform::scale;
pub use algorithms::transform::translate;
pub use geom::Coord;
pub use geom::Envelope;
pub use geom::Geometry;
pub use geom::LineString;
pub use geom::LinearRing;
pub use geom::Polygon;
pub use graph::DirectedEdge;
pub use graph::GraphNode;
pub use graph::TopologyGraph;
pub use hull::concave_hull;
pub use hull::concave_hull_geometry;
pub use hull::concave_hull_geometry_with_options;
pub use hull::concave_hull_geometry_with_precision;
pub use hull::concave_hull_with_options;
pub use hull::concave_hull_with_precision;
pub use hull::convex_hull;
pub use hull::convex_hull_geometry;
pub use hull::convex_hull_geometry_with_precision;
pub use hull::convex_hull_with_precision;
pub use hull::ConcaveHullEngine;
pub use hull::ConcaveHullOptions;
pub use io::from_wkb;
pub use io::from_wkt;
pub use io::to_wkb;
pub use io::to_wkt;
pub use natural_neighbour::PreparedSibsonInterpolator;
pub use noding::node_linestrings;
pub use noding::node_linestrings_with_options;
pub use noding::NodingOptions;
pub use noding::NodingStrategy;
pub use overlay::polygon_difference;
pub use overlay::polygon_difference_with_precision;
pub use overlay::polygon_difference_faces;
pub use overlay::polygon_intersection;
pub use overlay::polygon_intersection_with_precision;
pub use overlay::polygon_intersection_faces;
pub use overlay::polygon_overlay;
pub use overlay::polygon_overlay_all;
pub use overlay::polygon_overlay_all_with_precision;
pub use overlay::polygon_overlay_with_precision;
pub use overlay::polygon_overlay_faces;
pub use overlay::polygon_sym_diff;
pub use overlay::polygon_sym_diff_with_precision;
pub use overlay::polygon_sym_diff_faces;
pub use overlay::polygon_union;
pub use overlay::polygon_union_with_precision;
pub use overlay::polygon_union_faces;
pub use overlay::polygon_unary_union;
pub use overlay::polygon_unary_union_with_options;
pub use overlay::polygon_unary_dissolve;
pub use overlay::polygon_unary_dissolve_with_options;
pub use overlay::OverlayOutputs;
pub use overlay::OverlayOp;
pub use overlay::UnaryDissolveOptions;
pub use overlay::UnaryDissolveStrategy;
pub use overlay::UnaryDissolveGroup;
pub use precision::PrecisionModel;
pub use precision::TopologyPrecisionOptions;
pub use relate::relate;
pub use relate::relate_with_epsilon;
pub use relate::relate_with_precision;
pub use relate::Location;
pub use relate::RelateMatrix;
pub use spatial_index::IndexedGeometry;
pub use spatial_index::SpatialIndex;
pub use topology::contains;
pub use topology::contains_with_epsilon;
pub use topology::contains_with_precision;
pub use topology::covered_by;
pub use topology::covered_by_with_epsilon;
pub use topology::covered_by_with_precision;
pub use topology::covers;
pub use topology::covers_with_epsilon;
pub use topology::covers_with_precision;
pub use topology::crosses;
pub use topology::crosses_with_epsilon;
pub use topology::crosses_with_precision;
pub use topology::disjoint;
pub use topology::disjoint_with_epsilon;
pub use topology::disjoint_with_precision;
pub use topology::intersects;
pub use topology::intersects_with_epsilon;
pub use topology::intersects_with_precision;
pub use topology::is_simple_linestring;
pub use topology::is_valid_polygon;
pub use topology::overlaps;
pub use topology::overlaps_with_epsilon;
pub use topology::overlaps_with_precision;
pub use topology::touches;
pub use topology::touches_with_epsilon;
pub use topology::touches_with_precision;
pub use topology::within;
pub use topology::within_with_epsilon;
pub use topology::within_with_precision;
pub use topology::PreparedPolygon;
pub use triangulation::delaunay_triangulation;
pub use triangulation::delaunay_triangulation_with_constraints;
pub use triangulation::delaunay_triangulation_with_options;
pub use triangulation::delaunay_triangulation_with_options_checked;
pub use triangulation::delaunay_triangulation_with_precision;
pub use triangulation::DelaunayTriangulation;
pub use triangulation::TriangulationOptions;
pub use voronoi::voronoi_diagram;
pub use voronoi::voronoi_diagram_with_clip;
pub use voronoi::voronoi_diagram_with_clip_with_precision;
pub use voronoi::voronoi_diagram_with_options;
pub use voronoi::voronoi_diagram_with_precision;
pub use voronoi::VoronoiOptions;
pub use voronoi::VoronoiDiagram;

Modules§

algorithms
Low-level computational geometry kernels.
constructive
Constructive geometry utilities.
error
Error types for wbtopology.
fixed_radius_search
Fixed-radius point search utilities.
geom
Core geometry types.
graph
Topology graph utilities built from noded linework.
hull
Convex and concave hull utilities.
io
WKT/WKB interoperability for wbtopology geometries.
natural_neighbour
True natural-neighbour (Sibson) interpolation utilities.
noding
Noding utilities for linework.
overlay
Overlay face selection built on topology graph extraction.
precision
Precision model utilities.
relate
DE-9IM topological relation matrix — full implementation.
spatial_index
Spatial index for fast envelope-based candidate filtering.
topology
Topological predicates and validation helpers.
triangulation
Delaunay triangulation utilities.
vector_io
Interoperability with wbvector for vector read/write workflows.
voronoi
Voronoi diagram construction from Delaunay triangulation.

Functions§

delaunay_triangulation_fast
Build a fast 2D Delaunay triangulation using a sweep-hull strategy.