Repository navigation
Description
Status: done
Part of #3652 (step 1). Read the epic first: its Facts on routing and "The screen" (the points about no_snap and no_path).
TL;DR
Goal: A long plan routes with two requests at a time, a point far from a road is left out with a note, a leg with no legal path becomes a remembered gap, and a line with a gap never goes to the bike computer.
Problem: The route requests of a long plan go one after the other (9.2 s for the 64-day cycling test plan), and one point that the service cannot reach, or one leg with no legal path, gives no line at all.
Decision: At most 2 requests in flight; joins checked after the answers; the service names the bad point or leg in its error answer; the leg cache passes the index on; calculateLine drops a no_snap point and makes a no_path leg a cached gap leg; today's sync refuses a line with a gap leg.
Systems: route-planning, routing, web-planner
Contracts: specs/route-api.md Errors (fields point and leg)
Size: M (3 systems, a compatible contract change, about 550 lines)
Facts
-
LegCache.route(builder/web/src/lib/planner/route-legs.ts:81-127) sends the chunks of a gap one after the other, each pinned to the end of the chunk before. On a failed join it clears the whole cache and starts again (:105-109, meant for a new routing package). Onno_pathunder a pin it widens the chunk by one leg on each side, then sends the whole run again (:113-123). -
post(routing.ts:100-115), whichrequestRoute(:136-138) calls, throws an error with the service'scodeonly. -
calculateLine(routing.ts:182-) builds an expanded point list for each run of routed legs: a detour adds 3 points (anchor, place, anchor) and a turnaround (routing.ts:247-251);endsmaps the index of the leg that ends at a plan point to that point ids. -
gapNote(route-gaps.ts:30-40) gives, for one point: "Route starts ‹d› from the selected point", "Route ends ‹d› before the selected point" or "Route passes ‹d› from the selected point", each followed by " — no accessible path"; for several points "Route misses ‹n› selected points by up to ‹d› — no accessible path". The note row has no Show button (PlannerApp.svelte:1224-1226). -
unknownElevationKm > 0hides the ascent (PlannerApp.svelte:1222,DayRow.svelte:55);unroutedKm > 0drops the riding times from search requests (search/plan.ts:39). -
Error::NoPathis used atplanner/router/src/router.rs:304,:309,:315,planner/router/src/alternatives.rs:49,:112andplanner/router-build/tests/routing.rs:287. -
Measurement (throwaway edit: only the two-at-a-time change of this issue, plus the profile slice edit that changes memory and not routing; 64-day cycling test plan, search off, 3 loads each, terrain run active, load average 5 to 8):
Route requests From the first route request to the last answer Requests Map quiet One after the other, as today 9.2 s (8.4, 9.2, 9.4) 6 21.1 s Two at a time, bad joins sent again 5.1 s (4.9, 5.1, 6.2) 9 14.4 s 3 of the 5 joins between chunks landed on another road position in every load and went out again. The rest of the time to a quiet map is the night search of every night, which Planner: a strip of all days and a week in focus for trips of 15 days or more #3712 limits to the week.
Plan
- Service.
planner/router/src/lib.rs:40:Error::NoPathbecomesNoPath(usize), the leg index in the request: set it in the leg loop ofrouter.rs:303-304(the loop takes one leg a step), at:309the last leg, and at:315the legindexthat the loop there knows. The other matches takeNoPath(_)(alternatives.rs:49,:112,router-build/tests/routing.rs:287).planner/service/src/lib.rs(error_body): theno_snapanswer gets"point": <index from 0>, theno_pathanswer"leg": <index from 0>.specs/route-api.mdErrors: "An error answer is{"code", "message"}; ano_snapanswer also haspoint, the index of the point, from 0; ano_pathanswer also hasleg, the index of the leg from 0, between pointlegandleg + 1." post(routing.ts:115): the thrown error also carriespointandlegfrom the body.LegCache.route(route-legs.ts):- The chunks of a gap go out with at most 2 requests in flight. The first chunk is pinned to the cached leg before it, the last to the cached leg after it; chunks between are not pinned. Each answer is kept in the cache as it arrives. When a request fails, no new chunk starts; the one in flight finishes and is kept; then the error goes up. An abort (the rider edits) stops both; kept answers stay for the next calculation.
- After the answers, the join check (
:87) runs over the gap again: a leg that does not join its neighbour becomes missing and goes out as a one-leg request pinned at both ends. The cache restarts from empty only when a new answer has anotherpackagethan its neighbour (:105); a join that fails with the same package is such a re-request, never a restart. - An error with
pointorleggoes up with the index changed to an index intopoints(the chunk'sfromadded).no_pathon the first leg of a chunk pinned at its start, or the last leg of a chunk pinned at its end, goes out once more without that pin (one leg wider on that side); if it fails again, the error goes up. The whole-run fallback (whole = true) goes. - A gap leg is cached like a routed leg (
gap: true, a straight geometry from its start to its end point, no heights, no edges, 0 s, no package). It joins any neighbour, and a neighbour of a gap leg is not pinned to it. So later edits elsewhere send no request for it; a move of one of its two points changes its key and routes it again.
calculateLine(routing.ts):no_snapat expanded index i: the plan point of i (throughends, or the place of a detour) goes into a set of left-out points, and the run is built and routed again without it; turnaround indexes are counted again on the new list. When the point is a start or a finish, or the end of a run beside a drawn or transfer leg (a drawn leg must keep its join), it is not left out: the routed legs at it become gap legs. A detour whose place fails is left out as a whole (anchor, place, anchor). The line lists the left-out points;routeGapsmeasures the miss from the line to each.no_pathat leg k: that leg is a gap leg in the cache (above), and the run routes again around it.RoutingLinegetsgapLegs: string[]: the ids of the plan points at which a gap leg ends (aslegEndId).daySegmentsgives these segmentsleg: 'gap'; the map draws them withtrip-gap(PlannerMap.svelte:270).- A gap leg's straight length counts in the distance (
appendmeasures its geometry); it adds no time and no climb, and it does not count inunroutedKm,unknownSurfaceKmorunknownElevationKm. So the distance holds the gap as a straight line, the time and the climb hold only the routed parts, the climb stays visible, and search keeps its times. That is honest: the note says a part is missing and how it is counted.
- Notes (
route-gaps.ts, the note row atPlannerApp.svelte:1224-1226): a left-out point gives today'sgapNotetext ("Route passes 1.2 km from the selected point — no accessible path"). A gap leg gives "No legal path between 2 points" (several: "2 legs have no legal path"). The row gets Show / Next / Hide as the closure rows (showNext), stepping through the points and gap legs. On planner: less text, clear controls, a night picker that follows the stay kinds, no route alternatives (#3286) #3338 the row goes into the list of things to check. - Sync (
device-sync/sync.ts, aftercalculateLine,:126): a line withgapLegs.length > 0does not go; the plan stays inwaiting;problemgets "“‹name›” waits: 1 leg has no legal path. Change it in the planner." (plural "‹n› legs have"). A left-out point does not block: the line is complete without it. - Comment at
gpx-import.ts:50: the import shapes lines one at a time; a page routes with two requests at a time, which the service takes because a request waits up to 1 s for a worker beforebusy(planner/service/src/http.rs:24).
Tests
builder/web/src/lib/planner/routing.test.ts:
- Replace "sends the chunks one after the other, each pinned to the end of the chunk before" (
:252) with: two chunks are in flight at once; a bad join goes out again as one leg pinned at both ends; a join with another package restarts once. - Replace "sends a gap without a path again with one more leg on each side, not the whole run" (
:288) and "fails a run without cached legs after the widened request, not after the whole run again" (:314) with: ano_pathleg in the middle becomes a gap at once; a second calculation after an edit elsewhere sends no request for it. - Replace "sends a chunk without a path under the pin of the chunk before again from one leg earlier" (
:303-312, it pins chunk 2 to chunk 1, which no longer happens) with: a first chunk, pinned to a cached leg before it, that fails withno_pathon its first leg goes out once more one leg wider without that pin; if that fails too, the leg is a gap. - Change "keeps each chunk as it arrives; a failure or an abort stops the chunks after it" (
:334): with two in flight, the answer in flight is kept and no new chunk starts. - New: a
no_snapshaping point is left out and listed; ano_snapdetour place leaves out the detour; ano_snappoint beside a drawn leg gives gap legs.
builder/web/src/lib/device-sync/sync.test.ts: a plan whose line has a gap leg waits, with the sentence.
planner/service/src/lib.rstests: theno_snapbody haspoint, theno_pathbody hasleg.
Proof
The speed run of this change alone:
- Setup on the build PC, in
/media/timo/OSM1/tmp/explore-3506/long-trips-design/tools/:run.sh(local route service with 2 workers, the catalogue proxy with search off, the vite page of the worktree inW) andspeed.mjs(3 loads of the stored 64-day cycling planbike-64.jsonat 1920 × 1080; it writesrouteMs, from the first route request to the last answer, and the request count). In your worktree only, never committed, add by hand three of the four edits thatexp.pydescribes (not the night edit, which belongs to Planner: a strip of all days and a week in focus for trips of 15 days or more #3712):maxRidingDays = 64, theobc:idlemark inPlannerMap.svelte, and the profile slice edit ofexp-profile.py(memory only). Runobc suites preparein the worktree first. Do not runexp.pyin a worktree with your change: it resetsbuilder/web/srcfirst. - Command:
/media/timo/OSM1/tmp/explore-3506/tools/heavy.sh $T env W=<your worktree> $T/run.sh "flock /tmp/trailview-gpu.lock timeout 280 tools/obc exec node $T/speed.mjs step1 bike-64 64 3"withTthe tools folder. Say in the pull request whether the terrain run was active and the load average. - Pass: median
routeMs6.0 s or less (today 9.2 s; the experiment gave 5.1 s). Re-requested joins = requests − 6; write the three times and that count into the pull request.
Checks
obc test -p planner-router,obc test -p planner-router-build,obc test -p planner-service, andobc exec cargo clippy -p <crate> --all-targets -- -D warningsfor each.- In
builder/web:npx vitest run src/lib/planner/routing.test.ts src/lib/planner/route-gaps.test.ts src/lib/device-sync/sync.test.ts, thennpm run check.
Limits
- The Route page (
pages/Route.svelte:89) and the signed-route page (Signed.svelte:135) show a gap leg as a plain line with no note; their GPX and FIT export write it as a straight segment. - A plan with a gap counts the gap's straight length in its distance, and no time and no climb for it.
Done when
- The checks pass, and the proof is in the pull request.
- The owner's check runs on the pull request's head, served on the build PC as in the Proof setup (the vite page of the worktree with the local route service; the orchestrator gives him the address). He opens the 32-day cycling test plan: pass when its line shows (the speed is the measured proof above, not his check). He opens a copy with one shaping point moved 2 km away from any road and one leg between two points with no legal path (for example a point on the other side of a lake with no road around it, or a point on a motorway for the hiking profile): pass when the route goes past the first point with the note "Route passes 2.0 km from the selected point — no accessible path" (about that distance) and Show moves the map there, and the leg is a dashed straight line with the note "No legal path between 2 points"; fail when the line is missing or the whole plan says it cannot route.
Public docs: no change.
Activity
timohueser commentedon Nov 19, 2026
The owner's check passed on the sheet of the built planner (the 32-day plan with its whole line, the point 2 km off the roads with its note and Show, the leg with no legal path as a dashed line): "Yes, merge it".
Generated by Claude Code