Skip to main content

Crate packed_spatial_index

Crate packed_spatial_index 

Source
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): SimdIndex2D and SimdIndex3D with SIMD searches through wide and 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.
Index2DBuilder
Builder for Index2D and, with the simd feature, SimdIndex2D.
Index2DView
Zero-copy read-only view over bytes produced by Index2D::to_bytes.
Index3D
Finished static read-only 3D index.
Index3DBuilder
Builder for Index3D and, with the simd feature, SimdIndex3D.
Index3DView
Zero-copy read-only view over bytes produced by Index3D::to_bytes.
NeighborWorkspace
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.
SearchWorkspace
Reusable buffers for allocation-free repeated searches.
SimdIndex2Dsimd
Finished read-only SIMD index.
SimdIndex2DViewsimd
Zero-copy SIMD view over bytes produced by SimdIndex2D::to_bytes or Index2D::to_bytes.
SimdIndex3Dsimd
Finished read-only SIMD 3D index.
SimdIndex3DViewsimd
Zero-copy SIMD view over bytes produced by SimdIndex3D::to_bytes or Index3D::to_bytes.

Enums§

BoundsError
Error returned by Box2D::try_new and Box3D::try_new for invalid coordinate bounds.
BuildError
Build error for finishing an index.
LoadError
Error returned when loading an index from bytes.
SortKey2D
Which key to use when sorting boxes before packing the tree.
SortKey3D
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_ITEMSparallel
Minimum index size at which parallel(true) enables rayon.