Skip to content

Planner route notes: one row for neighbouring stretches #3368

Closed

Description

@timohueser

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 (RouteNote in builder/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. km is where it starts along the route; length is the length of its stretch in km. A gap is a point and has no length.
  • Piece: one stretch of route as closureStretches or alpineStretches returns it (Stretch in builder/web/src/lib/planner/route-closures.ts).

Facts

  • routeNotes in route-notes.ts makes one note for each gap, each access stretch and each alpine stretch, sorted by km. noteKey names a note by its icon, km and label.
  • edgeStretches in route-closures.ts already 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.seasonal in route-closures.ts gives "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. highlighted in builder/web/src/components/planner/PlannerApp.svelte passes shownNote?.coordinates to the map, and PlannerMap.svelte draws one line feature. highlighted also carries the band of a night, which is one line.
  • closureLabel builds 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.svelte shows a row as "km 104.6 · 861 m" (noteDistance formats the length).

Plan

  1. route-notes.ts: RouteNote.coordinates becomes a list of lines (Coordinate[][]), one for each piece. routeNotes builds the notes as today and sorts them by km. Then it merges: a note with a length joins 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 without length (a gap) never merges. The 2 km is one named constant with a comment that the owner chose it.
  2. A merged note keeps the km of its first piece and its place in the order. It gets the new field end, the end of its last piece in km; a note of one piece has no end. Its length is the sum of its pieces. It holds the coordinates of all its pieces. noteKey does not change. List each other reader of RouteNote and of length in the pull request.
  3. RouteNotes.svelte: a row with end reads "km 104.6 – 118.3". A row without end stays "km 28.5 · 6 m". The count in the header is the number of rows, as it is.
  4. PlannerApp.svelte and PlannerMap.svelte: the highlight takes a list of lines and draws each. The band of a night is a list of one line. showNote fits the map to all pieces of the note.
  5. route-closures.ts phrases.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.conditional keeps 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 of closureLabel.
  6. 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, length and 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).
  7. Search docs/content and docs/design for the old seasonal text and for a description of the notes list, and update what is stale. A change of docs/content is its own docs: commit.

Done when

  • From builder/web: npx vitest run src/lib/planner/ src/components/planner/ and npm 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions