Skip to main content

Crate tensor_spatial

Crate tensor_spatial 

Source
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:

§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§

BoundingBoxN
An axis-aligned bounding box in D-dimensional space.
SpatialConfig
Configuration for R-tree node capacity and split behavior.
SpatialEntryN
An entry in the spatial index pairing a bounding box with user data.
SpatialIndexN
A spatial index backed by an R-tree for efficient region and nearest-neighbor queries in D-dimensional space.
SpatialIterN
Iterator over references to spatial entries in a SpatialIndexN.

Enums§

SpatialError
Errors that can occur during spatial operations.
SplitStrategy
Split strategy for R-tree overflow handling.

Type Aliases§

BoundingBox
An axis-aligned bounding box in 2D space.
BoundingBox3D
An axis-aligned bounding box in 3D space.
SpatialEntry
An entry in the 2D spatial index pairing a bounding box with user data.
SpatialEntry3D
An entry in the 3D spatial index pairing a bounding box with user data.
SpatialIndex
A 2D spatial index backed by an R-tree.
SpatialIndex3D
A 3D spatial index backed by an R-tree.
SpatialIter
Iterator over references to 2D spatial entries.
SpatialIter3D
Iterator over references to 3D spatial entries.