This commit is contained in:
vcoppe committed 2026-11-08 15:32:12 +01:00
1 parent 002fd259aa
commit 7474f892ce
20 files changed
+28 -221

No files matched your search

-20
View File
@@ -560,26 +560,6 @@ impl WaypointDetails {
}
}
#[derive(Serialize)]
pub struct TrackpointDetails {
lng: f64,
lat: f64,
ele: f64,
#[serde(skip_serializing_if = "Option::is_none")]
time: Option<f64>,
}
impl TrackpointDetails {
pub fn new(pt: &engine::Trackpoint) -> Self {
Self {
lng: pt.coordinates.lng,
lat: pt.coordinates.lat,
ele: pt.ele,
time: pt.time.map(|t| t as f64),
}
}
}
/// A trackpoint of the selection: what the statistics buffers do not hold for each trackpoint.
/// Absent fields are unknown.
#[derive(Serialize)]
-12
View File
@@ -63,18 +63,6 @@ pub fn waypoint<H: History>(
.map(WaypointDetails::new)
}
/// A trackpoint of a segment of a file, `None` if it does not exist.
pub fn trackpoint<H: History>(
engine: &Engine<H>,
file_id: Uuid,
segment_id: Uuid,
index: usize,
) -> Option<TrackpointDetails> {
engine
.trackpoint(&FileId(file_id), &engine::TrackSegmentId(segment_id), index)
.map(TrackpointDetails::new)
}
/// A file as GPX (UTF-8 bytes), `None` if it does not exist. The options say which data of the
/// trackpoints to keep.
pub fn export_file<H: History>(
-8
View File
@@ -24,14 +24,6 @@ pub struct Statistics {
}
impl Statistics {
pub fn total_speed(&self) -> Option<f64> {
self.global.total_speed()
}
pub fn moving_speed(&self) -> Option<f64> {
self.global.moving_speed()
}
pub fn compute(trkseg: &TrackSegment) -> Self {
let mut stats = Self::default();
if trkseg.is_empty() {
@@ -36,6 +36,7 @@ impl StatisticsCache {
}
/// Statistics of the segments of the selection.
#[cfg(test)]
pub fn get<'a>(
&'a self,
state: Option<&'a Files>,
+1 -17
View File
@@ -11,7 +11,7 @@ pub use outcome::*;
pub use state::*;
use crate::{
ExportOptions, FileId, GlobalStatistics, Restored, Snapshot, TrackSegmentId, Trackpoint,
ExportOptions, FileId, GlobalStatistics, Restored, Snapshot, TrackSegmentId,
TrackpointCategories, Waypoint, WaypointId, reduction_distances, write,
};
@@ -82,22 +82,6 @@ impl<H: History> Engine<H> {
.find(|wpt| wpt.id == *id)
}
/// A trackpoint of a segment (of a route or a track) of a file. `None` if it does not exist.
pub fn trackpoint(
&self,
file_id: &FileId,
segment_id: &TrackSegmentId,
index: usize,
) -> Option<&Trackpoint> {
let segment = self
.history
.current()?
.get(file_id)?
.segments()
.find(|seg| seg.id == *segment_id)?;
(index < segment.len()).then(|| &segment[index])
}
/// For each trackpoint of the selection (numbered as in the statistics), the tolerance up to
/// which `Reduce` keeps it, see [`reduction_distances`].
pub fn reduction_distances(&self) -> Vec<f64> {
-18
View File
@@ -1169,24 +1169,6 @@ fn test_categories_are_shared_and_kept_by_the_history() {
assert_eq!(expand(&engine.statistics().surface, 5), [1, 1, 0, 2, 2]);
}
#[test]
fn test_trackpoint() {
let mut engine = TestEngine::default();
load(&mut engine, "data/simple.gpx");
let file = engine.order()[0];
let structure = engine.file_structure(&file).unwrap();
let seg = &structure.tracks[0].segments[0];
let (seg_id, len) = (seg.id, seg.len);
let coordinates = engine.segment_coordinates(&seg_id).to_vec();
let last = engine.trackpoint(&file, &seg_id, len - 1).unwrap();
assert_eq!(
[last.coordinates.lng, last.coordinates.lat],
coordinates[(len - 1) * 2..]
);
assert!(engine.trackpoint(&file, &seg_id, len).is_none());
assert!(engine.trackpoint(&Default::default(), &seg_id, 0).is_none());
}
#[test]
fn test_export_writes_the_file_as_it_is() {
let mut engine = TestEngine::default();
+5 -3
View File
@@ -1,9 +1,9 @@
use std::cell::RefCell;
use std::collections::HashMap;
use crate::{
Batch, ChunkKey, ChunkKind, CommitError, FileId, Revision, Storage, StorageError, StoredData,
};
#[cfg(test)]
use crate::ChunkKind;
use crate::{Batch, ChunkKey, CommitError, FileId, Revision, Storage, StorageError, StoredData};
/// A storage that lives as long as the session. It is what an engine without a host storage uses,
/// and what the tests use.
@@ -22,6 +22,7 @@ struct State {
}
/// How much there is in a storage.
#[cfg(test)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct StorageCounts {
pub files: usize,
@@ -29,6 +30,7 @@ pub struct StorageCounts {
pub waypoint_chunks: usize,
}
#[cfg(test)]
impl MemoryStorage {
/// How many files and chunks are stored.
pub fn counts(&self) -> StorageCounts {