mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
1bc82f97fd
Paddle tours are planned on the water by TREK's own router: a water network per paddle region, built from the same Geofabrik extract as the obstacles and searched in a worker thread of the server (no sidecar). Rivers, canals and lakes (direct or along the shore), portages round weirs, locks by policy, whitewater by boat, gaps marked. Found portages and locks become points of their own; an unplannable leg says why and offers a way out. - Shaping points: a click on the line sets a point that steers the route without being a stop (hikes and paddle tours); recompute a single leg. - Lake style direct/shore, suggested from the wind forecast. - Regions load by themselves where a paddler plans (admin setting: automatic, on request, off; size cap and a daily count), with requests for the admins, a notification, and the load followed on the leg. - Portage from the last point, portages follow footways via the walking router (or stay straight), "put in here" on slipways and put-ins. - MCP plan_paddle_route with the REST route's rules.
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import {
|
|
estimatePaddleTime,
|
|
paddleLayoutOfPoints,
|
|
paddleRolesOf,
|
|
type PaddlePlanPoint,
|
|
type PaddleRole,
|
|
type PaddleTimeEstimate,
|
|
} from '@trek/shared';
|
|
import type { TourPlannerWaypoint } from './tourPlannerWaypoints';
|
|
|
|
/** 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), with the routed length of each
|
|
* leg where the router planned it (PAD-11). 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,
|
|
legLengths?: ReadonlyArray<number | null>
|
|
): PaddleTimeEstimate {
|
|
return estimatePaddleTime(paddleLayoutOfPoints(paddlePlanPoints(points), legLengths), {
|
|
paddleSpeedKmh: speedInvalid ? null : paddle.effectiveSpeedKmh,
|
|
portageSpeedKmh: paddle.portageSpeedKmh,
|
|
breakMinutes: null,
|
|
});
|
|
}
|