This commit is contained in:
vcoppe committed 2026-10-14 08:51:38 +02:00
1 parent ce8398f749
commit 41b9116c6a
60 files changed
+7525 -340

No files matched your search

@@ -400,10 +400,13 @@ export class ElevationProfile {
} else if (startIndex !== endIndex) {
const start = Math.min(startIndex, endIndex);
const end = Math.max(startIndex, endIndex);
const global = get(this._statistics).slice(start, end);
if (global) {
this._slicedStatistics.set({ global, start, end });
}
get(this._statistics)
.slice(start, end)
.then((global) => {
if (global) {
this._slicedStatistics.set({ global, start, end });
}
});
}
}
}
+26 -12
View File
@@ -54,18 +54,32 @@
return [];
});
// the data that none of them has is not offered
let hide: Record<keyof ExportOptions, boolean> = $derived.by(() => {
const available = engine.exportableData(fileIds);
return {
time: !available.time,
hr: !available.hr,
cad: !available.cad,
atemp: !available.atemp,
power: !available.power,
osm: !available.osm,
// always possible
asRoute: false,
};
let hide: Record<keyof ExportOptions, boolean> = $state({
time: false,
hr: false,
cad: false,
atemp: false,
power: false,
osm: false,
asRoute: false,
});
$effect(() => {
const ids = fileIds;
engine.exportableData(ids).then((available) => {
// the files may have changed since
if (ids === fileIds) {
hide = {
time: !available.time,
hr: !available.hr,
cad: !available.cad,
atemp: !available.atemp,
power: !available.power,
osm: !available.osm,
// always possible
asRoute: false,
};
}
});
});
$effect(() => {
@@ -31,11 +31,15 @@ export function allFileIds(): string[] {
}
async function exportFiles(fileIds: string[], options: ExportOptions) {
const files = fileIds.flatMap((fileId) => {
const gpx = engine.exportFile(fileId, options);
const name = get(engine.files).get(fileId);
return gpx === undefined || !name ? [] : [{ name: get(name).structure.name, gpx }];
});
const files = (
await Promise.all(
fileIds.map(async (fileId) => {
const gpx = await engine.exportFile(fileId, options);
const name = get(engine.files).get(fileId);
return gpx === undefined || !name ? [] : [{ name: get(name).structure.name, gpx }];
})
)
).flat();
if (files.length === 1) {
const blob = new Blob([files[0].gpx], { type: 'application/gpx+xml' });
@@ -152,9 +152,9 @@
engine.selectNode(node, 'toggle');
}
}}
onmouseenter={() => {
onmouseenter={async () => {
if (node.type === 'waypoint' && !isHidden(fileState, node.waypointId)) {
const waypoint = engine.waypoint(node.fileId, node.waypointId);
const waypoint = await engine.waypoint(node.fileId, node.waypointId);
if (waypoint) {
waypointPopup?.setItem({
item: waypoint,
@@ -393,13 +393,15 @@ export class GPXLayer {
mapCursor.notify(MapCursorState.LAYER_HOVER, false);
}
layerOnMouseMove(e: any) {
async layerOnMouseMove(e: any) {
if (e.originalEvent.shiftKey) {
const { segmentId } = e.features[0].properties;
const lngLat = { lng: e.lngLat.lng, lat: e.lngLat.lat };
const index = closestPointIndex(engine.segmentCoordinates(segmentId), lngLat);
const index = closestPointIndex(await engine.segmentCoordinates(segmentId), lngLat);
const trackpoint =
index === undefined ? undefined : engine.trackpoint(this.fileId, segmentId, index);
index === undefined
? undefined
: await engine.trackpoint(this.fileId, segmentId, index);
if (trackpoint) {
trackpointPopup?.setItem({
item: trackpoint,
@@ -469,8 +471,8 @@ export class GPXLayer {
mapCursor.notify(MapCursorState.WAYPOINT_HOVER, true);
}
showWaypointPopup(waypointId: string) {
const waypoint = engine.waypoint(this.fileId, waypointId);
async showWaypointPopup(waypointId: string) {
const waypoint = await engine.waypoint(this.fileId, waypointId);
if (waypoint) {
waypointPopup?.setItem({ item: waypoint, kind: 'waypoint', fileId: this.fileId });
}
@@ -30,9 +30,14 @@
let reducedLayer = new ReducedLayer();
// read again only when the selection or the files change, not with the tolerance
let distances = $derived.by(() => {
void $statistics;
return engine.reductionDistances();
let distances = $state<Float64Array>(new Float64Array());
$effect(() => {
const current = $statistics;
engine.reductionDistances().then((values) => {
if (current === $statistics) {
distances = values;
}
});
});
$effect(() => {
@@ -61,8 +61,12 @@
function updateSlicedStatistics([startStep, endStep]: number[]) {
if (validSelection && (startStep !== 0 || endStep !== steps)) {
const [start, end] = [toIndex(startStep), toIndex(endStep)];
const global = $statistics.slice(start, end);
slicedStatistics.set(global && { global, start, end });
$statistics.slice(start, end).then((global) => {
// the slider may have moved since
if (validSelection) {
slicedStatistics.set(global && { global, start, end });
}
});
} else {
slicedStatistics.set(undefined);
}
@@ -92,8 +92,8 @@ export class WaypointSelection {
}
// read again each time the file changes
const read = () => {
const waypoint = engine.waypoint(target.fileId, target.id);
const read = async () => {
const waypoint = await engine.waypoint(target.fileId, target.id);
this._selection.set(waypoint ? { ...target, waypoint } : undefined);
};
const file = get(engine.files).get(target.fileId);