mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 06:37:33 +00:00
fix(maps): stop the day route drawing drives to airports you flew from
A flight leaving overnight contributes only its departure airport on the day it leaves, and the evening hotel bookend was attaching to whatever point sat at the day's edge. So the map drew a straight line from the airport you took off from to the hotel you were checking into. The same blind spot on the run builder produced the long rays: a day's order is a bare wall clock, so an inbound long-haul whose departure clock reads late sorts after the day's local stops, and its far departure airport got appended to that run. OSRM answers such a pair with NoRoute and the fallback straightens the whole chunk, taking the genuine local drive with it. Both now ask whether the pair could be driven at all. A flight, train, ferry, cruise or coach carries you out of the day's geography, so its departure point has no drive back to tonight's hotel and its arrival point had no drive from this morning's. A hire car is the opposite and stays out of that set: you keep driving it, so a multi-day rental's pickup and drop-off points keep their hotel legs. Alongside it, any leg touching a booking endpoint has to be within MAX_DRIVE_KM, which catches the mis-sorted edges the role alone cannot see. The sidebar gets both guards so its hotel connectors stay in step with the drawn route; the mobile map and timeline read the same hook.
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
import type { Day, Accommodation, RouteAnchors } from '../types'
|
||||
import { parseTimeToMinutes } from './dayMerge'
|
||||
|
||||
/**
|
||||
* Set on an edge waypoint that is the endpoint of a booking which CARRIES you out of
|
||||
* the day's geography (see `isCarrierTransport`): 'departure' = you left from this
|
||||
* point, 'arrival' = you were set down at it. A hire car — a vehicle you keep driving —
|
||||
* leaves this unset, so its pickup/drop-off points keep the hotel legs they have always
|
||||
* drawn. Undefined always means "no opinion", which is what keeps every existing caller
|
||||
* and the activity-free transfer day behaving exactly as before.
|
||||
*/
|
||||
export type CarrierEdge = 'departure' | 'arrival' | null
|
||||
|
||||
export const getDayOrder = (day: Day, days: Day[]): number =>
|
||||
day.day_number ?? days.indexOf(day)
|
||||
|
||||
@@ -67,8 +77,12 @@ export const getAccommodationAnchors = (
|
||||
export const shouldDrawMorningLeg = (
|
||||
bookends: { morning?: Accommodation; morningIsSleptHere?: boolean },
|
||||
day: Day,
|
||||
firstStop?: { isPlace: boolean; time?: string | null },
|
||||
firstStop?: { isPlace: boolean; time?: string | null; carrierEdge?: CarrierEdge },
|
||||
): boolean => {
|
||||
// You landed here. Whatever hotel the day belongs to, nobody drove out of it to the
|
||||
// airport they arrived at — so there is no morning leg, not even on a night you
|
||||
// provably slept in that hotel (#2133).
|
||||
if (firstStop?.carrierEdge === 'arrival') return false
|
||||
if (bookends.morningIsSleptHere) return true
|
||||
const m = bookends.morning
|
||||
if (!m || m.start_day_id !== day.id || !firstStop?.isPlace) return false
|
||||
@@ -91,8 +105,11 @@ export const shouldDrawMorningLeg = (
|
||||
export const shouldDrawEveningLeg = (
|
||||
bookends: { evening?: Accommodation; eveningIsOvernight?: boolean },
|
||||
day: Day,
|
||||
lastStop?: { isPlace: boolean; time?: string | null },
|
||||
lastStop?: { isPlace: boolean; time?: string | null; carrierEdge?: CarrierEdge },
|
||||
): boolean => {
|
||||
// Mirror: you took off from here, so no drive leads from it back to tonight's hotel —
|
||||
// the reported "flight starting airport connected to the accommodation" (#2133).
|
||||
if (lastStop?.carrierEdge === 'departure') return false
|
||||
if (bookends.eveningIsOvernight) return true
|
||||
const e = bookends.evening
|
||||
if (!e || e.end_day_id !== day.id || !lastStop?.isPlace) return false
|
||||
|
||||
Reference in New Issue
Block a user