pub struct SpatialIndex { /* private fields */ }Expand description
Spatial index for efficient viewport and proximity queries
Implementations§
Source§impl SpatialIndex
impl SpatialIndex
Sourcepub fn with_cell_size(cell_size: f64) -> Self
pub fn with_cell_size(cell_size: f64) -> Self
Create a new spatial index with specified cell size
Sourcepub fn insert<T>(&mut self, node: &Node<T>) -> Result<()>where
T: Clone,
pub fn insert<T>(&mut self, node: &Node<T>) -> Result<()>where
T: Clone,
Insert a node into the spatial index
Sourcepub fn update<T>(&mut self, node: &Node<T>) -> Result<()>where
T: Clone,
pub fn update<T>(&mut self, node: &Node<T>) -> Result<()>where
T: Clone,
Update a node’s position in the spatial index
Sourcepub fn query_rect(&self, bounds: &Rect) -> Vec<NodeId>
pub fn query_rect(&self, bounds: &Rect) -> Vec<NodeId>
Query nodes within a rectangular area
Sourcepub fn query_viewport(&self, viewport: &Viewport) -> Vec<NodeId>
pub fn query_viewport(&self, viewport: &Viewport) -> Vec<NodeId>
Query nodes within a viewport
Sourcepub fn query_radius(&self, center: Position, radius: f64) -> Vec<NodeId>
pub fn query_radius(&self, center: Position, radius: f64) -> Vec<NodeId>
Query nodes within a circular area
Sourcepub fn nearest(&self, point: Position) -> Option<NodeId>
pub fn nearest(&self, point: Position) -> Option<NodeId>
Find the nearest node to a given point
Sourcepub fn bulk_load<T>(&mut self, nodes: &[Node<T>]) -> Result<()>where
T: Clone,
pub fn bulk_load<T>(&mut self, nodes: &[Node<T>]) -> Result<()>where
T: Clone,
Bulk load multiple nodes into the index
Sourcepub fn get_grid_cells_for_bounds(&self, bounds: &Rect) -> Vec<GridCell>
pub fn get_grid_cells_for_bounds(&self, bounds: &Rect) -> Vec<GridCell>
Get grid cells that a bounds rectangle intersects
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpatialIndex
impl RefUnwindSafe for SpatialIndex
impl Send for SpatialIndex
impl Sync for SpatialIndex
impl Unpin for SpatialIndex
impl UnwindSafe for SpatialIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more