diff --git a/README.md b/README.md index 30bb0c3..3b67490 100644 --- a/README.md +++ b/README.md @@ -235,59 +235,37 @@ Click **⚙ Preferences** in the top bar: ## Directions & Routing -The flow is: pick an **origin**, open **Directions**, pick a **destination**, -then **Calculate**. +Everything starts from the map. Clicking one spot opens a **context dialog**; +no click ever saves or routes automatically. -1. **Pick the origin (start point)** — select any POI from **search**, or click - directly on the map. (Clicking empty space creates a browser-local *Saved - Point* and uses it as the origin.) -2. The **Directions** button in the top bar is enabled only when an origin is - selected. -3. In the dialog, pick a **destination** — by clicking the map, **searching** a - POI (local or online via Nominatim), or choosing a **Saved Point**. -4. **Calculate route** enables once both points are set. The computation runs in +- **Clicking an existing point** (a POI/zone/path, or a Saved Point) shows its + info and offers **"Directions from here"** - which sets it as the origin and + opens the destination picker - plus **"Directions to here"** once an origin + is set. +- **Clicking empty space** shows a **"Save point..."** form (with an optional + label) to save it as a browser-local Saved Point, or the same + "Directions from here" action. + +From the opened **Directions** panel: + +1. **Origin** is already set (from "Directions from here"). Pick a + **destination** - by clicking another point (and choosing + "Directions to here"), **searching** a POI (local or online via Nominatim), + or choosing a **Saved Point**. +2. **Calculate route** enables once both points are set. The computation runs in a **Web Worker** (off the UI thread) with a live **progress bar**. -5. On completion the panel shows the **turn-by-turn** directions (*Head north*, - *Turn right*, *Arrive at destination*, …) for **Drive** mode, plus distance, +3. On completion the panel shows the **turn-by-turn** directions (*Head north*, + *Turn right*, *Arrive at destination*, ...) for **Drive** mode, plus distance, estimated travel time, and the drawn route. -Other behaviors: - -- **Route options** (collapsed): **avoid certain POI categories** (schools, fire - stations, fuel stations, parking, restaurants, …) and choose the **travel - mode** (Drive / Walk). -- **Robustness:** if the origin/destination are far from the routable road - network, or the destination is disconnected / fully blocked by avoided - categories, the app reports *why* and still draws the **closest reachable** - portion of a route (flagged as a partial path) instead of failing silently. -- **On-demand layer loading:** if the road-data layer needed for routing isn't - loaded, the dialog prompts you to load it ("Road data layer needed for route - computation") rather than silently disabling. - -Routing is done **entirely in the browser** (`src/lib/routing.ts`, invoked from -`src/lib/routing.worker.ts`): an A*-search over the graph built from the OSM -dump. Points are snapped to the nearest graph node. When you enable a category -to avoid, edges within a radius of POIs in that category are heavily penalized -(or blocked) so the route routes around them. - -```ts -import { route } from '$lib/routing'; -const r = route(graph, [latA, lonB], [latB, lonB], pois, [ - { category: 'amenity', value: 'school', radiusM: 300, block: true } -]); -// r.found, r.path ([[lat,lon],...]), r.distanceM -// r.partial (best-effort partial route when the destination is unreachable), -// r.fromSnapM / r.toSnapM (distance from A/B to nearest road), -// r.reason (human explanation when no full route exists), -// r.turns (turn-by-turn steps for driving mode) -``` - ## Saved Points (browser-local) -Clicking an empty spot on the map creates a **Saved Point** — a location you -want to remember. Saved points are stored only in your browser's `localStorage` -and shown as a toggleable **"Saved Points"** layer in the legend, with a -distinct purple pin. They can be used as route origins or destinations. +Clicking an empty spot on the map opens a **context dialog** with a +**"Save point..."** button (plus an optional label). Saving creates a +**Saved Point** — a location you want to remember. Saved points are stored only +in your browser's `localStorage` and shown as a toggleable **"Saved Points"** +layer in the legend, with a distinct purple pin. They can be used as route +origins or destinations. Because they live only in the browser, **Export / Import** (in ⚙ Preferences) lets you back them up as a JSON file and restore them (merged, deduplicated by