Skip to main content

Crate spart

Crate spart 

Source
Expand description

§Spart

A collection of space partitioning tree data structures for indexing points in 2D and 3D.

§API

All five trees implement index::SpatialIndex, so they share a common API for inserting, removing, and searching points. The trees differ in their partitioning strategy, which affects their performance and memory usage.

TreeDimensionsBounded
quadtree::Quadtree2Dyes
octree::Octree3Dyes
kdtree::KdTree2D and 3Dno
rtree::RTree2D and 3Dno
rstar_tree::RStarTree2D and 3Dno

§Example

use spart::geometry::{EuclideanDistance, Point2D, Rectangle};
use spart::quadtree::Quadtree;

let boundary = Rectangle { x: 0.0, y: 0.0, width: 100.0, height: 100.0 };
let mut tree: Quadtree<&str> = Quadtree::new(&boundary, 4).unwrap();
tree.insert(Point2D::new(10.0, 20.0, Some("a")));
tree.insert(Point2D::new(80.0, 30.0, Some("b")));

let nearest = tree.knn_search::<EuclideanDistance>(&Point2D::new(12.0, 22.0, None), 1);
assert_eq!(nearest[0].data, Some("a"));

Modules§

errors
Custom Errors for Spart
geometry
Geometric Primitives and Operations for 2D and 3D Spaces
index
The Common Spatial Index Interface
kdtree
Kd‑tree Implementation
octree
Octree Implementation
quadtree
Quadtree Implementation
rstar_tree
R*‑tree Implementation
rtree
R‑tree Implementation