No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
public/wanderer!62
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/51-surface-mapmatch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Data source for the surface / way-type / SAC breakdown that #51 (Komoot-style trail view) and #49 (colour track and profile by surface) need. Backend + typed client only; the UI is built separately in #51.
What it does
GET /trail/{id}/surface(PocketBase, Go) reads the trail's stored GPX track and map-matches it with Valhallatrace_attributes(pedestrian costing,max_hiking_difficulty: 6,map_snap). Imported, recorded and routed tracks all go through the same path.source/target_percent_along) are handled. Positions are track distances (cumulative haversine over the GPX points, the same measure the elevation profile uses), so hover and colouring line up with the profile.unknown.unknown.surface:paved(paved_smooth/paved/paved_rough) ·gravel(compacted/gravel) ·unpaved(dirt/path/impassable) ·unknownway:road(motorway…tertiary) ·street(residential/unclassified/service/living_street…) ·track·cycleway·path(footway/path/pedestrian/bridleway/sidewalk) ·trail(path-like with SAC T2–T3) ·alpine(path-like with SAC T4–T6) ·steps·ferry·unknownsac:T1…T6·none(matched, no grade) ·unknowntrail_surface, one record per trail, keyed by a geometry hash and an algorithm version.Versiontriggers a recompute on the next view.no_matchresults are cached for 7 days, then retried in case the tiles grow.CanAccessRecord, exactly likeGET /remote/trail/{id}: owner, public, shared with the requester, or?share=<link token>. Every refusal, an unknown id included, is the same 404, so the endpoint does not reveal whether a private trail exists. Refused requests never reach Valhalla.trail_surfacehas no API rules (superusers only), so the cache cannot be listed through the collection API. Responses areCache-Control: private, no-cache.GET /api/v1/trail/{id}/surface(forwards onlyshare), types and a store. No UI and no changes tovalhalla_store.Data contract
GET /api/v1/trail/{id}/surface[?share=<token>]returns 200:Per kind, the segments are contiguous, cover
0..trackDistance, and neighbouring segments differ intypeorraw. Two adjacent segments can share atypewith differentrawvalues; merge them by type for colouring if you want. Distances are rounded to 0.1 m. The endpoint answers 404 when the requester may not view the trail and 503 when Valhalla is temporarily unavailable.For the #51 component, everything is in
web/src/lib/models/trail_surface.tsandweb/src/lib/stores/trail_surface_store.ts:trail_surface_get(trailId, {share?, fetch?, signal?}) → TrailSurface | null. It returnsnullwhenever there is nothing to render (404, 503, unavailable, network error), so the component can just render nothing.trail_surface_segments(data, kind)gives{kind, type, raw, start, end, distance}[]. Its subset{type, distance}is what the component takes.trail_surface_summary(data, kind)gives{kind, type, distance, share}[].trail_surface_kind_has_data(data, kind): false when a kind is onlyunknown, or forsaconlynone/unknown.trail_surface_segment_at(data, kind, metres): the segment under the cursor, for profile hover.The first view of a trail waits for the map-matching. On the recorded fixtures (3–5 km) that is one request; long tracks take a few chunk requests. Load the breakdown client-side after the page renders.
⚠️ Deploy window needed: DB migration + first fork change in
db/db/from upstream. Live runsflomp/wanderer-db:v0.21.2(upstream). Shipping this means:deploywithimage.yml(component: db).apps/wanderer/wanderer.yamlfromflomp/wanderer-db:v0.21.2togit.mirus-tech.com/public/wanderer-db:deploy-<sha8>@sha256:….VALHALLA_URL=http://valhalla:8002to the db container. Without it the endpoint answersunavailable/not_configured.1793896331_created_trail_surface.goruns automatically on start (Automigrate) and creates the emptytrail_surfacecollection. Down: it drops the collection. Back up pb_data before the switch. Rolling back to the upstream image leaves a harmless unused collection.unavailable/no_match(retried after 7 days).Tests
db/services/trailsurface: normalisation tables, and aggregation against recordedtrace_attributesfixtures (Valhalla 3.8.3, PACA tiles, recorded 2026-11-05, no live calls in tests):db/trail_surface_access_test.go(real schema from migrations):web: vitest for the store (URL/share forwarding, null on 404/503/unavailable/network error, abort rethrown, kind helpers, segment lookup).Open questions
pedestrianfor every trail. Bike tracks on roads closed to pedestrians may match worse; switching tobicycleby category is possible later.trail/alpine), or keep way and SAC strictly separate? Both are available now.messagestable is not used. Map-matching is the single source of truth, as agreed.Refs #51, #49
🤖 Generated with Claude Code
GET /trail/{id}/surface map-matches the stored GPX track with Valhalla trace_attributes (thinned to 10 m, chunks of <=2000 points / 50 km) and aggregates the matched edges into contiguous per-kind segments in track distances, with normalised types (surface, way, sac) and the raw values. Results are cached in the new superuser-only trail_surface collection (one record per trail, keyed by geometry hash and algorithm version) and computed lazily on first view. Access follows the trails view rule; every refusal is a 404. Valhalla is read from VALHALLA_URL. Refs #51, #49 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XMf4EGfBC9xbQ6rjD6HxgPAdds the GET /api/v1/trail/{id}/surface proxy (forwards only the share token), the TrailSurface types and trail_surface_get plus helpers that split segments and totals by kind and find the segment at a distance, for the #51 trail view and #49 track colouring. Refs #51, #49 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XMf4EGfBC9xbQ6rjD6HxgPShipped via batch PR #64 (
deploy0d0d85a4), which merged this branch head unchanged; web part live since 2026-11-05 ~19:30 CET inwanderer-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
The db part (migration +
/trail/{id}/surfaceroute) goes live with the db image switch (homelab-flux #837).Pull request closed