Export only computed track, not editing waypoints

Editing waypoints represent where the user clicked, not the actual
route. Exporting them causes reimported routes to look different
because BRouter re-routes without no-go areas.

Now both GPX export and Save to Journal only include the computed
track. On reimport, Douglas-Peucker extracts waypoints from the
track shape, preserving the route including no-go detours.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-03 10:46:12 +01:00
parent 596d96d8cb
commit ef85e03bb2
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
2 changed files with 7 additions and 17 deletions

View file

@ -9,14 +9,9 @@ export function ExportButton({ yjs }: { yjs: YjsState }) {
const { t } = useTranslation("planner");
const handleExport = useCallback(() => {
// Get waypoints from Yjs
const waypoints = yjs.waypoints.toArray().map((yMap: Y.Map<unknown>) => ({
lat: yMap.get("lat") as number,
lon: yMap.get("lon") as number,
name: yMap.get("name") as string | undefined,
}));
// Get route track from GeoJSON
// Export only the computed track, not editing waypoints.
// The track already reflects no-go area avoidance and BRouter's routing.
// On reimport, waypoints are extracted from the track shape.
let tracks: TrackPoint[][] = [];
const geojsonStr = yjs.routeData.get("geojson") as string | undefined;
if (geojsonStr) {
@ -37,7 +32,7 @@ export function ExportButton({ yjs }: { yjs: YjsState }) {
}
}
const gpx = generateGpx({ name: "trails.cool route", waypoints, tracks });
const gpx = generateGpx({ name: "trails.cool route", waypoints: [], tracks });
// Download
const blob = new Blob([gpx], { type: "application/gpx+xml" });

View file

@ -23,13 +23,8 @@ export function SaveToJournalButton({ yjs, callbackUrl, callbackToken, returnUrl
setError(null);
try {
// Build GPX from current Yjs state
const waypoints = yjs.waypoints.toArray().map((yMap: Y.Map<unknown>) => ({
lat: yMap.get("lat") as number,
lon: yMap.get("lon") as number,
name: yMap.get("name") as string | undefined,
}));
// Build GPX from computed track (not editing waypoints).
// The track reflects the actual routed path including no-go avoidance.
let tracks: TrackPoint[][] = [];
const geojsonStr = yjs.routeData.get("geojson") as string | undefined;
if (geojsonStr) {
@ -42,7 +37,7 @@ export function SaveToJournalButton({ yjs, callbackUrl, callbackToken, returnUrl
} catch { /* invalid geojson */ }
}
const gpx = generateGpx({ name: "trails.cool route", waypoints, tracks });
const gpx = generateGpx({ name: "trails.cool route", waypoints: [], tracks });
// POST to Journal callback
const response = await fetch(callbackUrl, {