docs: document context-dialog interaction; correct Saved Points flow
All checks were successful
CI / test-and-build (push) Successful in 42s
All checks were successful
CI / test-and-build (push) Successful in 42s
This commit is contained in:
parent
80d049eebf
commit
b442e1ef44
72
README.md
72
README.md
@ -235,59 +235,37 @@ Click **⚙ Preferences** in the top bar:
|
|||||||
|
|
||||||
## Directions & Routing
|
## Directions & Routing
|
||||||
|
|
||||||
The flow is: pick an **origin**, open **Directions**, pick a **destination**,
|
Everything starts from the map. Clicking one spot opens a **context dialog**;
|
||||||
then **Calculate**.
|
no click ever saves or routes automatically.
|
||||||
|
|
||||||
1. **Pick the origin (start point)** — select any POI from **search**, or click
|
- **Clicking an existing point** (a POI/zone/path, or a Saved Point) shows its
|
||||||
directly on the map. (Clicking empty space creates a browser-local *Saved
|
info and offers **"Directions from here"** - which sets it as the origin and
|
||||||
Point* and uses it as the origin.)
|
opens the destination picker - plus **"Directions to here"** once an origin
|
||||||
2. The **Directions** button in the top bar is enabled only when an origin is
|
is set.
|
||||||
selected.
|
- **Clicking empty space** shows a **"Save point..."** form (with an optional
|
||||||
3. In the dialog, pick a **destination** — by clicking the map, **searching** a
|
label) to save it as a browser-local Saved Point, or the same
|
||||||
POI (local or online via Nominatim), or choosing a **Saved Point**.
|
"Directions from here" action.
|
||||||
4. **Calculate route** enables once both points are set. The computation runs in
|
|
||||||
|
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**.
|
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*,
|
3. On completion the panel shows the **turn-by-turn** directions (*Head north*,
|
||||||
*Turn right*, *Arrive at destination*, …) for **Drive** mode, plus distance,
|
*Turn right*, *Arrive at destination*, ...) for **Drive** mode, plus distance,
|
||||||
estimated travel time, and the drawn route.
|
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)
|
## Saved Points (browser-local)
|
||||||
|
|
||||||
Clicking an empty spot on the map creates a **Saved Point** — a location you
|
Clicking an empty spot on the map opens a **context dialog** with a
|
||||||
want to remember. Saved points are stored only in your browser's `localStorage`
|
**"Save point..."** button (plus an optional label). Saving creates a
|
||||||
and shown as a toggleable **"Saved Points"** layer in the legend, with a
|
**Saved Point** — a location you want to remember. Saved points are stored only
|
||||||
distinct purple pin. They can be used as route origins or destinations.
|
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)
|
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
|
lets you back them up as a JSON file and restore them (merged, deduplicated by
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user