Skip to main content

Module vector

Module vector 

Source
Expand description

Vector operations and geometric algorithms

This module provides comprehensive geometric operations for vector data:

§Core Operations

  • Buffer generation (fixed and variable distance)
  • Intersection operations
  • Union operations
  • Difference operations

§Topology Operations

  • Overlay analysis (intersection, union, difference, symmetric difference)
  • Erase operations (cookie-cutter)
  • Split operations (geometry splitting)

§Network Analysis

  • Graph structures and building
  • Shortest path algorithms (Dijkstra, A*, bidirectional)
  • Service area calculation (isochrones)
  • Advanced routing with constraints

§Spatial Clustering

  • DBSCAN (density-based clustering)
  • K-means clustering
  • Hierarchical clustering

§Triangulation

  • Delaunay triangulation
  • Voronoi diagrams
  • Constrained Delaunay

§Spatial Joins

  • R-tree spatial index
  • Nearest neighbor search
  • K-nearest neighbors
  • Range queries

§Simplification

  • Douglas-Peucker algorithm
  • Visvalingam-Whyatt algorithm
  • Topology-preserving simplification

§Geometric Analysis

  • Centroid calculation (geometric and area-weighted)
  • Area calculation (planar and geodetic)
  • Length measurement (planar and geodetic)
  • Distance measurement (Euclidean, Haversine, Vincenty)
  • Convex hull computation

§Spatial Predicates

  • Contains, Within
  • Intersects, Disjoint
  • Touches, Overlaps, Crosses

§Validation & Repair

  • Geometry validation
  • Self-intersection detection
  • Duplicate vertex detection
  • Spike detection
  • Geometry repair (fix orientation, remove duplicates, close rings)

§Coordinate Transformation

  • CRS transformation (WGS84, Web Mercator, UTM, etc.)
  • Geometry reprojection

§Object Pooling

  • Thread-local object pools for Point, LineString, Polygon
  • Pooled versions of buffer, union, difference, intersection operations
  • Reduces allocations by 2-3x for batch operations
  • Automatic return to pool via RAII guards

§Using Object Pooling

use oxigdal_algorithms::vector::{buffer_point_pooled, Point, BufferOptions};

let point = Point::new(0.0, 0.0);
let options = BufferOptions::default();

// Get a pooled polygon - automatically returned to pool when dropped
let buffered = buffer_point_pooled(&point, 10.0, &options)?;
// Use buffered geometry...
// Polygon returned to pool when `buffered` goes out of scope

All operations use geometry types from oxigdal-core::vector.

Re-exports§

pub use pool::Pool;
pub use pool::PoolGuard;
pub use pool::PoolStats;
pub use pool::clear_all_pools;
pub use pool::get_pool_stats;
pub use pool::get_pooled_coordinate_vec;
pub use pool::get_pooled_linestring;
pub use pool::get_pooled_point;
pub use pool::get_pooled_polygon;

Modules§

clustering
Spatial clustering algorithms for point data
delaunay
Delaunay triangulation
network
Network analysis for geospatial routing and accessibility
pool
Object pooling for geometry types to reduce allocations
spatial_join
Spatial join operations with spatial indexing
topology
Topology operations for advanced vector processing
voronoi
Voronoi diagram generation

Structs§

BufferOptions
Options for buffer operations
Coordinate
Coordinate in 2D, 3D, or 4D space
CrsTransformer
Transformer for coordinate reference system conversions
LineString
LineString geometry
MultiPolygon
MultiPolygon geometry
Point
Point geometry
Polygon
Polygon geometry
RepairOptions
Options for geometry repair operations
ValidationIssue
A validation issue found in a geometry

Enums§

AreaMethod
Area calculation method
BufferCapStyle
End cap style for line buffers
BufferJoinStyle
Join style for line buffers at vertices
CommonCrs
Common coordinate reference systems
DistanceMethod
Distance calculation method
IssueType
Validation issue type
LengthMethod
Length calculation method
SegmentIntersection
Intersection result for two line segments
Severity
Validation issue severity
SimplifyMethod
Simplification algorithm selection

Traits§

ContainsPredicate
Trait for geometries that support contains predicate
CrossesPredicate
Trait for geometries that support crosses predicate
IntersectsPredicate
Trait for geometries that support intersects predicate
OverlapsPredicate
Trait for geometries that support overlaps predicate
TouchesPredicate
Trait for geometries that support touches predicate

Functions§

