sparser data transfers

This commit is contained in:
vcoppe committed 2026-10-18 16:20:32 +02:00
1 parent 4583874e7e
commit a07da16163
15 files changed
+22 -24

No files matched your search

+3
View File
@@ -527,6 +527,9 @@ impl TrackpointDetails {
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SelectionPoint {
/// Slope (%) at the trackpoint.
#[serde(skip_serializing_if = "Option::is_none")]
pub slope: Option<f64>,
/// ms since the epoch.
#[serde(skip_serializing_if = "Option::is_none")]
pub time: Option<f64>,
+1 -1
View File
@@ -153,7 +153,6 @@ buffers!(
total_distance,
elevation_gain,
elevation_loss,
slope,
lng,
lat,
ele
@@ -202,6 +201,7 @@ pub fn selection_point<H: History>(engine: &Engine<H>, index: usize) -> Option<S
let segment = stats.slope_segments.at(index);
let finite = |value: f64| value.is_finite().then_some(value);
Some(SelectionPoint {
slope: finite(stats.slope[index]),
time: stats
.time
.as_ref()
+1 -1
View File
@@ -17,7 +17,7 @@ macro_rules! f64_getters {
)*};
}
f64_getters!(total_distance, slope, slope_segment_slopes, lng, lat, ele);
f64_getters!(total_distance, slope_segment_slopes, lng, lat, ele);
macro_rules! optional_f64_getters {
($($name:ident),*) => {$(
-1
View File
@@ -145,7 +145,6 @@ fn register_commands<R: tauri::Runtime>(builder: tauri::Builder<R>) -> tauri::Bu
queries::waypoint_coordinates,
// statistics
statistics::total_distance,
statistics::slope,
statistics::slope_segment_starts,
statistics::slope_segment_slopes,
statistics::lng,
-1
View File
@@ -25,7 +25,6 @@ macro_rules! stats_getter {
stats_getter!(total_distance, Float64Array);
stats_getter!(elevation_gain, Float64Array);
stats_getter!(elevation_loss, Float64Array);
stats_getter!(slope, Float64Array);
stats_getter!(lng, Float64Array);
stats_getter!(lat, Float64Array);
stats_getter!(ele, Float64Array);
+2
View File
@@ -69,6 +69,8 @@ export interface TrackpointDetails {
* Absent fields are unknown.
*/
export interface SelectionPoint {
/** Slope (%) at the trackpoint. */
slope?: number;
/** ms since epoch */
time?: number;
/** Slope (%) and length (km) of the smoothed elevation segment of the trackpoint. */
@@ -226,23 +226,25 @@ export class ElevationProfile {
const details =
hovered?.index === point.index ? hovered.point : undefined;
const elevationFill = get(this._elevationFill);
let slope = `${this._data.slope[point.index]?.toFixed(1)} %`;
if (
elevationFill === 'slope' &&
details?.slopeSegmentSlope !== undefined &&
details.slopeSegmentDistance !== undefined
) {
slope += ` (${getDistanceWithUnits(details.slopeSegmentDistance)} @${details.slopeSegmentSlope.toFixed(1)} %)`;
}
let labels = [
` ${i18n._('quantities.distance')}: ${getDistanceWithUnits(point.x, false)}`,
` ${i18n._('quantities.slope')}: ${slope}`,
];
if (!details) {
return labels;
}
if (details.slope !== undefined) {
let slope = `${details.slope.toFixed(1)} %`;
if (
elevationFill === 'slope' &&
details.slopeSegmentSlope !== undefined &&
details.slopeSegmentDistance !== undefined
) {
slope += ` (${getDistanceWithUnits(details.slopeSegmentDistance)} @${details.slopeSegmentSlope.toFixed(1)} %)`;
}
labels.push(` ${i18n._('quantities.slope')}: ${slope}`);
}
let surface = details.surface ?? 'unknown';
let highway = details.highway ?? 'unknown';
let sacScale = details.sacScale;
+1 -1
View File
@@ -56,6 +56,7 @@ async function point(index: number): Promise<SelectionPoint | undefined> {
}
const segment = intervalAt(slopeSegmentStarts, index);
return {
slope: data.slope[index],
time: data.timestamps[index],
slopeSegmentSlope: data.slopeSegmentSlopes[segment],
slopeSegmentDistance: data.slopeSegmentDistances[segment],
@@ -66,7 +67,6 @@ export const exampleStatistics: SelectionStatistics = {
global: data.global,
length,
totalDistance: Float64Array.from(data.totalDistance),
slope: Float64Array.from(data.slope),
lng: Float64Array.from(data.lng),
lat: Float64Array.from(data.lat),
ele: Float64Array.from(data.ele),
-1
View File
@@ -178,7 +178,6 @@ export async function createTauriBackend(): Promise<Backend> {
slice_statistics: async (start, end) =>
(await invoke('slice_statistics', { start, end })) ?? undefined,
total_distance: () => f64('total_distance'),
slope: () => f64('slope'),
lng: () => f64('lng'),
lat: () => f64('lat'),
ele: () => f64('ele'),
-1
View File
@@ -274,7 +274,6 @@ export interface Backend {
selection_statistics(): Promise<GlobalStatistics | undefined>;
slice_statistics(start: number, end: number): Promise<GlobalStatistics | undefined>;
total_distance(): Promise<Float64Array>;
slope(): Promise<Float64Array>;
lng(): Promise<Float64Array>;
lat(): Promise<Float64Array>;
ele(): Promise<Float64Array>;
-1
View File
@@ -131,7 +131,6 @@ export async function createWasmBackend(): Promise<Backend> {
selection_statistics: lift(w.selection_statistics),
slice_statistics: lift(w.slice_statistics),
total_distance: lift(w.total_distance),
slope: lift(w.slope),
lng: lift(w.lng),
lat: lift(w.lat),
ele: lift(w.ele),
+1
View File
@@ -256,6 +256,7 @@ describe('statistics', () => {
const statistics = get(engine.statistics);
const point = (await statistics.point(3))!;
assert.ok(point.slopeSegmentDistance! > 0);
assert.equal(typeof point.slope, 'number');
assert.equal(await statistics.point(statistics.length), undefined);
// only for the selection it was read for
+1 -3
View File
@@ -46,10 +46,9 @@ export class StatisticsReader {
private async read(backend: Backend): Promise<SelectionStatistics> {
const version = ++this._version;
this._loaded.clear();
const [global, totalDistance, slope, lng, lat, ele] = await Promise.all([
const [global, totalDistance, lng, lat, ele] = await Promise.all([
backend.selection_statistics(),
backend.total_distance(),
backend.slope(),
backend.lng(),
backend.lat(),
backend.ele(),
@@ -60,7 +59,6 @@ export class StatisticsReader {
global: global ?? EMPTY_STATISTICS,
length: totalDistance.length,
totalDistance,
slope,
lng,
lat,
ele,
-3
View File
@@ -209,8 +209,6 @@ export type SelectionStatistics = {
/** Number of trackpoints. */
length: number;
totalDistance: Float64Array;
/** Slope at the trackpoint. */
slope: Float64Array;
lng: Float64Array;
lat: Float64Array;
ele: Float64Array;
@@ -248,7 +246,6 @@ export const EMPTY_SELECTION_STATISTICS: SelectionStatistics = {
global: EMPTY_STATISTICS,
length: 0,
totalDistance: new Float64Array(),
slope: new Float64Array(),
lng: new Float64Array(),
lat: new Float64Array(),
ele: new Float64Array(),
@@ -61,7 +61,7 @@ export async function computeExampleData() {
movingTime: numbers(engine.moving_time()),
elevationGain: numbers(engine.elevation_gain()),
elevationLoss: numbers(engine.elevation_loss()),
slope: numbers(engine.slope()),
slope: points.map((point) => point.slope!),
slopeSegmentStarts,
slopeSegmentSlopes: numbers(engine.slope_segment_slopes()),
// the length of each segment, which is the one of its trackpoints