@@ -5,13 +5,18 @@ use std::ptr::NonNull;
55use geos_sys:: * ;
66
77use crate :: context_handle:: with_context;
8+ #[ cfg( any( feature = "v3_12_0" , feature = "dox" ) ) ]
9+ use crate :: functions:: errcheck;
810use crate :: functions:: nullcheck;
911use crate :: { AsRaw , AsRawMut , GResult , Geom } ;
1012
1113pub 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
1722pub 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
7086impl < I > AsRaw for STRtree < I > {
0 commit comments