Skip to content

Count named trail paths as hikes where trails aren't mapped as hiking routes - #99

Merged
jtopgi merged 3 commits into
masterfrom
jtopgi-azure-deployment
Oct 6, 2026
Merged

jtopgi merged 3 commits into
masterfrom
jtopgi-azure-deployment

Conversation

@jtopgi

@jtopgi jtopgi commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Why

This is the second step of the plan you chose ("buses and ferries …, then hikes from named trail paths"). Searches only used OpenStreetMap hiking-route relations, but across the American West most trails are mapped as named paths, with no relation:

Hills near Hiking-route relations Named trails mapped only as paths
NYC: Hudson Highlands 203 309
Seattle: Issaquah Alps 134 437
Portland: Columbia Gorge 30 218
SF: Marin / Mt Tam 55 204
LA: San Gabriels 8 135

How

  • Tiles. The tile query now also lists named footpaths, bridleways and paths (OverpassService::PATH_FILTER). It skips sidewalks, crossings, private paths and ways that belong to a hiking route (- .routed).
    • Ways come with their tags, nodes and bounding box, but not their geometry. That's about 3 MB per four tiles around the Issaquah Alps or Marin, taking 17–23 s.
    • Full geometry would have been 3.5–6.5 MB per two tiles, over the 8 MB response limit.
    • LONG_QUERY_SECONDS and the query timeout go from 45/40 to 60.
  • Grouping. Ways with the same name that share a node become one trail, using union-find (path_candidates). Each trail is a candidate with the negative of its first way's id, which no relation can have, plus its ways.
    • TILE_KEY is bumped to v3.
    • Named paths are half a point less promising than mapped hiking routes (PATH_PROMISE), so places rich in relations change little.
  • Details. TrailsService::Search#known remembers each candidate path's ways, and trails_for / routes / fetch_routes take paths:.
    • The details query fetches the picked paths' ways with geometry (way(id:…)->.named; out tags geom) together with relations. It measures length, loop, a loose-end start, the preview and the paved share (path_attributes), and stores ways in the details.
    • A path requested without its ways is skipped, never cached as unmeasurable.
  • Highlights. Highlights are looked up along a named path's ways, read from its stored details (path_ways), so the hike page works too.
  • Links. Trail#osm_url points to /way/<first way> for paths. The hike page accepts negative route ids.
  • Route database. It needs no change: negative ids import as they are, and details keep their ways.
  • Fixes from review:
    • Dense areas. Where named paths push a tile query over 8 MB, as around Zürich, those tiles are queried again for their hiking routes alone. They keep their routes, and a response that large no longer counts as an Overpass outage.
    • Trails at tile edges. Paths are listed 0.05° beyond each tile so short trails crossing an edge arrive whole. Pieces from different tiles, including the first four and the rest, are joined where they share a way, and keep the id of a piece already checked.
    • Re-measuring. A path measured from fewer ways than are now known is measured again. If that fails, as Overpass does from the server, it keeps the stored details and waits 6 hours before retrying. Details record the ways they were measured from, so ways deleted since don't trigger refetches.
  • README updated.

Verified locally (live providers, Overpass mirror)

  • San Francisco, from Caltrain 4th & King: 30 hikes, 20 of them named paths. They include Montara Mountain, Hazelnut Trail, Redwood Regional's French Trail and Sweeney Ridge. Earlier test builds found 0.
  • New York, from Grand Central: 28 hikes, only 1 of them a named path, up from 26 with relations only. Hiking routes still lead where they're mapped, as intended.

Tests

  • Path candidates: grouping by shared nodes, the same name elsewhere kept separate, and short paths dropped.
  • Measuring a path from its ways, with the paved share, a loose-end start and ways kept.
  • Highlights along a path's ways.
  • A path without known ways is neither queried nor written off.
  • Promise; the route database round trip.
  • The hike page for a named path (highlights, and the /way/5 link); a route id of 0 is rejected.
  • The search passes paths' ways to trails_for.
  • Exact query strings updated.
  • Full suite (295), system tests, Brakeman and Zeitwerk pass.

jtopgi and others added 3 commits October 5, 2026 19:35
… routes

Across the American West, trails are mostly mapped as named paths rather than
hiking route relations, so searches found few hikes. The tiles query now also
lists named footpaths, bridleways, and paths that aren't sidewalks, crossings,
private, or part of a hiking route, with their nodes, and each set of ways of
one name joined at a node is a route, with the negative of its first way's id.
A picked path's details are measured from its ways, its highlights found along
them, and its OpenStreetMap link goes to its first way. Paths are half a point
less promising than mapped hiking routes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ross tile edges whole

Where named paths would take a tile query over 8 MB, as around Zürich, the
tiles are queried again for their hiking routes alone, and a response that
large isn't asked of the other instance. Paths are listed 0.05° beyond their
tiles, pieces of one trail from different tiles are joined where they share a
way, and a path measured from fewer of its ways than a search knows is
measured again from them all.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…its pieces across all tiles

Measuring a path again from ways its tiles list now keeps what was measured
when that fails, as Overpass does from the server, and doesn't try again for 6
hours. Details list the ways a path was measured from, those gone since too, so
they aren't asked for again and again. Pieces from the first four tiles and the
rest are joined too, keeping the id of a piece already checked.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jtopgi
jtopgi merged commit 140e037 into master Oct 6, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant