client: resolve boundary-leg modes from either endpoint in the map route calc

This commit is contained in:
Ida Rogalska
2026-08-11 19:30:44 +02:00
committed by Maurice
parent 5679ea76d2
commit 38bdb1d4b7
2 changed files with 28 additions and 21 deletions
+8 -8
View File
@@ -92,14 +92,14 @@ export async function calculateRoute(
* hotel and the first/last located waypoint exist; passing nulls leaves `runs`
* untouched. The shared first/last waypoint is repeated so the polylines join.
*/
export function withHotelBookends(
runs: Waypoint[][],
firstWay: Waypoint | undefined,
lastWay: Waypoint | undefined,
startHotel: Waypoint | null,
endHotel: Waypoint | null,
): Waypoint[][] {
const out: Waypoint[][] = []
export function withHotelBookends<T extends { lat: number; lng: number }>(
runs: T[][],
firstWay: T | undefined,
lastWay: T | undefined,
startHotel: T | null,
endHotel: T | null,
): T[][] {
const out: T[][] = []
if (startHotel && firstWay) out.push([startHotel, firstWay])
out.push(...runs)
if (endHotel && lastWay) out.push([lastWay, endHotel])