Expand description
R-tree spatial index for region and nearest-neighbor queries.
Provides a generic N-dimensional R-tree with linear and R*-tree split
algorithms, supporting insertion, removal, region queries, radius queries,
and k-nearest-neighbor lookups. The core types are parameterized by
const D: usize for the spatial dimension and T for user data.
Type aliases preserve the existing 2D and 3D API:
BoundingBox=BoundingBoxN<2>BoundingBox3D=BoundingBoxN<3>SpatialEntry=SpatialEntryN<2, T>SpatialEntry3D=SpatialEntryN<3, T>SpatialIndex=SpatialIndexN<2, T>SpatialIndex3D=SpatialIndexN<3, T>
§Concurrency
SpatialIndexN has no internal synchronization. For concurrent access,
wrap it in Arc<parking_lot::RwLock<>>:
ⓘ
use std::sync::Arc;
use parking_lot::RwLock;
use tensor_spatial::{SpatialIndex, SpatialEntry, BoundingBox};
let index = Arc::new(RwLock::new(SpatialIndex::<String>::new()));
// Read access (multiple concurrent readers allowed):
let region = BoundingBox::new(0.0, 0.0, 10.0, 10.0).unwrap();
let results = index.read().query_region(region);
// Write access (exclusive):
index.write().insert(SpatialEntry {
bounds: BoundingBox::new(1.0, 2.0, 1.0, 1.0).unwrap(),
data: "item".to_string(),
});Structs§
- Bounding
BoxN - An axis-aligned bounding box in
D-dimensional space. - Spatial
Config - Configuration for R-tree node capacity and split behavior.
- Spatial
EntryN - An entry in the spatial index pairing a bounding box with user data.
- Spatial
IndexN - A spatial index backed by an R-tree for efficient region and
nearest-neighbor queries in
D-dimensional space. - Spatial
IterN - Iterator over references to spatial entries in a
SpatialIndexN.
Enums§
- Spatial
Error - Errors that can occur during spatial operations.
- Split
Strategy - Split strategy for R-tree overflow handling.
Type Aliases§
- Bounding
Box - An axis-aligned bounding box in 2D space.
- Bounding
Box3D - An axis-aligned bounding box in 3D space.
- Spatial
Entry - An entry in the 2D spatial index pairing a bounding box with user data.
- Spatial
Entry3D - An entry in the 3D spatial index pairing a bounding box with user data.
- Spatial
Index - A 2D spatial index backed by an R-tree.
- Spatial
Index3D - A 3D spatial index backed by an R-tree.
- Spatial
Iter - Iterator over references to 2D spatial entries.
- Spatial
Iter3D - Iterator over references to 3D spatial entries.