Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(roadtrip): a merged drive keeps its first piece ends when a leg comes without them

Maurice83d088e842bc
diff --git a/shared/src/roadtrip/routeRun.ts b/shared/src/roadtrip/routeRun.ts
index 09db903ca..2bd79ba89 100644
--- a/shared/src/roadtrip/routeRun.ts
+++ b/shared/src/roadtrip/routeRun.ts
@@ -27,10 +27,17 @@ export function mergeRouteSegments(parts: RouteSegment[], unit: DistanceUnit): R
const distance = parts.reduce((sum, leg) => sum + (leg.distance ?? 0), 0);
const duration = parts.reduce((sum, leg) => sum + (leg.duration ?? 0), 0);
const durationText = formatDurationShort(duration);
+ // A leg a provider handed over without its ends keeps the first piece's; the texts are
+ // what the reader was shown wrong, the ends only place the label.
+ const ends = first.from && last.to ? { from: first.from, to: last.to } : null;
return {
...first,
- to: last.to,
- mid: [(first.from[0] + last.to[0]) / 2, (first.from[1] + last.to[1]) / 2],
+ ...(ends
+ ? {
+ to: ends.to,
+ mid: [(ends.from[0] + ends.to[0]) / 2, (ends.from[1] + ends.to[1]) / 2] as [number, number],
+ }
+ : {}),
distance,
duration,
distanceText: formatDistance(distance / 1000, unit),