1use chrono::{DateTime, Duration, Utc};
2use ecoord::FrameId;
3
4#[derive(Debug, Clone, PartialEq)]
5pub struct VoxelGridInfo {
6 pub(crate) frame_id: FrameId,
7 pub(crate) resolution: f64,
8 pub(crate) start_time: Option<DateTime<Utc>>,
9 pub(crate) stop_time: Option<DateTime<Utc>>,
10 pub(crate) submap_index: Option<i32>,
11}
12
13impl VoxelGridInfo {
14 pub fn new(
15 frame_id: FrameId,
16 resolution: f64,
17 start_time: Option<DateTime<Utc>>,
18 stop_time: Option<DateTime<Utc>>,
19 submap_index: Option<i32>,
20 ) -> Self {
21 Self {
22 resolution,
23 frame_id,
24 start_time,
25 stop_time,
26 submap_index,
27 }
28 }
29
30 pub fn frame_id(&self) -> &FrameId {
31 &self.frame_id
32 }
33
34 pub fn resolution(&self) -> f64 {
35 self.resolution
36 }
37
38 pub fn start_time(&self) -> &Option<DateTime<Utc>> {
39 &self.start_time
40 }
41
42 pub fn stop_time(&self) -> &Option<DateTime<Utc>> {
43 &self.stop_time
44 }
45
46 pub fn submap_index(&self) -> Option<i32> {
47 self.submap_index
48 }
49
50 pub fn duration(&self) -> Option<Duration> {
51 if self.start_time.is_some() && self.stop_time.is_some() {
52 Some(self.stop_time.unwrap() - self.start_time.unwrap())
53 } else {
54 None
55 }
56 }
57}