feat(tours): route paddle tours on the water, shaping points and auto-loaded regions

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.
This commit is contained in:
Maurice
2026-10-18 01:13:24 +02:00
parent b76a298bb3
commit 1bc82f97fd
321 changed files with 14675 additions and 471 deletions
+2 -2
View File
@@ -44,8 +44,8 @@ describe('ALL_ENTITIES', () => {
* `entity-schema-parity.test.ts` can't see — it iterates the metadata map,
* which de-duplicates by class name).
*/
it('ENT-003: exactly 140 entities, every class name unique', () => {
expect(ALL_ENTITIES.length).toBe(140);
it('ENT-003: exactly 141 entities, every class name unique', () => {
expect(ALL_ENTITIES.length).toBe(141);
const names = ALL_ENTITIES.map((s) => s.meta.className);
expect(new Set(names).size).toBe(names.length);
});
@@ -31,7 +31,9 @@ import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest';
// + tour_obstacle_reviews: place_id, obstacle_key, decision, both fingerprints, obstacle_snapshot, decided_at.
// + trip_journal_links: id, trip_id, journey_id, created_at; trip_journal_link_members: link_id, user_id,
// added_at (a link and its members are always written whole).
const KNOWN_UNINITIALISED_NOT_NULL_SCALARS = 482;
// + paddle_water_graphs: file, rev, bytes, built_at, stats and its bounding box (a network is only ever written
// whole, from one build of its region).
const KNOWN_UNINITIALISED_NOT_NULL_SCALARS = 491;
describe('entity class fields never carry a NaN initialiser (task-4-review-shape.md, Important 1)', () => {
it('CLASSFIELD-001: new X() has no own property whose value is NaN, across all 133 entities', () => {
@@ -55,6 +55,10 @@ const UNNUMBERED = [
'Migration20200101044100_paddle_obstacles_from_openstreetmap',
'Migration20200101044200_a_paddle_tour_records_its_obstacle_decisions',
'Migration20200101044300_a_trip_links_a_journal',
'Migration20200101044400_a_paddle_region_builds_its_water_network',
'Migration20200101044500_a_tour_waypoint_can_shape_the_route',
'Migration20200101044600_a_paddle_tour_remembers_how_it_crosses_lakes',
'Migration20200101044700_paddle_water_data_loads_where_a_paddler_plans',
];
// The last step the positional runner ever had; planLegacyBaseline refuses a
// schema_version past it.
@@ -126,4 +126,16 @@ describe('TourWaypointsRepository', () => {
t.clear();
expect((await repo.listForPlace(place.id))[0]).toEqual({ lat: 47, lng: 11, role: 'start', sequence: 0 });
});
it('TWREPO-007: a shaping point is stored as such and read back; a stop carries no flag (P2A-03)', async () => {
const { place } = tourInTrip();
await repo.insertForPlace(place.id, [
{ lat: 47, lng: 11, role: 'start', sequence: 0 },
{ lat: 47.05, lng: 11.05, role: 'via', sequence: 1, shaping: true },
{ lat: 47.1, lng: 11.1, role: 'end', sequence: 2 },
]);
const points = await repo.listForPlace(place.id);
expect(points[1]).toEqual({ lat: 47.05, lng: 11.05, role: 'via', sequence: 1, shaping: true });
expect(points[0]).not.toHaveProperty('shaping');
});
});
@@ -96,6 +96,7 @@ describe('ToursRepository reads', () => {
water_context: null,
paddle_speed_kmh: null,
portage_speed_kmh: null,
paddle_lake_style: null,
track_marks: null,
has_recorded_track: 0,
},
@@ -123,6 +124,7 @@ describe('ToursRepository reads', () => {
water_context: null,
paddle_speed_kmh: null,
portage_speed_kmh: null,
paddle_lake_style: null,
track_marks: null,
has_recorded_track: 0,
},
@@ -206,6 +208,7 @@ describe('ToursRepository writes', () => {
water_context: null,
paddle_speed_kmh: null,
portage_speed_kmh: null,
paddle_lake_style: null,
track_marks: null,
has_recorded_track: 0,
});
@@ -218,6 +221,7 @@ describe('ToursRepository writes', () => {
water_context: null,
paddle_speed_kmh: null,
portage_speed_kmh: null,
paddle_lake_style: null,
};
it('TOURREPO-007: updateInTrip replaces the metrics of a tour of that trip and refuses one of another trip', async () => {
@@ -283,6 +287,7 @@ describe('ToursRepository writes', () => {
water_context: null,
paddle_speed_kmh: null,
portage_speed_kmh: null,
paddle_lake_style: null,
track_marks: null,
},
]);
@@ -1,10 +1,11 @@
import { ToursBoatType, ToursWaterContext } from '../../../src/db/entities/Tours.entity';
import { paddleBoatTypeSchema, paddleWaterContextSchema } from '@trek/shared';
import { ToursBoatType, ToursPaddleLakeStyle, ToursWaterContext } from '../../../src/db/entities/Tours.entity';
import { paddleBoatTypeSchema, paddleLakeStyleSchema, paddleWaterContextSchema } from '@trek/shared';
import { describe, expect, it } from 'vitest';
/**
* The boat and water columns hold a CHECK list (migration 043900) that the
* The boat, water and lake style columns hold a CHECK list (migrations 043900
* and 044600) that the
* entity carries as its enum, and the contract holds its own list. A value
* one side knows and the other refuses would be a tour the planner can save
* and the database cannot store, or the other way round.
@@ -17,4 +18,8 @@ describe('paddle columns match the contract', () => {
it('knows the same waters as the paddle contract', () => {
expect(Object.values(ToursWaterContext).sort()).toEqual([...paddleWaterContextSchema.options].sort());
});
it('knows the same lake styles as the paddle contract (PAD-11)', () => {
expect(Object.values(ToursPaddleLakeStyle).sort()).toEqual([...paddleLakeStyleSchema.options].sort());
});
});