area
Computes the area of a geometry
area_multipolygon
Computes the area of a multipolygon
area_polygon
Computes the area of a polygon
buffer_linestring
Generates a buffer around a linestring
buffer_linestring_pooled
Generates a buffer around a linestring using object pooling
buffer_point
Generates a circular buffer around a point
buffer_point_pooled
Generates a circular buffer around a point using object pooling
buffer_polygon
Generates a buffer around a polygon
buffer_polygon_pooled
Generates a buffer around a polygon using object pooling
cascaded_union
Computes cascaded union of multiple polygons
cascaded_union_pooled
Computes cascaded union using object pooling (alias)
centroid
Computes the centroid of any geometry type
centroid_collection
Computes the centroid of a geometry collection
centroid_linestring
Computes the geometric centroid of a linestring
centroid_multilinestring
Computes the centroid of a multilinestring
centroid_multipoint
Computes the centroid of a multipoint
centroid_multipolygon
Computes the centroid of a multipolygon
centroid_point
Computes the centroid of a point (returns the point itself)
centroid_polygon
Computes the area-weighted centroid of a polygon
clip_to_box
Clips a polygon to a rectangular bounding box
close_ring
Closes an unclosed ring by adding the first point at the end
contains
Tests if geometry A contains geometry B
convex_hull
Computes the convex hull of a set of points
convex_hull_pooled
Computes convex hull and returns as pooled polygon
crosses
Tests if one geometry crosses another
difference_polygon
Computes the difference of two polygons (poly1 - poly2)
difference_polygon_pooled
Computes difference of two polygons using object pooling
difference_polygons
Computes the difference of multiple polygons
difference_polygons_pooled
Computes difference of base polygons with subtract polygons using object pooling
disjoint
Tests if geometries are disjoint (share no points)
distance_point_to_linestring
Computes minimum distance from a point to a linestring
distance_point_to_point
Computes distance between two points
distance_point_to_polygon
Computes minimum distance from a point to a polygon boundary
envelope
Computes the envelope of any geometry type
envelope_collection
Computes the envelope of a geometry collection
envelope_contains_point
Checks if an envelope contains a point
envelope_intersection
Computes the intersection of two envelopes
envelope_linestring
Computes the envelope of a linestring
envelope_multilinestring
Computes the envelope of a multilinestring
envelope_multipoint
Computes the envelope of a multipoint
envelope_multipolygon
Computes the envelope of a multipolygon
envelope_point
Computes the envelope of a point
envelope_polygon
Computes the envelope of a polygon
envelope_union
Computes the union of two envelopes
envelope_with_buffer
Computes expanded envelope with buffer
envelopes_intersect
Checks if two envelopes intersect
erase_small_holes
Erases small holes from a polygon
fix_self_intersection
Attempts to fix self-intersecting polygons using a buffer of 0
intersect_linestrings
Computes all intersection points between two linestrings
intersect_linestrings_sweep
Computes all intersection points using Bentley-Ottmann sweep line algorithm
intersect_polygons
Computes intersection of two polygons
intersect_polygons_pooled
Computes intersection of two polygons using object pooling
intersect_segment_segment
Computes intersection of two line segments
intersects
Tests if geometries intersect (share any points)
is_clockwise
Checks if a polygon is oriented clockwise
is_counter_clockwise
Checks if a polygon is oriented counter-clockwise
length
Computes the length of a geometry
length_linestring
Computes the length of a linestring
length_linestring_3d
Computes 3D length of a linestring (Euclidean distance including Z coordinate)
length_multilinestring
Computes the length of a multilinestring
merge_polygons
Merges touching or overlapping polygons
overlaps
Tests if geometries overlap (share some but not all points)
point_in_polygon
Checks if a point is inside a polygon using ray casting algorithm
point_in_polygon_or_boundary
Tests if a point is inside or on the boundary of a polygon
point_on_polygon_boundary
Tests if a point is on the boundary of a polygon
point_strictly_inside_polygon
Tests if a point is strictly inside a polygon (not on boundary)
remove_collinear_vertices
Removes collinear vertices (simplification)
remove_duplicate_vertices
Removes consecutive duplicate vertices
remove_spikes
Removes spike vertices (vertices that create a sharp reversal)
repair_linestring
Repairs a linestring according to specified options
repair_linestring_with_options
Repairs a linestring with custom options
repair_polygon
Repairs a polygon according to specified options
repair_polygon_with_options
Repairs a polygon with custom options
reverse_ring
Reverses the orientation of a ring
simplify_linestring
Simplifies a linestring using the specified algorithm
simplify_linestring_dp
Simplifies a linestring using Douglas-Peucker algorithm
simplify_polygon
Simplifies a polygon using the specified algorithm
symmetric_difference
Computes the symmetric difference of two polygons
symmetric_difference_pooled
Computes symmetric difference using object pooling
touches
Tests if geometries touch (share boundary but not interior)
transform_geometry
Transforms a geometry between coordinate reference systems
transform_linestring
Transforms a linestring between coordinate reference systems
transform_point
Transforms a point between coordinate reference systems
transform_polygon
Transforms a polygon between coordinate reference systems
union_polygon
Computes union of two polygons
union_polygon_pooled
Computes union of two polygons using object pooling
union_polygons
Computes union of multiple polygons (alias for clarity)
union_polygons_pooled
Computes cascaded union of multiple polygons using object pooling
validate_geometry
Validates a geometry and returns list of issues
validate_linestring
Validates a linestring
validate_polygon
Validates a polygon
within
Tests if geometry A is within geometry B (inverse of contains)