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 { t } = useTranslation("planner");
|
||||||
|
|
||||||
const handleExport = useCallback(() => {
|
const handleExport = useCallback(() => {
|
||||||
// Get waypoints from Yjs
|
// Export only the computed track, not editing waypoints.
|
||||||
const waypoints = yjs.waypoints.toArray().map((yMap: Y.Map<unknown>) => ({
|
// The track already reflects no-go area avoidance and BRouter's routing.
|
||||||
lat: yMap.get("lat") as number,
|
// On reimport, waypoints are extracted from the track shape.
|
||||||
lon: yMap.get("lon") as number,
|
|
||||||
name: yMap.get("name") as string | undefined,
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Get route track from GeoJSON
|
|
||||||
let tracks: TrackPoint[][] = [];
|
let tracks: TrackPoint[][] = [];
|
||||||
const geojsonStr = yjs.routeData.get("geojson") as string | undefined;
|
const geojsonStr = yjs.routeData.get("geojson") as string | undefined;
|
||||||
if (geojsonStr) {
|
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
|
// Download
|
||||||
const blob = new Blob([gpx], { type: "application/gpx+xml" });
|
const blob = new Blob([gpx], { type: "application/gpx+xml" });
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,8 @@ export function SaveToJournalButton({ yjs, callbackUrl, callbackToken, returnUrl
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Build GPX from current Yjs state
|
// Build GPX from computed track (not editing waypoints).
|
||||||
const waypoints = yjs.waypoints.toArray().map((yMap: Y.Map<unknown>) => ({
|
// The track reflects the actual routed path including no-go avoidance.
|
||||||
lat: yMap.get("lat") as number,
|
|
||||||
lon: yMap.get("lon") as number,
|
|
||||||
name: yMap.get("name") as string | undefined,
|
|
||||||
}));
|
|
||||||
|
|
||||||
let tracks: TrackPoint[][] = [];
|
let tracks: TrackPoint[][] = [];
|
||||||
const geojsonStr = yjs.routeData.get("geojson") as string | undefined;
|
const geojsonStr = yjs.routeData.get("geojson") as string | undefined;
|
||||||
if (geojsonStr) {
|
if (geojsonStr) {
|
||||||
|
|
@ -42,7 +37,7 @@ export function SaveToJournalButton({ yjs, callbackUrl, callbackToken, returnUrl
|
||||||
} catch { /* invalid geojson */ }
|
} 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
|
// POST to Journal callback
|
||||||
const response = await fetch(callbackUrl, {
|
const response = await fetch(callbackUrl, {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue