mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 06:37:33 +00:00
feat(tours): show a multi-day tour's stages in the list and put each on a day
A multi-day tour in the planner's list of the trip's tours now unfolds into its stages (MDT-02), so the stages can be seen together and fitted into the trip without leaving the one route they are cut from. - The fold beside a multi-day tour lists its stages in route order, each from stop to stop with its distance, climb, descent and moving time, read off the saved tour the way the planner reads them, and below them what the whole tour adds up to. A value no stage tells is left out, a total some stages do not tell is marked as at least that much and says for how many, and a stage whose route is not planned yet says so. - Each stage has its own day: a pill opens the trip's days, moves the stage to another one or takes it off again. A stage without a day shows a dashed "No day" pill. A day holds a tour, or one of its stages, once, and a stage is on one day at most; the plan's own offline path writes it. - A stage opens in the planner: the tour opens as any tour does and the stage is shown once its points are in. - The day plan names the stage a day holds with its own figures, and the day's route runs to that stage's start and on from its end; the trip map draws that stretch only. The tour list still counts a tour once, however many days hold it or its stages. - A saved change that takes a stage away (its stage end gone, the tour a day tour again, back to the recorded track) takes it off its day in the same write and tells every client; the planner says so before the save. - REST and the assign_place_to_day tool take the stage by the key of the stop it starts at, with the same checks; list_tours names the stops between the stages and the stage each day holds. A day assignment remembers its stage by that key (migration 046010); every assignment made before holds the whole tour, as it did.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { buildDayRouteRuns, hotelBookendOf } from './dayRoutePlan'
|
||||
import { projectDayItinerary } from './dayTourProjection'
|
||||
import { projectDayItinerary, tourStageStopsByPlace } from './dayTourProjection'
|
||||
import { resolveLegMode } from '../Planner/legMode'
|
||||
import { planTripRoute, assembleTripRoute, emptyAnswers, summariseTripRoute } from './tripRouteGeometry'
|
||||
import { buildAssignment, buildDay, buildPlace, buildReservation } from '../../../tests/helpers/factories'
|
||||
@@ -437,6 +437,54 @@ describe('Tour day itinerary segments', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// MDT-02: a day holding one stage of a multi-day tour routes to that stage and draws its stretch.
|
||||
describe('A stage of a multi-day tour on a day', () => {
|
||||
const line: [number, number][] = [[48, 11], [48.01, 11], [48.02, 11], [48.03, 11], [48.04, 11]]
|
||||
const stops = [
|
||||
{ key: 'stop-start', lat: 48, lng: 11 },
|
||||
{ key: 'stop-hut', lat: 48.02, lng: 11 },
|
||||
{ key: 'stop-end', lat: 48.04, lng: 11 },
|
||||
]
|
||||
const hutToHut = (order: number, tour_stage_key: string | null) => {
|
||||
const assignment = at(48, 11, order)
|
||||
return { ...assignment, tour_place_id: assignment.place.id, tour_route_geometry: JSON.stringify(line), tour_stage_key }
|
||||
}
|
||||
|
||||
it('FE-MAP-DRP-017: draws and routes to the stretch of the stage, the stops telling where it runs', () => {
|
||||
const second = hutToHut(1, 'stop-hut')
|
||||
const stageStops = new Map([[second.place.id, stops]])
|
||||
expect(projectDayItinerary([second], true, [], stageStops)[0]).toMatchObject({
|
||||
kind: 'tour', valid: true, start: { lat: 48.02, lng: 11 }, end: { lat: 48.04, lng: 11 }, geometry: line.slice(2),
|
||||
})
|
||||
const first = hutToHut(1, 'stop-start')
|
||||
expect(projectDayItinerary([first], true, [], new Map([[first.place.id, stops]]))[0]).toMatchObject({
|
||||
start: { lat: 48, lng: 11 }, end: { lat: 48.02, lng: 11 },
|
||||
})
|
||||
const runs = buildDayRouteRuns(1, {
|
||||
...inputs({ assignments: { '1': [at(47.99, 11, 0), second, at(48.05, 11, 2)] } }),
|
||||
toursEnabled: true, tourStageStops: stageStops,
|
||||
})
|
||||
expect(runs.map(run => run.map(point => [point.lat, point.lng]))).toEqual([[[47.99, 11], [48.02, 11]], [[48.04, 11], [48.05, 11]]])
|
||||
})
|
||||
|
||||
it('FE-MAP-DRP-018: keeps the whole tour where the stops do not tell the stage', () => {
|
||||
const whole = hutToHut(1, null)
|
||||
const unknown = hutToHut(1, 'stop-gone')
|
||||
const last = hutToHut(1, 'stop-end')
|
||||
for (const assignment of [whole, unknown, last]) {
|
||||
expect(projectDayItinerary([assignment], true, [], new Map([[assignment.place.id, stops]]))[0]).toMatchObject({ geometry: line })
|
||||
}
|
||||
const noStops = hutToHut(1, 'stop-hut')
|
||||
expect(projectDayItinerary([noStops], true)[0]).toMatchObject({ geometry: line })
|
||||
})
|
||||
|
||||
it('FE-MAP-DRP-019: reads the stage stops of the multi-day tours off the tour list, none for a day tour', () => {
|
||||
const stages = tourStageStopsByPlace([{ place_id: 4, stage_stops: stops }, { place_id: 5, stage_stops: null }, { place_id: 6 }])
|
||||
expect([...stages.keys()]).toEqual([4])
|
||||
expect(stages.get(4)).toBe(stops)
|
||||
})
|
||||
})
|
||||
|
||||
// #2600: an imported GPX/KML place sits at its track's first point, so routing it as a
|
||||
// plain stop drew a second road from the track start to the next stop, alongside the
|
||||
// track itself. Any assigned place with a track now leaves that stretch to the track.
|
||||
|
||||
Reference in New Issue
Block a user