1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! # Nitrite Spatial - Spatial Indexing for Nitrite Database
//!
//! This crate provides spatial indexing capabilities for the Nitrite database,
//! including a memory-efficient disk-based R-Tree implementation and spatial
//! query filters.
//!
//! ## Features
//!
//! - **Disk-Based Storage**: Pages stored on disk, loaded on demand
//! - **LRU Cache**: Frequently accessed pages kept in memory
//! - **Memory Efficient**: Only hot data in RAM, cold data on disk
//! - **Persistent**: Data survives process restarts
//! - **Thread Safe**: Concurrent read/write support
//! - **Two-Phase Search**: Fast R-tree bbox search followed by precise geometry refinement
//! - **Spatial Filters**: Intersects, Within, Near, and GeoNear filters
//! - **Fluent API**: Builder pattern for spatial queries
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use nitrite_spatial::{SpatialModule, spatial_field, Point, Geometry};
//! use nitrite::nitrite_builder::NitriteBuilder;
//! use nitrite::common::PersistentCollection;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Register spatial module
//! let db = Nitrite::builder()
//! .load_module(SpatialModule)
//! .open_or_create(None, None)?;
//!
//! // Create spatial index on a field
//! let collection = db.collection("places")?;
//! collection.create_index(vec!["location"], &nitrite_spatial::spatial_index())?;
//!
//! // Query with spatial filters
//! let filter = spatial_field("location")
//! .intersects(Geometry::point(0.0, 0.0));
//!
//! let results = collection.find(filter, None)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## R-Tree API
//!
//! ```rust,no_run
//! use nitrite_spatial::{DiskRTree, BoundingBox, NitriteRTree};
//! use tempfile::NamedTempFile;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a new R-Tree
//! let temp_file = NamedTempFile::new()?;
//! let tree = DiskRTree::create(temp_file.path())?;
//!
//! // Add entries
//! tree.add(&BoundingBox::new(0.0, 0.0, 10.0, 10.0), 1)?;
//!
//! // Find intersecting entries
//! let query = BoundingBox::new(5.0, 5.0, 15.0, 15.0);
//! let results = tree.find_intersecting_keys(&query)?;
//! # Ok(())
//! # }
//! ```
// Core R-Tree modules
// Spatial indexing modules
// Re-export R-Tree types
pub use BoundingBox;
pub use ;
pub use NitriteRTree;
// Re-export geometry types
pub use ;
pub use ;
// Re-export filter types
pub use ;
// Re-export fluent API
pub use SpatialFluentFilter;
// Re-export indexer types
pub use SpatialIndexer;
// Re-export filter constant
pub use SPATIAL_INDEX;
pub use SpatialModule;
// Re-export fluent API entry point
pub use spatial_field;
/// Creates index options for a spatial index.
///
/// This is a convenience function to create `IndexOptions` for spatial indexes.
///
/// # Example
///
/// ```rust,no_run
/// # use nitrite_spatial::spatial_index;
/// let options = spatial_index();
/// // Use with collection.create_index(vec!["location"], &options)?;
/// ```