Skip to main content

spatial_narrative/index/
mod.rs

1//! Spatial and temporal indexing for efficient queries.
2//!
3//! This module provides data structures for fast spatial and temporal
4//! lookups of events and other entities.
5//!
6//! # Overview
7//!
8//! - [`SpatialIndex`] - R-tree based spatial indexing for geographic queries
9//! - [`TemporalIndex`] - B-tree based temporal indexing for time-range queries
10//! - [`SpatiotemporalIndex`] - Combined space-time indexing
11//!
12//! # Example
13//!
14//! ```rust
15//! use spatial_narrative::index::{SpatialIndex, TemporalIndex, SpatiotemporalIndex};
16//! use spatial_narrative::core::{Location, Timestamp, GeoBounds, TimeRange};
17//!
18//! // Create a spatiotemporal index
19//! let mut index = SpatiotemporalIndex::new();
20//!
21//! index.insert("Event 1",
22//!     &Location::new(40.7128, -74.0060),
23//!     &Timestamp::now());
24//!
25//! // Query by location
26//! let bounds = GeoBounds::new(39.0, -75.0, 42.0, -73.0);
27//! let spatial_results = index.query_spatial(&bounds);
28//!
29//! // Query by time
30//! let range = TimeRange::year(2024);
31//! let temporal_results = index.query_temporal(&range);
32//!
33//! // Query by both
34//! let combined_results = index.query(&bounds, &range);
35//! ```
36
37mod spatial;
38mod spatiotemporal;
39mod temporal;
40
41pub use spatial::{IndexedLocation, SpatialIndex};
42pub use spatiotemporal::{GridSpec, Heatmap, SpatiotemporalIndex};
43pub use temporal::{SlidingWindowIter, TemporalIndex};