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
@@ -0,0 +1,34 @@
import { Migration } from '@mikro-orm/migrations';
/**
* PAD-11: the water network a paddle region builds for routing, from the same
* read as its obstacles. The network itself is a file in the data folder
* (`file`, named after its revision `rev`, the first hex digits of its
* hash); the row says where it is, how big it came out, when it was built,
* what it holds (`stats`, JSON: kilometres of water, lakes, portages, gaps,
* locks) and the box it covers, so a point finds its network without reading
* the region. One row per region, gone with the region.
*/
export class Migration20200101044400_a_paddle_region_builds_its_water_network extends Migration {
override name = 'Migration20200101044400_a_paddle_region_builds_its_water_network';
override up(): void {
this.addSql(`
CREATE TABLE IF NOT EXISTS paddle_water_graphs (
region_id TEXT PRIMARY KEY REFERENCES paddle_regions(id) ON DELETE CASCADE,
file TEXT NOT NULL,
rev TEXT NOT NULL,
bytes INTEGER NOT NULL,
built_at DATETIME NOT NULL,
stats TEXT NOT NULL,
min_lat REAL NOT NULL,
min_lng REAL NOT NULL,
max_lat REAL NOT NULL,
max_lng REAL NOT NULL
)
`);
this.addSql(
`CREATE INDEX IF NOT EXISTS idx_paddle_water_graphs_box ON paddle_water_graphs (min_lat, max_lat, min_lng, max_lng)`,
);
}
}
@@ -0,0 +1,14 @@
import { Migration } from '@mikro-orm/migrations';
/**
* P2A-03: a waypoint can be a shaping point, there only to steer the route:
* no stop, no place to get in or out, nothing a day plan shows. 0 or 1;
* every waypoint saved before is a stop, as it was.
*/
export class Migration20200101044500_a_tour_waypoint_can_shape_the_route extends Migration {
override name = 'Migration20200101044500_a_tour_waypoint_can_shape_the_route';
override up(): void {
this.addSql(`ALTER TABLE tour_waypoints ADD COLUMN shaping INTEGER NOT NULL DEFAULT 0 CHECK (shaping IN (0, 1))`);
}
}
@@ -0,0 +1,16 @@
import { Migration } from '@mikro-orm/migrations';
/**
* PAD-11: how a paddle tour crosses its lakes, as the router planned it:
* `direct` (straight over, also what NULL means) or `shore` (along the
* shore, for wind). Kept with the tour so it routes the same when opened again.
*/
export class Migration20200101044600_a_paddle_tour_remembers_how_it_crosses_lakes extends Migration {
override name = 'Migration20200101044600_a_paddle_tour_remembers_how_it_crosses_lakes';
override up(): void {
this.addSql(
`ALTER TABLE tours ADD COLUMN paddle_lake_style TEXT CHECK (paddle_lake_style IS NULL OR paddle_lake_style IN ('direct', 'shore'))`,
);
}
}
@@ -0,0 +1,35 @@
import { Migration } from '@mikro-orm/migrations';
/**
* PAD-11C: TREK fetches the water data of a place a paddler plans in by
* itself. `paddle_regions.origin` says who added a region: an admin by hand
* (`admin`, every region before this) or TREK for a paddler (`auto`), which
* also counts against the few a day it may add.
*
* `paddle_region_requests` holds a region that waits for an admin instead:
* the mode asks for it, it is larger than allowed or the day's few are used
* up (`reason`). It keeps the size Geofabrik announced, the name of whoever
* asked (as it read then; no link to the account, a request outlives it) and
* when, and whether an admin declined it (then it is not asked for again). A
* request goes once its region is added.
*/
export class Migration20200101044700_paddle_water_data_loads_where_a_paddler_plans extends Migration {
override name = 'Migration20200101044700_paddle_water_data_loads_where_a_paddler_plans';
override up(): void {
this.addSql(
`ALTER TABLE paddle_regions ADD COLUMN origin TEXT NOT NULL DEFAULT 'admin' CHECK (origin IN ('admin', 'auto'))`,
);
this.addSql(`
CREATE TABLE IF NOT EXISTS paddle_region_requests (
region_id TEXT PRIMARY KEY NOT NULL,
name TEXT NOT NULL,
reason TEXT NOT NULL CHECK (reason IN ('ask', 'too_large', 'limit')),
bytes INTEGER,
requested_by TEXT,
requested_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
declined_at DATETIME
)
`);
}
}