From d45f1e14fd0af634498b56ef4ceddb945a51515e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ullrich=20Sch=C3=A4fer?= Date: Mon, 13 Apr 2026 07:57:04 +0200 Subject: [PATCH] Fix route display: parse track coordinates from GPX on init The route polyline wasn't visible because segments were initialized empty. Now extractSegmentsFromGpx() parses trkpt coordinates from the GPX string via regex on init, so the route shows immediately in both view and edit modes. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/mobile/lib/editor/use-route-editor.ts | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/apps/mobile/lib/editor/use-route-editor.ts b/apps/mobile/lib/editor/use-route-editor.ts index 5ba4475..08dad73 100644 --- a/apps/mobile/lib/editor/use-route-editor.ts +++ b/apps/mobile/lib/editor/use-route-editor.ts @@ -21,9 +21,10 @@ export interface EditorState { export function useRouteEditor(route: RouteDetail) { const [state, setState] = useState(() => { const waypoints = extractWaypoints(route); + const segments = extractSegmentsFromGpx(route.gpx); return { waypoints, - segments: [], + segments, dirty: false, computing: false, saving: false, @@ -174,6 +175,27 @@ function extractWaypoints(route: RouteDetail): Waypoint[] { } } +function extractSegmentsFromGpx(gpx: string | null): RouteSegment[] { + if (!gpx) return []; + try { + const segments: RouteSegment[] = []; + const trkptRegex = / 0) { + segments.push({ coordinates }); + } + return segments; + } catch { + return []; + } +} + function extractCoordsFromGeojson(geojson: unknown): [number, number][] { try { const features = (geojson as { features?: unknown[] })?.features;