feat(trail-edit): colour track and profile by metric, toggle profile (#49) #59

Closed
maximus wants to merge 0 commits from feat/49-map-profile-colouring into deploy
Member

Part 1 of #49 (trail editor): the Elevation / pace profile and Track line items. Doesn't close #49.

Stacked on PR #58 (feat/49-map-layout). Until that merges, this diff also contains its commit, so review only the last two commits: feat(trail-edit): colour track and profile by metric… and …colour the track line by gradient by default.

#49 checklist items covered

  • Toggle the profile. A visible map control (chart icon, also P) shows or hides the elevation profile. The chart's own toggle button used a text-black icon that disappeared in dark mode; it now uses text-content. The stats overlay, the legend and the controls move with the profile's height.
  • Choosable colouring metric, independent per curve. A colour menu (palette button) has metric chips for the elevation curve and the pace curve separately: None, Gradient, Elevation, Speed, Pace. Each choice shows a preview strip of how it colours this route. Without a choice, other pages keep the chart's legacy |grade| palette exactly as it is.
  • Colour the track by a metric, with a legend. The same menu sets the track line metric. By default the line is coloured by gradient and the legend shows (Bear's call). A stored choice, including "None" for the plain violet line, is kept. Routes without elevation fall back to the plain line. The coloured line is a separate MapLibre layer on top of the route. Hover, click and drag still go to the route layer underneath, and its violet line shows as a thin edge. A legend appears on the map.
    • Speed and pace come from the pace engine's per-point output (pace_series, [segment start m, speed m/s], the same data the profile's pace curve uses). They need My pace → Estimate first; the menu says so.

Design

  • util/track_metrics.ts is a metric registry (TRACK_METRICS). Each metric maps the track to one class per point, plus legend classes (colour and label). The map line, both profile curves and the legend all use the same classes.
  • Gradient: a fixed, signed scale (descent blue → flat green → climb red; thresholds ±3/10/20 %).
  • Elevation, speed and pace: "nice" equal-interval classes over the route's own range. Speed and pace use the 5–95 % range, so one outlier doesn't flatten the scale. Units follow the metric/imperial setting.
  • Surface and way type (BRouter messages tags, #5) are not wired up. They can be added as categorical metrics: one more registry entry plus an optional field on TrackMetricContext. valhalla_store is untouched.
  • Choices are remembered per browser in localStorage. Defaults: track line = gradient; elevation and pace curves = gradient.
  • Follow-up (not in this PR, filed separately): the trail view switches to the same signed gradient scale once #56 and this PR are merged.

Note for #51 / #56

I didn't change the chart's legacy palette, but it is now exported as PROFILE_GRADE_COLOURS from vendor/maplibre-elevation-profile/elevationprofile.ts. #56's GRADE_PALETTE copy could import it instead, as a follow-up. The new signed gradient scale is GRADIENT_THRESHOLDS / GRADIENT_COLOURS in util/track_metrics.ts.

Tests

  • vitest track_metrics.test.ts (27 tests) covers:
    • classify/bucketing, nice thresholds, quantiles, palette sampling, legend labels
    • grade window, pace step lookup, position extraction
    • each metric's availability and colours (speed and pace colours agree)
    • the coloured line features, the hard gradient stops, and preference parsing
  • npm run check: 0 errors (2 warnings that were already there). Full vitest: 874 passed, plus the same unhandled rejection that was already there in trail_analyze.test.ts (not touched here).
  • The changed .svelte files compile with the Svelte compiler for both client and server.
  • Not checked visually in a browser: the browser broker couldn't reach wanderer.bearoverse.com.

🤖 Generated with Claude Code

Part 1 of #49 (trail editor): the **Elevation / pace profile** and **Track line** items. Doesn't close #49. **Stacked on PR #58** (`feat/49-map-layout`). Until that merges, this diff also contains its commit, so review only the last two commits: `feat(trail-edit): colour track and profile by metric…` and `…colour the track line by gradient by default`. ## #49 checklist items covered - [x] **Toggle the profile.** A visible map control (chart icon, also `P`) shows or hides the elevation profile. The chart's own toggle button used a `text-black` icon that disappeared in dark mode; it now uses `text-content`. The stats overlay, the legend and the controls move with the profile's height. - [x] **Choosable colouring metric, independent per curve.** A colour menu (palette button) has metric chips for the **elevation curve** and the **pace curve** separately: None, Gradient, Elevation, Speed, Pace. Each choice shows a preview strip of how it colours this route. Without a choice, other pages keep the chart's legacy |grade| palette exactly as it is. - [x] **Colour the track by a metric, with a legend.** The same menu sets the **track line** metric. **By default the line is coloured by gradient and the legend shows** (Bear's call). A stored choice, including "None" for the plain violet line, is kept. Routes without elevation fall back to the plain line. The coloured line is a separate MapLibre layer on top of the route. Hover, click and drag still go to the route layer underneath, and its violet line shows as a thin edge. A legend appears on the map. - Speed and pace come from the pace engine's per-point output (`pace_series`, `[segment start m, speed m/s]`, the same data the profile's pace curve uses). They need **My pace → Estimate** first; the menu says so. ## Design - `util/track_metrics.ts` is a metric registry (`TRACK_METRICS`). Each metric maps the track to one class per point, plus legend classes (colour and label). The map line, both profile curves and the legend all use the same classes. - Gradient: a fixed, signed scale (descent blue → flat green → climb red; thresholds ±3/10/20 %). - Elevation, speed and pace: "nice" equal-interval classes over the route's own range. Speed and pace use the 5–95 % range, so one outlier doesn't flatten the scale. Units follow the metric/imperial setting. - Surface and way type (BRouter `messages` tags, #5) are **not** wired up. They can be added as categorical metrics: one more registry entry plus an optional field on `TrackMetricContext`. `valhalla_store` is untouched. - Choices are remembered per browser in localStorage. Defaults: track line = gradient; elevation and pace curves = gradient. - Follow-up (not in this PR, filed separately): the trail view switches to the same signed gradient scale once #56 and this PR are merged. ## Note for #51 / #56 I didn't change the chart's legacy palette, but it is now exported as `PROFILE_GRADE_COLOURS` from `vendor/maplibre-elevation-profile/elevationprofile.ts`. #56's `GRADE_PALETTE` copy could import it instead, as a follow-up. The new signed gradient scale is `GRADIENT_THRESHOLDS` / `GRADIENT_COLOURS` in `util/track_metrics.ts`. ## Tests - vitest `track_metrics.test.ts` (27 tests) covers: - classify/bucketing, nice thresholds, quantiles, palette sampling, legend labels - grade window, pace step lookup, position extraction - each metric's availability and colours (speed and pace colours agree) - the coloured line features, the hard gradient stops, and preference parsing - `npm run check`: 0 errors (2 warnings that were already there). Full vitest: 874 passed, plus the same unhandled rejection that was already there in `trail_analyze.test.ts` (not touched here). - The changed `.svelte` files compile with the Svelte compiler for both client and server. - Not checked visually in a browser: the browser broker couldn't reach wanderer.bearoverse.com. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(trail-edit): centre on the user, maximise map, stats overlay, colour (#49)
All checks were successful
CI / web (push) Successful in 1m45s
CI / go (push) Successful in 14m21s
f9017fad02
Map and layout items of #49 on the trail editor:

- Centre a new trail on the user's position. MapLibre's GeolocateControl
  cannot be triggered before its async setup finishes, so the existing
  autoGeolocateOnDrawing call did nothing on load (and later switched the
  map into tracking mode on every "Edit route"). A one-shot helper now asks
  the browser once, jumps there unless the user already moved the map or
  started a route, and caches the last fix for an instant first view.
- Maximise the map: a map control (and the F key, Esc to leave) expands the
  map over the whole page, top bar and sidebar included.
- Stats overlay: distance, D+, D- and estimated time (personal pace when
  estimated, else the router's) as coloured tiles on the map while the
  sidebar is hidden or the map is maximised.
- Design: the same stat tiles in the sidebar, accent-coloured section
  headings and a tinted pace panel, all on Tailwind palette tones with
  light and dark variants.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EGfBC9xbQ6rjD6HxgP
feat(trail-edit): colour track and profile by metric, toggle profile (#49)
Some checks failed
CI / go (push) Has been cancelled
CI / web (push) Has been cancelled
88c68b0ed2
Elevation/pace profile and track-line items of #49:

- Track metrics module (util/track_metrics.ts): per-point elevation,
  signed gradient (centred distance window) and speed/pace from the pace
  engine's pace_series, bucketed into classes with a colour and a legend
  label each. Metrics are a registry (TRACK_METRICS), so categorical ones
  such as surface or way type (BRouter segment tags, #5) plug in later.
- Track line: a coloured overlay layer on top of the editor's route
  (interactions stay on the route layer underneath), with a legend on the
  map. Speed and pace need a personal pace estimate.
- Profile: the elevation and the pace curve are coloured by independently
  chosen metrics; without a choice the chart keeps its legacy |grade|
  palette (now exported as PROFILE_GRADE_COLOURS for #51/#56 to share).
- Toggle the profile from a visible map control (and P); the stats overlay,
  legend and controls follow the profile's height. The chart's own button
  icon now follows the theme (it was black on dark glass).
- Colour menu with metric chips per target and a preview strip of how the
  metric colours this route; choices are remembered per browser.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EGfBC9xbQ6rjD6HxgP
feat(trail-edit): colour the track line by gradient by default (#49)
All checks were successful
CI / web (push) Successful in 59s
CI / go (push) Successful in 13m14s
c2218663d2
Bear's call on #59: the editor's track line starts coloured by gradient,
with its legend, instead of the plain violet line. A stored choice
(including "None") is kept. The palette button is now highlighted only
while its menu is open, since a metric is nearly always active.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XMf4EGfBC9xbQ6rjD6HxgP
Author
Member

Shipped via batch PR #64 (deploy 0d0d85a4), which merged this branch head unchanged; live since 2026-11-05 ~19:30 CET in wanderer-web:deploy-676a7c62 (homelab-flux #843). Forgejo does not mark stacked PRs as merged, so I am closing this by hand.

🤖 Generated with Claude Code

Shipped via batch PR #64 (`deploy` 0d0d85a4), which merged this branch head unchanged; live since 2026-11-05 ~19:30 CET in `wanderer-web:deploy-676a7c62` (homelab-flux #843). Forgejo does not mark stacked PRs as merged, so I am closing this by hand. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
maximus closed this pull request 2026-11-05 19:10:45 +00:00
All checks were successful
CI / web (push) Successful in 59s
Required
Details
CI / go (push) Successful in 13m14s
Required
Details

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
public/wanderer!59
No description provided.