feat(tours): plan ski and winter tours, snowshoeing and winter hiking among them

Ski becomes "Ski & winter", a type the planner plans with six disciplines
(alpine, snowboard, cross-country, ski touring, snowshoeing, winter hiking),
nothing preselected; saving needs a discipline, and a technique for
cross-country. Every leg is drawn straight between the points through
planner/skiRouting.ts, the one place the piste router will plug in, with its
heights from the elevation source and no ski time worked out.

The hike's winter label goes entirely: its migration, column, field, marks,
GPX rule, MCP field and strings. A hike is summer only; a ski tour with the
snowshoe discipline exports as snowshoeing. The unreleased ski migration takes
the six disciplines and the collection migration loses the winter column.

The pistes are offered for a ski tour, shown until switched off, and with no
tour open, never for a hike. Export, copy, collections, stages (untimed),
actual tracks, the atlas, list and day marks (one glyph per discipline), 3D,
planning over a ski import and list_tours/get_tour_plan know the planned ski
tour.
This commit is contained in:
Maurice
2026-10-20 18:27:53 +02:00
parent 204ee2ef86
commit 164a3633ac
116 changed files with 1675 additions and 1576 deletions
+10 -9
View File
@@ -197,17 +197,18 @@ describe('tourRepo.update', () => {
expect(await offlineDb.places.get(40)).toMatchObject({ description: 'Keep description', website: 'https://example.org/old' })
})
it('FE-REPO-TOUR-042: offline, a hike takes its winter label at once, keeps it when a save leaves it out, and another type drops it (HIK-01)', async () => {
it('FE-REPO-TOUR-042: offline, a planned ski tour shows its discipline at once, a technique for cross-country only, and another type drops both (SKI-02)', async () => {
setOnline(false)
await offlineDb.tours.put({ ...tour({ winter_activity: 'snowshoe' }), trip_id: 3 })
await offlineDb.tours.put({ ...tour(), trip_id: 3 })
const ski = { ...body, tour_type: 'ski' as const, max_hiking_difficulty: null, duration_seconds: null }
expect((await tourRepo.update(3, 40, body)).tour.winter_activity).toBe('snowshoe')
expect((await tourRepo.update(3, 40, { ...body, winter_activity: 'winter_hike' })).tour.winter_activity).toBe('winter_hike')
expect((await tourRepo.update(3, 40, { ...body, winter_activity: null })).tour.winter_activity).toBeNull()
await tourRepo.update(3, 40, { ...body, winter_activity: 'snowshoe' })
const bike = { ...body, tour_type: 'bike' as const, bike_profile: 'touring' as const, max_hiking_difficulty: null }
expect((await tourRepo.update(3, 40, bike)).tour.winter_activity).toBeNull()
expect((await offlineDb.tours.get(40))?.winter_activity).toBeNull()
expect((await tourRepo.update(3, 40, { ...ski, ski_discipline: 'snowshoe' })).tour).toMatchObject({ tour_type: 'ski', ski_discipline: 'snowshoe', ski_technique: null })
const skating = { ...ski, ski_discipline: 'cross_country' as const, ski_technique: 'skating' as const }
expect((await tourRepo.update(3, 40, skating)).tour).toMatchObject({ ski_discipline: 'cross_country', ski_technique: 'skating' })
expect((await tourRepo.update(3, 40, { ...skating, ski_discipline: 'touring' })).tour.ski_technique).toBeNull()
expect((await tourRepo.update(3, 40, body)).tour).toMatchObject({ tour_type: 'hike', ski_discipline: null, ski_technique: null })
expect(await offlineDb.tours.get(40)).toMatchObject({ ski_discipline: null, ski_technique: null })
expect(await offlineDb.tours.get(40)).not.toHaveProperty('winter_activity')
})
it('FE-REPO-TOUR-043: offline, a run shows its profile, pace and planned time at once, and another type drops them (RUN-01)', async () => {
+7 -6
View File
@@ -84,12 +84,13 @@ function endpointsOf(routeGeometry: unknown): TourWaypoint[] {
}
/**
* HIK-01: a hike's winter label as the server keeps it. Another type has none,
* and a hike's save that leaves the field out keeps the label it has.
* SKI-02: a ski tour's discipline and cross-country technique as the server
* keeps them; any other type has neither.
*/
function winterField(body: TourCreateRequest): Pick<TourListItem, 'winter_activity'> {
if (body.tour_type !== 'hike') return { winter_activity: null }
return body.winter_activity === undefined ? {} : { winter_activity: body.winter_activity }
function skiFields(body: TourCreateRequest): Pick<TourListItem, 'ski_discipline' | 'ski_technique'> {
if (body.tour_type !== 'ski') return { ski_discipline: null, ski_technique: null }
const discipline = body.ski_discipline ?? null
return { ski_discipline: discipline, ski_technique: discipline === 'cross_country' ? (body.ski_technique ?? null) : null }
}
/** RUN-01: a run's profile and pace as the server keeps them; any other type has neither. */
@@ -125,7 +126,7 @@ function routeFields(body: TourCreateRequest) {
match_confidence: 1,
caution: false,
max_hiking_difficulty: body.max_hiking_difficulty,
...winterField(body),
...skiFields(body),
...runFields(body),
has_waypoints: true,
...walkStationFacts(body.tour_type, body.waypoints),