Skip to content

Commit 47afbad

Browse files
committed
Add SpatialIndex::build
1 parent 945420e commit 47afbad

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/spatial_index.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ use std::ptr::NonNull;
55
use geos_sys::*;
66

77
use crate::context_handle::with_context;
8+
#[cfg(any(feature = "v3_12_0", feature = "dox"))]
9+
use crate::functions::errcheck;
810
use crate::functions::nullcheck;
911
use crate::{AsRaw, AsRawMut, GResult, Geom};
1012

1113
pub trait SpatialIndex<I> {
1214
fn insert<G: Geom>(&mut self, geometry: &G, item: I);
1315

1416
fn query<G: Geom, V: FnMut(&I)>(&self, geometry: &G, visitor: V);
17+
18+
#[cfg(any(feature = "v3_12_0", feature = "dox"))]
19+
fn build(&self) -> GResult<()>;
1520
}
1621

1722
pub struct STRtree<I> {
@@ -53,7 +58,7 @@ impl<I> SpatialIndex<I> for STRtree<I> {
5358
});
5459
}
5560

56-
fn query<'b, G: Geom, V: FnMut(&I)>(&self, geometry: &G, visitor: V) {
61+
fn query<G: Geom, V: FnMut(&I)>(&self, geometry: &G, visitor: V) {
5762
with_context(|ctx| unsafe {
5863
let (closure, callback) = unpack_closure(&visitor);
5964
GEOSSTRtree_query_r(
@@ -65,6 +70,17 @@ impl<I> SpatialIndex<I> for STRtree<I> {
6570
);
6671
})
6772
}
73+
74+
#[cfg(any(feature = "v3_12_0", feature = "dox"))]
75+
fn build(&self) -> GResult<()> {
76+
with_context(|ctx| unsafe {
77+
errcheck!(GEOSSTRtree_build_r(
78+
ctx.as_raw(),
79+
self.as_raw_mut_override(),
80+
))?;
81+
Ok(())
82+
})
83+
}
6884
}
6985

7086
impl<I> AsRaw for STRtree<I> {

0 commit comments

Comments
 (0)