Compare commits
1 commit
main
...
fix/export
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef85e03bb2 |
2 changed files with 7 additions and 17 deletions
|
|
@ -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" });
|
||||
|
|
|
|||
|
|
@ -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, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue