mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 08:30:05 +00:00
2c3b20bb57
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.
43 lines
1.5 KiB
TypeScript
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,
|
|
});
|
|
}
|