pub struct SpatialIndex<T> { /* private fields */ }Expand description
Spatial index for efficient geographic queries.
Uses an R-tree data structure for O(log n) query performance.
Implementations§
Source§impl<T: Clone> SpatialIndex<T>
impl<T: Clone> SpatialIndex<T>
Sourcepub fn from_iter<I, F>(iter: I, location_fn: F) -> Self
pub fn from_iter<I, F>(iter: I, location_fn: F) -> Self
Create a spatial index from items with a location extractor.
Sourcepub fn query_bbox(
&self,
min_lat: f64,
min_lon: f64,
max_lat: f64,
max_lon: f64,
) -> Vec<&T>
pub fn query_bbox( &self, min_lat: f64, min_lon: f64, max_lat: f64, max_lon: f64, ) -> Vec<&T>
Query items within a bounding box.
§Arguments
min_lat- Minimum latitudemin_lon- Minimum longitudemax_lat- Maximum latitudemax_lon- Maximum longitude
Sourcepub fn query_bounds(&self, bounds: &GeoBounds) -> Vec<&T>
pub fn query_bounds(&self, bounds: &GeoBounds) -> Vec<&T>
Query items within geographic bounds.
Sourcepub fn query_radius(&self, lat: f64, lon: f64, radius_degrees: f64) -> Vec<&T>
pub fn query_radius(&self, lat: f64, lon: f64, radius_degrees: f64) -> Vec<&T>
Query items within a radius of a point.
Note: This uses Euclidean distance in degrees. For accurate
great-circle distance, use query_radius_meters.
Sourcepub fn query_radius_meters(
&self,
lat: f64,
lon: f64,
radius_meters: f64,
) -> Vec<&T>
pub fn query_radius_meters( &self, lat: f64, lon: f64, radius_meters: f64, ) -> Vec<&T>
Query items within a radius in meters.
Uses the Haversine formula for accurate great-circle distance.
Sourcepub fn nearest(&self, lat: f64, lon: f64, k: usize) -> Vec<&T>
pub fn nearest(&self, lat: f64, lon: f64, k: usize) -> Vec<&T>
Find the k nearest neighbors to a point.
Trait Implementations§
Source§impl<T: Debug> Debug for SpatialIndex<T>
impl<T: Debug> Debug for SpatialIndex<T>
Auto Trait Implementations§
impl<T> Freeze for SpatialIndex<T>
impl<T> RefUnwindSafe for SpatialIndex<T>where
T: RefUnwindSafe,
impl<T> Send for SpatialIndex<T>where
T: Send,
impl<T> Sync for SpatialIndex<T>where
T: Sync,
impl<T> Unpin for SpatialIndex<T>where
T: Unpin,
impl<T> UnwindSafe for SpatialIndex<T>where
T: UnwindSafe,
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