Skip to content

Commit 220021b

Browse files
committed
Load the rtree on the Lrs instance
It only stores the data, not an instance of RTree. This is not a problem as it is designed a zerocopy and we can spawn an instance of RTreeRef on the go. Otherwise, we need to manage lifetimes, and we don’t want to Signed-off-by: Tristram Gräbener <tristram+git@tristramg.eu>
1 parent 5aef6e8 commit 220021b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/lrs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ pub struct Lrs<CurveImpl: Curve> {
6565
pub nodes: Vec<Node>,
6666
/// All the [`Segment`] of this Lrs
6767
pub segments: Vec<Segment>,
68+
/// An RTree spatial index of the LRM extents
69+
rtree_data: Option<Vec<u8>>,
6870
}
6971

7072
/// A Node is a topological element of the [`Lrs`] that represents a intersection (or an extremity) of an [`Lrm`]
@@ -223,12 +225,16 @@ impl<CurveImpl: Curve> Lrs<CurveImpl> {
223225
pub fn from_bytes(buf: &[u8]) -> Result<Self, LrsError> {
224226
let lrs = lrs_generated::root_as_lrs(buf).map_err(LrsError::InvalidArchive)?;
225227

228+
let rtree_data = lrs
229+
.lrm_spatial_index()
230+
.map(|buffer| buffer.bytes().to_vec());
226231
let mut result = Self {
227232
lrms: vec![],
228233
traversals: vec![],
229234
properties: from_fb(lrs.properties()),
230235
nodes: vec![],
231236
segments: vec![],
237+
rtree_data,
232238
};
233239

234240
let source_anchors = lrs
@@ -710,6 +716,7 @@ mod tests {
710716
properties: properties!("source" => "test"),
711717
nodes: vec![],
712718
segments: vec![],
719+
rtree_data: None,
713720
}
714721
}
715722

0 commit comments

Comments
 (0)