Repository navigation
Description
Status: done
Size: S
Part of #3286 (round 2, after the owner's browser check).
Systems: route-planning
TL;DR
Goal: The list of route notes shows one row for a restriction that covers one stretch of road, such as a mountain pass that is closed in winter.
Problem: OpenStreetMap stores a pass road as many short pieces, and each piece carries the tag of the restriction. The planner makes one note for each piece. A route over one pass shows "20 things to check", with 19 rows of the same text within 14 km.
Decision: Notes with the same text that follow each other within 2 km become one row. The row shows where the restriction starts and ends, and a click shows all its pieces on the map. The seasonal text becomes shorter, so a row with only that text fits on one line. (Wireframe page https://claude.ai/artifact/HibXoqwkvZM9jHwdae1Ka7, question 1, option A. The owner chose the 2 km.)
Rejected:
- One row for each reason, which opens a second level: two passes far apart fall into one row.
- A row that names the road: the route answer carries no road name. It can follow as its own change.
Accepted limits: Only notes with exactly the same text merge; a piece that also needs a permit stays its own row. Two different roads with the same text and less than 2 km between them become one row. Alpine stretches merge by the same rule.
Words
- Route note: one row of the list "N things to check" in the side panel (
RouteNoteinbuilder/web/src/lib/planner/route-notes.ts). It comes from a gap (a point that the route does not reach), an access note (a stretch where the rider may have no access) or an alpine stretch.kmis where it starts along the route;lengthis the length of its stretch in km. A gap is a point and has nolength. - Piece: one stretch of route as
closureStretchesoralpineStretchesreturns it (Stretchinbuilder/web/src/lib/planner/route-closures.ts).
Facts
routeNotesinroute-notes.tsmakes one note for each gap, each access stretch and each alpine stretch, sorted bykm.noteKeynames a note by its icon,kmand label.edgeStretchesinroute-closures.tsalready joins route edges that touch. A stretch ends at an edge with no restriction, so a short piece of road without the tag splits one pass into many stretches.phrases.seasonalinroute-closures.tsgives "May be closed seasonally (Oct–May)". At the width of the side panel this text takes two lines.- A note has one line of coordinates.
highlightedinbuilder/web/src/components/planner/PlannerApp.sveltepassesshownNote?.coordinatesto the map, andPlannerMap.sveltedraws one line feature.highlightedalso carries the band of a night, which is one line. closureLabelbuilds the text of a stretch from the kinds and the conditions of its edges, so a piece that also needs a permit has another text than its neighbours.RouteNotes.svelteshows a row as "km 104.6 · 861 m" (noteDistanceformats the length).
Plan
route-notes.ts:RouteNote.coordinatesbecomes a list of lines (Coordinate[][]), one for each piece.routeNotesbuilds the notes as today and sorts them bykm. Then it merges: a note with alengthjoins the last earlier note that has the same icon and the same label, when it starts less than 2 km after the end of that note. Notes of another kind between the two do not stop the merge. A note withoutlength(a gap) never merges. The 2 km is one named constant with a comment that the owner chose it.- A merged note keeps the
kmof its first piece and its place in the order. It gets the new fieldend, the end of its last piece in km; a note of one piece has noend. Itslengthis the sum of its pieces. It holds the coordinates of all its pieces.noteKeydoes not change. List each other reader ofRouteNoteand oflengthin the pull request. RouteNotes.svelte: a row withendreads "km 104.6 – 118.3". A row withoutendstays "km 28.5 · 6 m". The count in the header is the number of rows, as it is.PlannerApp.svelteandPlannerMap.svelte: the highlight takes a list of lines and draws each. The band of a night is a list of one line.showNotefits the map to all pieces of the note.route-closures.tsphrases.seasonal: with conditions the text is "May be closed Oct–May" (several conditions joined with ", "); with no condition it stays "May be closed seasonally".phrases.conditionalkeeps its text, such as "May be closed (wet)". A stretch with both reads "May be closed Oct–May · May be closed (wet)". Update the example in the comment ofclosureLabel.- Tests:
route-notes.test.ts(two pieces 1.9 km apart merge and 2.1 km apart do not; a note of another kind between two pieces does not stop the merge; two different labels do not merge; a gap does not merge;end,lengthand the coordinates of a merged note),route-closures.test.ts(the seasonal text alone and with a conditional closure),RouteNotes.svelte.test.ts(the row of a merged note). - Search
docs/contentanddocs/designfor the old seasonal text and for a description of the notes list, and update what is stale. A change ofdocs/contentis its owndocs:commit.
Done when
- From
builder/web:npx vitest run src/lib/planner/ src/components/planner/andnpm run check - In the running planner, a route over a pass that is closed in winter shows one row for the pass, and a click shows the whole closed stretch on the map.
Activity