Add split export: Export Route vs Export Plan
Split button with default "Export GPX" (track only) and dropdown: - Export Route: clean track for use in any app - Export Plan: track + waypoints + no-go areas in GPX extensions (trails:planning namespace) for reimporting into the planner Also: - Add no-go area serialization to generateGpx (GPX extensions) - Parse no-go areas from GPX extensions on import - Initialize no-go areas in Yjs session from imported GPX - Save to Journal now exports track only (consistent with Export Route) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
237660db5e
commit
4b711abaec
11 changed files with 172 additions and 60 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { data } from "react-router";
|
||||
import type { Route } from "./+types/api.sessions";
|
||||
import { createSession, listSessions } from "~/lib/sessions";
|
||||
import { createSession, listSessions, initializeSessionWithNoGoAreas } from "~/lib/sessions";
|
||||
import { parseGpxAsync, extractWaypoints } from "@trails-cool/gpx";
|
||||
import { withDb } from "@trails-cool/db";
|
||||
|
||||
|
|
@ -25,6 +25,9 @@ export async function action({ request }: Route.ActionArgs) {
|
|||
const gpxData = await parseGpxAsync(gpx);
|
||||
const wps = extractWaypoints(gpxData);
|
||||
if (wps.length > 0) initialWaypoints = wps;
|
||||
if (gpxData.noGoAreas.length > 0) {
|
||||
initializeSessionWithNoGoAreas(session.id, gpxData.noGoAreas);
|
||||
}
|
||||
} catch {
|
||||
// Continue with empty session if GPX is invalid
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { redirect, data } from "react-router";
|
||||
import type { Route } from "./+types/new";
|
||||
import { createSession, initializeSessionWithWaypoints } from "~/lib/sessions";
|
||||
import { createSession, initializeSessionWithWaypoints, initializeSessionWithNoGoAreas } from "~/lib/sessions";
|
||||
import { parseGpxAsync, extractWaypoints } from "@trails-cool/gpx";
|
||||
import { checkRateLimit } from "~/lib/rate-limit";
|
||||
|
||||
|
|
@ -37,6 +37,9 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|||
const gpx = decodeURIComponent(gpxEncoded);
|
||||
const gpxData = await parseGpxAsync(gpx);
|
||||
initializeSessionWithWaypoints(session.id, extractWaypoints(gpxData));
|
||||
if (gpxData.noGoAreas.length > 0) {
|
||||
initializeSessionWithNoGoAreas(session.id, gpxData.noGoAreas);
|
||||
}
|
||||
} catch {
|
||||
// Continue with empty session if GPX is invalid
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue