Skip to content

Planner: name the start and the finish after the nearest town #3292

Closed

Description

@timohueser

Status: done
Size: S
Part of #3286. Depends on #3287.
Systems: route-planning

TL;DR

Goal: A start or a finish that the rider sets on a bare spot of the map takes the name of the nearest town or village, so a plan is titled "Sempach → Andermatt".
Problem: Such a point is named "Start" or "Finish", so every plan is titled "Start → Finish".
Decision: The name comes from the two lookups that the planner already uses for the arrival point of a train: first the loaded map tiles (placeName, within 5 km), then the search (townName, within 3 km). With no town in reach, the point keeps "Start" or "Finish". (Review page, finding 11.)

Plan

  1. builder/web/src/lib/planner/editor.ts setEndpoint: without a label, the new point gets autoLabel: true and the label "Start" or "Finish". With a label, autoLabel stays unset.
  2. builder/web/src/lib/planner/plan-session.svelte.ts: move the last lines of nameVisit, which write a found name into the open history step with no Undo step, into a method autoName(id: string, coordinate: Coordinate, label: string). It keeps the guard of nameVisit: it writes only when the session is open and the point still has autoLabel and the same coordinate. So a late answer never names a point that moved, or a point of another plan. nameVisit calls it.
  3. builder/web/src/components/planner/PlannerApp.svelte: add nameEndpoint(point). For a point of the kind start or finish with autoLabel, it takes map?.placeName(point.coordinate) ?? await townName(point.coordinate) and, when a name comes, calls session.autoName. nameVisits calls it for the endpoints too, and chooseEndpoint calls it after the commit.
  4. movedPoint in plan-session.svelte.ts: a moved start or finish with autoLabel gets the label "Start" or "Finish" again, not its coordinate. movePoint in PlannerApp.svelte is the only caller of session.movePoint; it calls nameEndpoint beside its call of session.nameVisit. Undo and redo call neither. A point named after a place keeps that name when it moves, as it does today.
  5. startLoopAt in editor.ts: unnamed is old.autoLabel || old.label === shapeLabel, because "Start" is no longer the only label of an unnamed start.
  6. Tests: editor.test.ts for setEndpoint and startLoopAt; plan-session.test.ts for autoName and the moved endpoint.

Done when

  • From builder/web: npx vitest run src/lib/planner/ src/components/planner/ and npm run check
  • In the running planner, a start set on a street in a village and a finish set near another give a title with both village names.

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