mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
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:
@@ -1,13 +1,16 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* SKI-02: a ski track comes in as a GPX file and is kept as it was recorded.
|
||||
* TREK routes no ski track and works out no ski time: its distance and heights
|
||||
* are the file's, and nothing is said about snow, avalanches or whether a run
|
||||
* or a trail is open. What the skier names on purpose is the discipline, and
|
||||
* for cross-country the technique.
|
||||
* SKI-02: a ski and winter tour, planned in the planner or imported from a
|
||||
* GPX file. A planned one has every leg drawn between its points (the piste
|
||||
* router comes later), an imported one is kept as it was recorded. TREK works
|
||||
* out no ski time, and nothing is said about snow, avalanches or whether a
|
||||
* run or a trail is open. What the traveller names on purpose is the
|
||||
* discipline: alpine, snowboard, cross-country, ski touring, snowshoeing or
|
||||
* winter hiking (both of which live here and not on a hike), and for
|
||||
* cross-country the technique.
|
||||
*/
|
||||
export const SKI_DISCIPLINES = ['alpine', 'snowboard', 'cross_country', 'touring'] as const;
|
||||
export const SKI_DISCIPLINES = ['alpine', 'snowboard', 'cross_country', 'touring', 'snowshoe', 'winter_hike'] as const;
|
||||
export const skiDisciplineSchema = z.enum(SKI_DISCIPLINES);
|
||||
export type SkiDiscipline = z.infer<typeof skiDisciplineSchema>;
|
||||
|
||||
@@ -23,9 +26,10 @@ export type SkiTechnique = z.infer<typeof skiTechniqueSchema>;
|
||||
type SkiIssue = { path: string[]; message: string };
|
||||
|
||||
/**
|
||||
* What a ski track names, and what nothing else may: a ski track its
|
||||
* discipline, a cross-country track its technique as well; a technique on any
|
||||
* other discipline, and either field on another type, is refused.
|
||||
* What a ski tour names, and what nothing else may: a ski tour its
|
||||
* discipline, a cross-country tour its technique as well; a technique on any
|
||||
* other discipline, and either field on another type, is refused. Planned and
|
||||
* imported ski tours are held to the same rule.
|
||||
*/
|
||||
export function skiIssues(
|
||||
isSki: boolean,
|
||||
@@ -34,19 +38,19 @@ export function skiIssues(
|
||||
if (!isSki) {
|
||||
return (['ski_discipline', 'ski_technique'] as const)
|
||||
.filter((field) => value[field] != null)
|
||||
.map((field) => ({ path: [field], message: `${field} belongs to a ski track` }));
|
||||
.map((field) => ({ path: [field], message: `${field} belongs to a ski tour` }));
|
||||
}
|
||||
if (value.ski_discipline == null) return [{ path: ['ski_discipline'], message: 'a ski track needs a discipline' }];
|
||||
if (value.ski_discipline == null) return [{ path: ['ski_discipline'], message: 'a ski tour needs a discipline' }];
|
||||
const crossCountry = value.ski_discipline === 'cross_country';
|
||||
if (crossCountry && value.ski_technique == null)
|
||||
return [{ path: ['ski_technique'], message: 'a cross-country track needs a technique' }];
|
||||
return [{ path: ['ski_technique'], message: 'a cross-country tour needs a technique' }];
|
||||
if (!crossCountry && value.ski_technique != null)
|
||||
return [{ path: ['ski_technique'], message: 'only a cross-country track has a technique' }];
|
||||
return [{ path: ['ski_technique'], message: 'only a cross-country tour has a technique' }];
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* A ski track classified again after its import: the discipline and the
|
||||
* A ski tour classified again after its import: the discipline and the
|
||||
* technique, nothing of the track. Refused with a 409 once the tour moved on
|
||||
* past the revision the choice was made at.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user