mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-09-24 08:27:37 +00:00
parsing continued
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user