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
@@ -215,11 +215,12 @@ describe('useGpxConversion', () => {
);
});
it('SKI-02: a ski track is never planned over: nothing is offered and no router is asked', () => {
it('SKI-02: a ski track is planned over as a ski tour of its discipline, its legs drawn straight', async () => {
const ski = {
...imported,
tour_type: 'ski' as const,
ski_discipline: 'touring' as const,
ski_discipline: 'cross_country' as const,
ski_technique: 'classic' as const,
max_hiking_difficulty: null,
};
const controller = planner({
@@ -227,6 +228,29 @@ describe('useGpxConversion', () => {
readOnlyGpxTour: { tour: ski, routeGeometry: null },
} as Partial<TourPlannerController>);
const { result } = renderHook(() => useGpxConversion(controller));
expect(result.current.available).toBe(true);
expect(result.current.paddle).toBe(true);
await act(async () => {
await result.current.analyze();
});
const legs = routing.route.mock.calls[0]?.[0] as Array<{ fixedLeg: { kind: string } | null }>;
expect(legs.slice(0, -1).every((point) => point.fixedLeg?.kind === 'free')).toBe(true);
expect(routing.run).not.toHaveBeenCalled();
act(() => {
result.current.adopt('new');
});
expect(controller.startDerivedTour).toHaveBeenCalledWith(
expect.objectContaining({ tourType: 'ski', ski: { discipline: 'cross_country', technique: 'classic' } })
);
});
it('SKI-02: a ski track that names no discipline is not planned over: nothing is offered and no router is asked', () => {
const ski = { ...imported, tour_type: 'ski' as const, ski_discipline: null, max_hiking_difficulty: null };
const controller = planner({
mode: { type: 'view-gpx', placeId: ski.place_id, tour: ski },
readOnlyGpxTour: { tour: ski, routeGeometry: null },
} as Partial<TourPlannerController>);
const { result } = renderHook(() => useGpxConversion(controller));
expect(result.current.available).toBe(false);
const { container } = render(<TourConversionSection conversion={result.current} />);
expect(container).toBeEmptyDOMElement();
@@ -77,7 +77,13 @@ export default function TourConversionSection({ conversion }: { conversion: GpxC
return card(
<div className="flex flex-col items-start gap-2.5">
<p className="m-0 leading-snug text-content-secondary" style={fs(12, 'body')}>
{t(conversion.paddle ? 'tours.conversion.introPaddle' : 'tours.conversion.intro')}
{t(
conversion.ski
? 'tours.conversion.introSki'
: conversion.paddle
? 'tours.conversion.introPaddle'
: 'tours.conversion.intro'
)}
</p>
<CardAction onClick={() => void conversion.analyze()} icon={<Route size={12} strokeWidth={2.2} />}>
{t('tours.conversion.analyze')}
@@ -5,6 +5,7 @@ import { isTourRoute } from '../planner/tourRouteOutcome';
import { routeBikeTour, routeRun, routeWalkingTour } from '../planner/tourRouting';
import { paddleFieldsOf } from '../planner/usePaddleFields';
import type { TourPlannerController } from '../planner/useTourPlanner';
import { skiChoiceMissing, skiChoiceOf } from '../ski/skiChoice';
import { compareRoutes, deriveControlPoints, type RouteComparison, type TrackPoint } from './gpxConversion';
/** The grade a planned version routes with when the import carries none: the paths a T3 walk may take. */
@@ -47,6 +48,9 @@ export function useGpxConversion(planner: TourPlannerController) {
// RUN-01: a run import is planned as a run for its profile, at the pace it holds; a fresh
// import holds none, so its pace is the runner's to enter.
const runProfile = tour?.tour_type === 'run' ? (tour.run_profile ?? 'running') : null;
// SKI-02: a ski import is planned as a ski tour of its discipline, its legs drawn as the planner draws them.
const ski = useMemo(() => (tour?.tour_type === 'ski' ? skiChoiceOf(tour) : null), [tour]);
const drawn = paddle || ski !== null;
useEffect(() => () => abort.current?.abort(), []);
@@ -63,7 +67,7 @@ export function useGpxConversion(planner: TourPlannerController) {
return;
}
setState({ ...base, status: 'analyzing' });
const legs = paddle
const legs = drawn
? points.map((point, index) => ({
...point,
fixedLeg: index < points.length - 1 ? freeLegBetween(point, points[index + 1]) : null,
@@ -86,7 +90,7 @@ export function useGpxConversion(planner: TourPlannerController) {
line: routed.coordinates,
comparison: compareRoutes(trackPoints, suggestion),
});
}, [bikeProfile, difficulty, paddle, runProfile, tour, track]);
}, [bikeProfile, difficulty, drawn, runProfile, tour, track]);
const cancel = useCallback(() => {
abort.current?.abort();
@@ -115,11 +119,12 @@ export function useGpxConversion(planner: TourPlannerController) {
...(runProfile
? { tourType: 'run' as const, runProfile, runPaceSecondsPerKm: tour.run_pace_seconds_per_km ?? null }
: {}),
...(ski ? { tourType: 'ski' as const, ski } : {}),
});
if (started) setState(IDLE);
return started;
},
[bikeProfile, current.points, current.status, difficulty, paddle, runProfile, startDerivedTour, tour]
[bikeProfile, current.points, current.status, difficulty, paddle, runProfile, ski, startDerivedTour, tour]
);
return useMemo(
@@ -127,23 +132,25 @@ export function useGpxConversion(planner: TourPlannerController) {
...current,
/**
* The import shown can be planned from: it has a track and the user may add tours. A ski
* track (SKI-02) never: TREK routes no ski track, and a hike's or a walk's route is no stand-in.
* A ride (HOR-01) neither: no router plans one, and walking it again on foot would be no ride.
* track (SKI-02) once it names its discipline, planned as a ski tour with its legs drawn.
* A ride (HOR-01) never: no router plans one, and walking it again on foot would be no ride.
*/
available:
tour !== null &&
tour.tour_type !== 'ski' &&
(ski === null || skiChoiceMissing(ski) === null) &&
tour.tour_type !== 'horse' &&
(track?.length ?? 0) >= 2 &&
planner.canEdit,
difficulty,
/** The import is a paddle tour: its version is drawn with straight legs, not routed. */
paddle,
/** The import is a paddle or a ski tour: its version is drawn with straight legs, not routed. */
paddle: drawn,
/** SKI-02: the import is a ski track, planned as a ski tour of its discipline. */
ski: ski !== null,
analyze,
cancel,
adopt,
}),
[adopt, analyze, cancel, current, difficulty, paddle, planner.canEdit, tour, track]
[adopt, analyze, cancel, current, difficulty, drawn, planner.canEdit, ski, tour, track]
);
}