This commit is contained in:
vcoppe
2026-10-04 19:19:53 +02:00
parent 5e2f506120
commit c04367dd86
10 changed files with 129 additions and 16 deletions
@@ -44,6 +44,8 @@ interface ElevationProfilePoint {
};
surface?: string;
highway?: string;
sacScale?: string;
mtbScale?: string;
coordinates: Coordinates;
index: number;
}
@@ -189,9 +191,8 @@ export class ElevationProfile {
};
let surface = point.surface ?? 'unknown';
let highway = point.highway ?? 'unknown';
// TODO the engine does not store the sac and mtb scales yet
let sacScale: string | undefined = undefined;
let mtbScale: string | undefined = undefined;
let sacScale = point.sacScale;
let mtbScale = point.mtbScale;
let labels = [
` ${i18n._('quantities.distance')}: ${getDistanceWithUnits(point.x, false)}`,
@@ -414,6 +415,8 @@ export class ElevationProfile {
},
surface: categoryAt(data.surface, data.surfaces, index),
highway: categoryAt(data.highway, data.highways, index),
sacScale: categoryAt(data.sacScale, data.sacScales, index),
mtbScale: categoryAt(data.mtbScale, data.mtbScales, index),
coordinates: { lat: data.lat[index], lon: data.lng[index] },
index,
});
@@ -606,8 +609,7 @@ export class ElevationProfile {
highwayFillCallback(context: ScriptableLineSegmentContext & { p0: { raw: any } }) {
const point = context.p0.raw as ElevationProfilePoint;
// TODO the engine does not store the sac and mtb scales yet
return getHighwayColor(point.highway ?? '', undefined, undefined);
return getHighwayColor(point.highway ?? '', point.sacScale, point.mtbScale);
}
destroy() {
+16
View File
@@ -148,6 +148,14 @@ export type SelectionStatistics = {
highway: Uint8Array;
/** Names of the highways, by code. */
highways: string[];
/** SAC hiking scale of the trackpoints: 0 when unknown, else 1 + the index in `sacScales`. */
sacScale: Uint8Array;
/** Names of the SAC scales, by code. */
sacScales: string[];
/** Mountain biking scale of the trackpoints: 0 when unknown, else 1 + the index in `mtbScales`. */
mtbScale: Uint8Array;
/** Names of the mountain biking scales, by code. */
mtbScales: string[];
/**
* Global statistics of the trackpoints from `start` to `end` (both included), for example
* the part of the elevation profile that was dragged over. `undefined` if the range is not
@@ -181,6 +189,10 @@ const EMPTY_SELECTION_STATISTICS: SelectionStatistics = {
surfaces: [],
highway: new Uint8Array(),
highways: [],
sacScale: new Uint8Array(),
sacScales: [],
mtbScale: new Uint8Array(),
mtbScales: [],
slice: () => undefined,
};
@@ -635,6 +647,10 @@ class Engine {
surfaces: wasm.surfaces(),
highway: wasm.highway().slice(),
highways: wasm.highways(),
sacScale: wasm.sac_scale().slice(),
sacScales: wasm.sac_scales(),
mtbScale: wasm.mtb_scale().slice(),
mtbScales: wasm.mtb_scales(),
slice: (start, end) =>
version === this._statisticsVersion ? wasm.slice_statistics(start, end) : undefined,
};
@@ -49,6 +49,10 @@
surfaces: [],
highway: new Uint8Array(),
highways: [],
sacScale: new Uint8Array(),
sacScales: [],
mtbScale: new Uint8Array(),
mtbScales: [],
slice: () => undefined,
});
let slicedStatistics = writable(undefined);