Files
TREK/client/src/components/Tours/planner/paddlePlanOf.ts
T
Maurice 2c3b20bb57 feat(tours): paddle portages and locks, paddle time, wind at the start and obstacle data from OpenStreetMap
PAD-03 portages and locks on planned tours and recorded tracks, PAD-07 paddle time with portage and lock stops, PAD-08 wind forecast for the start, PAD-05A regional obstacle import from Geofabrik extracts with admin endpoints and a monthly refresh, PAD-05B first cut of the obstacle layer on Leaflet, GL and 3D. Work in progress: checklist (PAD-06), check bench (PAD-09), admin UI, translations and tests follow.
2026-10-16 23:44:58 +02:00

43 lines
1.5 KiB
TypeScript

import {
estimatePaddleTime,
paddleLayoutOfPoints,
paddleRolesOf,
type PaddlePlanPoint,
type PaddleRole,
type PaddleTimeEstimate,
} from '@trek/shared';
import type { TourPlannerWaypoint } from './useTourPlanner';
/** The planner's control points as the shared paddle plan reads them. */
export function paddlePlanPoints(points: readonly TourPlannerWaypoint[]): PaddlePlanPoint[] {
return points.map((point) => ({
lat: point.lat,
lng: point.lng,
fixed_leg: point.fixedLeg ?? null,
lock: point.lock ?? null,
}));
}
/** Put-in, take-out, re-entry and final take-out by control point id. */
export function paddleRolesById(points: readonly TourPlannerWaypoint[]): Map<string, PaddleRole | null> {
const roles = paddleRolesOf(paddlePlanPoints(points));
return new Map(points.map((point, index) => [point.id, roles[index] ?? null]));
}
/**
* PAD-07: the estimate of a paddle tour as planned, without its breaks (the
* planner adds those as it does for a hike). A speed the paddler typed that
* does not hold leaves the water time unknown rather than wrong.
*/
export function paddleEstimateOf(
points: readonly TourPlannerWaypoint[],
paddle: { effectiveSpeedKmh: number | null; portageSpeedKmh: number | null },
speedInvalid: boolean
): PaddleTimeEstimate {
return estimatePaddleTime(paddleLayoutOfPoints(paddlePlanPoints(points)), {
paddleSpeedKmh: speedInvalid ? null : paddle.effectiveSpeedKmh,
portageSpeedKmh: paddle.portageSpeedKmh,
breakMinutes: null,
});
}