Files
TREK/client/src/store/tourRouteHighlightStore.ts
T
Maurice 3572f4b8a3 feat(tours): show the known surfaces and way types along a hike (MAP-04)
The hike's "SAC grades" card becomes "Trail details": one switch, then a
segmented choice between SAC, Surface and Way type, three things kept
apart and drawn along the route on the planner map one at a time. Every
facet reads from the same answer: the ways under the line are matched on
foot once, their OpenStreetMap values fetched once through the
trail-grades read MAP-03 already uses, and each stretch is placed against
the tour's own line once. Switching facets asks nothing new.

The server now hands on a way's surface and highway tags as OpenStreetMap
wrote them, only trimmed and bounded. The planner groups them (asphalt or
concrete, paving stones, compacted, gravel, natural ground, grass, rock,
wood or metal, unpaved without a kind, other; path, footway, steps, farm
or forest track, cycle path, minor road, road, via ferrata, other), and
each row's tooltip names the values recorded, such as surface=gravel,
surface=pebblestone. The router's own surface reading is never used: it
is normalised and a default where nothing is recorded.

What is not known stays unknown and says why, in every facet: no value
recorded, a value no group takes or two at once (unclear, never the
nearest group), no way clearly under the tour's line, or a way that could
not be asked about. Imported tracks and hand-drawn stretches keep their
geometry; a matched way only counts where it keeps within 25 m of it.
A summary badge gives the known share and the most common class; the SAC
facet keeps its highest step and routing limit badges. Nothing about the
tour, its places or its days changes, and no routing preference is set.
2026-10-20 15:17:52 +02:00

31 lines
1.1 KiB
TypeScript

import { create } from 'zustand';
/**
* BIK-01 to BIK-05, RUN-02, MAP-03 and MAP-04: the stretches of the planned
* route a card points at (a surface, a kind of way, a trail or hiking grade,
* and on a hike its SAC grades, surfaces or kinds of way as OpenStreetMap
* records them), drawn over the route on the planner map in the colour of
* what they are. `paint` names a token of the route paints (bike and hike),
* resolved where the map is drawn, so the theme decides the colour.
*/
export interface RouteHighlight {
/** What is pointed at, so its row can show it is on. */
id: string;
lines: [number, number][][];
paint: string;
/** One paint per line where they differ, as when a hike's whole facet is drawn at once; else `paint` for all. */
paints?: readonly string[];
}
interface TourRouteHighlightState {
highlight: RouteHighlight | null;
show: (highlight: RouteHighlight | null) => void;
clear: () => void;
}
export const useTourRouteHighlightStore = create<TourRouteHighlightState>((set) => ({
highlight: null,
show: (highlight) => set({ highlight }),
clear: () => set({ highlight: null }),
}));