mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 18:04:18 +00:00
fix(roadtrip): the day view drives the road picked in the road trip
A chosen alternative or a hand-bent drive is stored as vias, and only the road trip rail routed through them. The day route on the map, its connectors in the day list and on the phone, and the overview of all days asked the router for the bare stops, so they drew and measured the default road again. They now thread the same vias between two stops that follow each other in the stored list, with the anchor counted the way the rail counts it, and fold the answer back to one leg per stop pair. Only while the road trip addon is on; avoid settings and the routing engine stay with the rail. Refs #2580
This commit is contained in:
@@ -14,6 +14,7 @@ import { dayWindow } from './dayWindow'
|
||||
import { useTranslation } from '../../i18n/TranslationContext'
|
||||
import { stayStartingOn } from '../../utils/dayMerge'
|
||||
import { staysAtTheirPlaces } from './nightBookend'
|
||||
import { viaKeyOf } from '../Map/dayRouteVias'
|
||||
|
||||
export type { RoadtripStop, RoadtripDay, RoadtripRoutes, QuietDay, AccessSpur, RoutedLeg, SnappedPoint } from '@trek/shared/roadtrip'
|
||||
|
||||
@@ -402,15 +403,7 @@ export function useRoadtripRoutes(
|
||||
|
||||
// Only the geometry decides whether legs have to be re-fetched: renaming a place or
|
||||
// editing its notes must not fire a routing round.
|
||||
const viaKey = useMemo(
|
||||
() => Object.entries(viasByDay)
|
||||
.map(([dayId, vias]) => `${dayId}:${vias.map(v => `${v.after_order_index}@${v.lat.toFixed(5)},${v.lng.toFixed(5)}`).join('|')}`)
|
||||
// Only the order has to be stable — this is a cache key, not a list anybody reads
|
||||
// — but it has to be stable on purpose rather than by default.
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.join(';'),
|
||||
[viasByDay],
|
||||
)
|
||||
const viaKey = useMemo(() => viaKeyOf(viasByDay), [viasByDay])
|
||||
|
||||
const planKey = useMemo(
|
||||
() => `${plan.map(d => `${d.dayId}:${d.stops.map(stopKey).join('|')}`).join(';')}#${viaKey}`,
|
||||
|
||||
Reference in New Issue
Block a user