mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
fix(roadtrip): a phone stage no longer draws the drive into the next day
"Connect the days" is a whole-drive setting: with it on, the leg from one day's last stop to the next day's first is drawn in the colour of the day it leaves, so the desktop map reads as one continuous drive across every day. The phone has no such view by default. It shows ONE day, and the stage filter went by day number alone, so that connection came along: a line running off the day on screen to a place it never visits, and on this trip the longest thing on the map by far. The assembler now says which lines are connections (`lineJoins`, parallel to `lines` and `lineDays`) rather than leaving each surface to guess, because the day number cannot tell them apart: it reads the leaving day for both a day's own legs and for the drive out of it. A stage drops them; the all-days view keeps them, which is the view the setting is for and is one tap away on the same map, next to the day chips. Routes read back from an older cache carry no marks, so nothing is known to be a join and nothing is dropped: those days draw exactly as they did before.
This commit is contained in:
@@ -162,4 +162,23 @@ describe('assembleRoadtrip connected days', () => {
|
||||
expect(routes.days[1]!.arrivingFrom).toBeUndefined();
|
||||
expect(routes.days[1]!.geometry[0]).toEqual([60, 10]);
|
||||
});
|
||||
|
||||
it('ROADTRIP-ASSEMBLE-006: that drive is marked as the connection it is, in the colour of the day it leaves', () => {
|
||||
const routes = assembleTwoDays(true);
|
||||
|
||||
// Day 1 drives two of its own legs and then on into day 2; day 2 drives one.
|
||||
expect(routes.lineDays).toEqual([1, 1, 1, 2]);
|
||||
expect(routes.lines).toHaveLength(routes.lineJoins.length);
|
||||
// The third line is drawn as day 1 but runs into day 2, and only it is a join. A
|
||||
// surface showing one day needs that apart from the day number, which says day 1 for
|
||||
// both the day's own legs and for the drive leading off it.
|
||||
expect(routes.lineJoins).toEqual([false, false, true, false]);
|
||||
});
|
||||
|
||||
it('ROADTRIP-ASSEMBLE-007: with the days unconnected there is no join to mark', () => {
|
||||
const routes = assembleTwoDays(false);
|
||||
|
||||
expect(routes.lineDays).toEqual([1, 1, 2]);
|
||||
expect(routes.lineJoins).toEqual([false, false, false]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -99,6 +99,9 @@ export function assembleRoadtrip({
|
||||
|
||||
const lines: [number, number][][] = [];
|
||||
const lineDays: number[] = [];
|
||||
// Parallel to `lines`: true where the line is the drive into the NEXT day, drawn in the
|
||||
// leaving day's colour. See `lineJoins` on RoadtripRoutes.
|
||||
const lineJoins: boolean[] = [];
|
||||
const segments: RouteSegment[] = [];
|
||||
const accessLines: RoadtripRoutes['accessLines'] = [];
|
||||
|
||||
@@ -134,6 +137,10 @@ export function assembleRoadtrip({
|
||||
if (inbound.line.length > 1) {
|
||||
lines.push(inbound.line);
|
||||
lineDays.push(inbound.drawnAs);
|
||||
// A spill carries its own `fromDayNumber` and a joined day the number of the day
|
||||
// it left: either way, a line drawn as a day other than the one it runs in is
|
||||
// the connection into this one.
|
||||
lineJoins.push(inbound.drawnAs !== chain.dayNumber);
|
||||
}
|
||||
if (inbound.seg) segments.push(inbound.seg);
|
||||
}
|
||||
@@ -142,6 +149,7 @@ export function assembleRoadtrip({
|
||||
if (leg.line.length > 1) {
|
||||
lines.push(leg.line);
|
||||
lineDays.push(chain.dayNumber);
|
||||
lineJoins.push(false);
|
||||
}
|
||||
segments.push(leg.seg);
|
||||
}
|
||||
@@ -288,6 +296,7 @@ export function assembleRoadtrip({
|
||||
days: drives,
|
||||
lines,
|
||||
lineDays,
|
||||
lineJoins,
|
||||
segments,
|
||||
accessLines,
|
||||
vias: out.flatMap((d) => d.legVias.flat()),
|
||||
|
||||
@@ -175,6 +175,18 @@ export interface RoadtripRoutes {
|
||||
|
||||
lineDays: number[];
|
||||
|
||||
/**
|
||||
* Which of `lines` is the drive INTO the following day rather than a drive within the
|
||||
* day it is drawn as, parallel to `lines` and `lineDays`.
|
||||
*
|
||||
* With "connect the days" on, the leg from one day's last stop to the next day's first
|
||||
* is drawn in the colour of the day it leaves, so on a map showing the whole drive it
|
||||
* reads as that day continuing. A surface showing ONE day has to tell the two apart:
|
||||
* the connection leads off the day on screen and belongs to the next one, and drawn
|
||||
* there it is a line to a place that day never visits.
|
||||
*/
|
||||
lineJoins: boolean[];
|
||||
|
||||
accessLines: AccessSpur[];
|
||||
|
||||
vias: RouteVia[];
|
||||
|
||||
Reference in New Issue
Block a user