Expand description
Packed static spatial index for 2D and 3D axis-aligned bounding boxes.
The canonical flow is Index2DBuilder -> Index2D -> Index2D::search.
With the simd feature, Index2DBuilder::finish_simd and
Index3DBuilder::finish_simd build SimdIndex2D and SimdIndex3D, which
have the same search APIs backed by SoA layouts and SIMD traversal.
Index2D, Index3D, and their SIMD counterparts can also be serialized
with to_bytes; scalar indexes can be viewed without copying through
Index2DView and Index3DView.
§Quick Start
use packed_spatial_index::{Index2DBuilder, Box2D};
let mut builder = Index2DBuilder::new(2);
builder.add(Box2D::new(0.0, 0.0, 1.0, 1.0));
builder.add(Box2D::new(5.0, 5.0, 6.0, 6.0));
let index = builder.finish().unwrap();
assert_eq!(index.search(Box2D::new(0.0, 0.0, 2.0, 2.0)), vec![0]);§Cargo Features
parallel(enabled by default): adaptive parallel builds through rayon.simd(enabled by default):SimdIndex2DandSimdIndex3Dwith SIMD searches throughwideand x86-64 AVX-512 intrinsics where available.
Structs§
- Box2D
- Axis-aligned 2D box stored as
(min_x, min_y, max_x, max_y). - Box3D
- Axis-aligned 3D box stored as
(min_x, min_y, min_z, max_x, max_y, max_z). - Index2D
- Finished static read-only index.
- Index2D
Builder - Builder for
Index2Dand, with thesimdfeature,SimdIndex2D. - Index2D
View - Zero-copy read-only view over bytes produced by
Index2D::to_bytes. - Index3D
- Finished static read-only 3D index.
- Index3D
Builder - Builder for
Index3Dand, with thesimdfeature,SimdIndex3D. - Index3D
View - Zero-copy read-only view over bytes produced by
Index3D::to_bytes. - Neighbor
Workspace - Reusable buffers for allocation-free repeated nearest-neighbor searches.
- Point2D
- 2D point used by nearest-neighbor searches.
- Point3D
- 3D point used by nearest-neighbor searches.
- Search
Workspace - Reusable buffers for allocation-free repeated searches.
- Simd
Index2D simd - Finished read-only SIMD index.
- Simd
Index2D View simd - Zero-copy SIMD view over bytes produced by
SimdIndex2D::to_bytesorIndex2D::to_bytes. - Simd
Index3D simd - Finished read-only SIMD 3D index.
- Simd
Index3D View simd - Zero-copy SIMD view over bytes produced by
SimdIndex3D::to_bytesorIndex3D::to_bytes.
Enums§
- Bounds
Error - Error returned by
Box2D::try_newandBox3D::try_newfor invalid coordinate bounds. - Build
Error - Build error for finishing an index.
- Load
Error - Error returned when loading an index from bytes.
- Sort
Key2D - Which key to use when sorting boxes before packing the tree.
- Sort
Key3D - Which key to use when sorting 3D boxes before packing the tree.
Constants§
- DEFAULT_
NODE_ SIZE - Default maximum number of children per tree node.
- DEFAULT_
PARALLEL_ MIN_ ITEMS parallel - Minimum index size at which
parallel(true)enables rayon.