feat(roadtrip): a booked night can stand at both ends of its days

The drive learns what a booked night at the edge of a day is, while nothing seats one
yet. One rule in shared, seatNightBookends, picks the stay a day wakes up in and the one
it sleeps in the way Days does, over real nights and in id order, and puts each hotel at
the edge of the day as a stop of its own that belongs to no assignment.

The schedule, the day window, the spill into the next morning, the sums and the connected
days read a night spent at one hotel as a leg going nowhere, never cut or postpone the
drive to tonight's hotel, and pass the hotel over wherever a stop is looked up by its
stored index. That lookup now also puts a place added behind a terminal where it fell.

The rail and the phone chain draw the hotel as a row of its own that opens the booking or
the stay, offers no other ways and takes no via, in every language. Until a trip switches
it on, every plan is the one stored.
This commit is contained in:
Maurice
2026-09-23 14:18:59 +02:00
parent 7fa0434570
commit 514e2e62ee
60 changed files with 2563 additions and 134 deletions
@@ -11,6 +11,7 @@ import {
carrierLegsFor,
carrierSeam,
foldRouteRun,
isStationaryJoin,
splitIntoRuns,
spillChains,
dayWindow,
@@ -20,7 +21,7 @@ import {
formatDurationShort,
seatCarrierStops,
undatedRides,
viasLeaving,
viasOnLeg,
type CarrierBooking,
type CarrierSeam,
type DistanceUnit,
@@ -269,8 +270,9 @@ export class RoadtripPlanService {
stops.forEach((stop, index) => {
stopAt.push(points.length);
points.push({ lat: stop.lat, lng: stop.lng });
// None bend the drive from or to a booked night's hotel (`viasOnLeg`).
if (index < stops.length - 1)
points.push(...viasLeaving(stop, context.vias).map((v) => ({ lat: v.lat, lng: v.lng })));
points.push(...viasOnLeg(stop, stops[index + 1], context.vias).map((v) => ({ lat: v.lat, lng: v.lng })));
});
try {
if (points.length > 100) throw new Error('Too many waypoints');
@@ -336,7 +338,8 @@ export class RoadtripPlanService {
const pairs = chain.stops.slice(0, -1).map((from, index) => ({ from, to: chain.stops[index + 1] }));
if (connectDays && previous && chain.stops.length) pairs.push({ from: previous, to: chain.stops[0] });
for (const { from, to } of pairs) {
if (asked.has(stopKey(from) + '>' + stopKey(to))) continue;
// A night spent at one hotel is no drive, and no router is asked about it.
if (isStationaryJoin(from, to) || asked.has(stopKey(from) + '>' + stopKey(to))) continue;
await fetchRun(
[from, to],
chain.dayId,