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

@@ -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();