parsing continued

This commit is contained in:
vcoppe
2026-09-18 09:50:04 +02:00
parent 69049e1345
commit 20222c450d
4 changed files with 175 additions and 57 deletions
+8 -26
View File
@@ -1,34 +1,10 @@
use std::{cell::RefCell, rc::Rc};
use std::rc::Rc;
use crate::gpx::TrackPoint;
#[derive(Debug, Default)]
pub struct TrackSegment {
pub chunks: Vec<Rc<RefCell<TrackPointChunk>>>,
}
impl TrackSegment {
pub fn append(&mut self, trkpt: TrackPoint) {
if self
.chunks
.last()
.is_none_or(|c| c.borrow().trkpt.len() == MAX_CHUNK_SIZE)
{
self.add_chunk();
}
self.chunks
.last_mut()
.unwrap()
.borrow_mut()
.trkpt
.push(trkpt);
}
fn add_chunk(&mut self) {
self.chunks
.push(Rc::new(RefCell::new(TrackPointChunk::default())));
}
pub chunks: Vec<Rc<TrackPointChunk>>,
}
static MAX_CHUNK_SIZE: usize = 4096;
@@ -37,3 +13,9 @@ static MAX_CHUNK_SIZE: usize = 4096;
pub struct TrackPointChunk {
pub trkpt: Vec<TrackPoint>,
}
impl TrackPointChunk {
pub fn is_full(&self) -> bool {
self.trkpt.len() == MAX_CHUNK_SIZE
}
}