Include no-go areas when saving to journal

Save to Journal now includes no-go areas in GPX extensions so they
round-trip correctly: Planner → Journal → Edit in Planner preserves
the no-go polygons.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-03 12:32:05 +01:00
parent 6ccf7af7b1
commit 45d1360be5
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9

View file

@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next";
import * as Y from "yjs";
import type { YjsState } from "~/lib/use-yjs";
import { generateGpx } from "@trails-cool/gpx";
import type { TrackPoint } from "@trails-cool/gpx";
import type { TrackPoint, NoGoArea } from "@trails-cool/gpx";
interface SaveToJournalButtonProps {
yjs: YjsState;
@ -23,7 +23,8 @@ export function SaveToJournalButton({ yjs, callbackUrl, callbackToken, returnUrl
setError(null);
try {
// Build GPX from computed track (not editing waypoints).
// Build GPX from computed track with planning data (no-go areas)
// so the route round-trips correctly through the journal.
let tracks: TrackPoint[][] = [];
const geojsonStr = yjs.routeData.get("geojson") as string | undefined;
if (geojsonStr) {
@ -36,7 +37,11 @@ export function SaveToJournalButton({ yjs, callbackUrl, callbackToken, returnUrl
} catch { /* invalid geojson */ }
}
const gpx = generateGpx({ name: "trails.cool route", waypoints: [], tracks });
const noGoAreas: NoGoArea[] = yjs.noGoAreas.toArray().map((yMap: Y.Map<unknown>) => ({
points: (yMap.get("points") as Array<{ lat: number; lon: number }>) ?? [],
})).filter((a) => a.points.length >= 3);
const gpx = generateGpx({ name: "trails.cool route", waypoints: [], tracks, noGoAreas });
// POST to Journal callback
const response = await fetch(callbackUrl, {