Files
gpx.studio/gpx-rs/src/gpx/chunk.rs
T

62 lines
1.1 KiB
Rust
Raw Normal View History

2026-10-01 18:42:31 +02:00
use uuid::Uuid;
2026-09-23 19:53:39 +02:00
use crate::gpx::{Trackpoint, Waypoint};
static MAX_TRKPT_CHUNK_SIZE: usize = 4096;
2026-10-01 18:42:31 +02:00
#[derive(Debug)]
2026-09-23 19:53:39 +02:00
pub struct TrackpointChunk {
2026-10-01 18:42:31 +02:00
pub id: Uuid,
2026-09-23 19:53:39 +02:00
pub trkpt: Vec<Trackpoint>,
}
2026-10-01 18:42:31 +02:00
impl Default for TrackpointChunk {
fn default() -> Self {
Self {
id: Uuid::new_v4(),
trkpt: Default::default(),
}
}
}
impl PartialEq for TrackpointChunk {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}
2026-09-23 19:53:39 +02:00
impl TrackpointChunk {
pub fn is_full(&self) -> bool {
self.trkpt.len() == MAX_TRKPT_CHUNK_SIZE
}
}
static MAX_WPT_CHUNK_SIZE: usize = 128;
2026-10-01 18:42:31 +02:00
#[derive(Debug)]
2026-09-23 19:53:39 +02:00
pub struct WaypointChunk {
2026-10-01 18:42:31 +02:00
pub id: Uuid,
2026-09-23 19:53:39 +02:00
pub wpt: Vec<Waypoint>,
}
2026-10-01 18:42:31 +02:00
impl Default for WaypointChunk {
fn default() -> Self {
Self {
id: Uuid::new_v4(),
wpt: Default::default(),
}
}
}
impl PartialEq for WaypointChunk {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}
2026-09-23 19:53:39 +02:00
impl WaypointChunk {
pub fn is_full(&self) -> bool {
self.wpt.len() == MAX_WPT_CHUNK_SIZE
}
}