Skip to content

TrailView parts P2: the bake lowers the floor of a tube under the ways on top #3679

Closed

Description

@timohueser

Status: approved

Part of #3651.

TL;DR

Goal: In each tube, between its openings, the outer shell of the crown lies at least a slab under every way and track that crosses on top. The bake lowers the floor for this, within the grade limit of the class, and makes the section lower where the grade does not allow it. The floor heights are the heights of the tube record; the way on top never moves.
Problem: The road solver gives a tunnel the heights of a road that follows the terrain within its limits. A way on top can then lie less than the tube's height over its floor, and the tube cuts it or the opening is low (#3635).
Decision: A pass parts::floor runs on the chords of each chain with a part (P1) before the bake places their records. It reads the ways on top from the solved ways of the bake, lowers the floor to the highest profile under the caps that keeps the grade limit and the heights at both openings, and gives a chord a lower height where the grade does not allow more.
Rejected: Change the heights of the tunnel way in the tiles: today's app reads them, and it must not change. A row of heights in a tag: the records are chords, and each chord already holds the heights of its two vertices.
Systems: trailview
Contracts: specs/trailview-features.md (section "Tunnel parts": the floor and the lower height of a chord)
Size: M (one system, a compatible change of a stored format, a layer revision)

Facts

  • Between its openings, the floor of a tube touches no other way: the bake can choose it freely (epic, Decision 5).
  • The bake holds every solved way with its curve and heights in ways of bake. The deck depth of a bridge (tag deck) is in extra, a map local to the block of the roads, which ends before the levels pass. The bake links rstar for spatial indexes.
  • roads.json gives the steepest grade per class (grade: motorway 0.06, primary 0.12, track 0.35, rail 0.08); paths, steps and funicular have none, and a funicular tunnel is much steeper than 0.15.
  • Ladder::room_m of graph/levels.rs is the least height of the way on top over the lower way's floor across their overlap.
  • P1 writes a tunnel-tube record of two vertices per chord, with z = the road solver's height, and the tags height, half, section.

Plan

Words: the tube is the list of chord vertices of one chain from opening to opening; s is the metres along it from its first vertex, L its length. H is the record's height, Hmin the least_height_m of its group.

  1. Table. bake of data/trailview/parts.json gets grade_default 0.15 (a class without grade) and cross_sin_min 0.2. slab_m (0.5) is there from P1. bake keeps a map from way id to the deck depth of each bridge way (from extra) for the pass.
  2. Ways on top, parts::floor::tops(tube, ways, rules) -> Vec<Top>. An rstar index of the curves (roads::polyline) of the solved ways with heights that are not of the kind tunnel or gallery. A Top is each crossing of such a curve with the tube's polyline between its openings: its s, the sine of the angle (at least cross_sin_min), the height u of the way's underside there (its curve height less its tag deck, or less slab_m for a way on the ground), and its window: s ± (outer_m of the way + half + shell_m) / sine.
  3. Floor, parts::floor::floor(tube, tops, grade, rules). Insert a vertex at each window's start and end. Per vertex i with metres s_i and solver height z_i:
    1. Cap: c_i = min(u) − shell_m − H over the windows that hold s_i, else no cap. Target t_i = min(z_i, c_i); t_0 = z_0 and t_n = z_n: the openings do not move.
    2. Grade envelope: a pass forward, f_i = min(t_i, f_{i−1} + g·(s_i − s_{i−1})), and the same pass backward. g is the larger of the class grade (the grade of the class of the chain's widest way, else grade_default) and the steepest grade of the chain's own chords.
    3. Openings: f_i = max(f_i, z_0 − g·s_i, z_n − g·(L − s_i)). Each of the three keeps the grade within g, so their maximum does too, and the ends keep their heights.
    4. Section: where f_i > c_i, the inside height there is h_i = max(Hmin, H − (f_i − c_i)). Where f_i + h_i + shell_m > min(u) still, the pass counts a clash.
      Because g is at least the steepest chord, |z_i − z_0| ≤ g·s_i and |z_n − z_i| ≤ g·(L − s_i): step 3 never lifts the floor over the road solver's height (f_i ≤ z_i), and the openings never move.
  4. Records. The vertices' z become f. Each chord record takes the lesser h of its two vertices as its height, where that is under H. A box chain (section box) takes the same pass; its height from P1 is its H. The tunnel-end records keep their z (step 3.3 holds them). P3 closes the step in the crown between two chords of different height.
  5. Metrics. parts in the step's metrics: tubes_lowered, low_stretches, floor_clashes (with the first ten places in degrees, as the census gate prints them). P7 turns the clashes into a check.
  6. Contract. The section "Tunnel parts" gets the rule of steps 2 to 4 and the lower height of a chord. It states that the tunnel way's heights stay those of the road solver.
  7. Revision. PLANNER_TRAILVIEW_FEATURES in planner.rs: the next revision.
  8. Tests, parts/tests.rs: a tube under a road on top keeps the crown's shell slab_m under its underside; along the result the grade is never over g and the openings keep their heights; a way on top too near an opening for the grade gives chords with a height under H and at least Hmin.

Files

  • host/obc-trailview-features/src/parts/floor.rs: create. parts/mod.rs, parts/tests.rs: change.
  • data/trailview/parts.json: change: two values.
  • host/obc-data-steps/src/planner.rs: change: revision.
  • specs/trailview-features.md: change.
  • builder/web/tests/browser/trailview/fixture/: change: rebaked feature tiles.

Done when

  • obc test -p obc-trailview-features, obc test -p obc-data-steps, obc exec cargo clippy -p <each> --all-targets -- -D warnings, cargo fmt --all.
  • The pull request gives the three metrics over test box B. Before a production update: today's app pictured before and after on the new tiles at tunnel entrances and underpasses.
  • A test of the bake on the fixture shows that the z of every tunnel way is the same before and after the pass, so today's app does not change.

Deviation in the build

Built in #3737. The review of #3737 found faults in Plan 2 and Plan 3; the orchestrator decided the rules below.

  • Ways on top (Plan 2). A way on top is the stretch of the tube within the reach of the way's curve (its outer half-width + half + shell_m), not a crossing of the two centre lines with a window of (outer + half + shell) / sine. Its underside is the way's height at its nearest point, less deck on a bridge, else less slab_m. Reason: a way along the top of a tube, or one that comes onto it and leaves on the same side, does not cross the centre line (13 such places on test box B), and the window was wider than the band. cross_sin_min goes. A vertex within 1 cm of another is that vertex.
  • At grade, and the mouth. A way lies on top only where its height is more than the at-grade band (the lesser snap_height_m of the two classes, as at a crossing of the ground plan) over the road solver's height of the chain at the foot of its nearest point, and only where that foot, searched on the whole chain past the openings, lies within the openings grown by the way's outer half-width. Reason: a way at the height of the floor that crosses near an end with no shared node dug a pit in the floor; a road that goes on from the chain's end meets it at the chain's height, so it is at grade with no rule of its own; and a way across the mouth itself (a bridge or a sidewalk over the opening) lies over the tube. This replaces the shared-vertex rule of the first build. The tube gets a vertex where it enters and leaves the reach of each way within reach that is not of the kind tunnel.
  • Grade per chord (Plan 3.2). Each chord may rise by the class grade times its length, or by the road solver's chord there, the larger. Plan 3 took the steepest chord of the whole tube, so one steep solver chord made the floor steep anywhere. The proof of Plan 3 holds chord by chord.
  • The height of an opening. The floor runs before the numbers of the openings. Each tunnel-end takes the height of the tube's chord at its vertex, and its face reads it. An underpass takes its height from the floor too, not from the room of P1: one measure of the way on top for both. On test box B no opening is higher than its first chord.
  • Clashes. The bake counts a clash once per way, where the way lies over the final floor by more than the band and the shell of the crown lies over its underside. So a way that the solver's height made at grade (the solver lifts some tunnels to a way on top) is counted where the floor went down under it. A way of the kind tunnel lowers no floor; its clashes are counted apart (tube_clashes). P7 must cover both. For a way beside the tube, the metres of a clash are the crown's top over the way's underside, not the depth of a cut.
  • Metrics. floors, tops, tubes_lowered, low_stretches, low_stretches_at_least_height, lowest_stretches, floor_clashes, floor_clash_places, tube_clashes, tube_clash_places.
  • Index. The rstar index holds the segments of the ways near the tubes.
  • Done when 3 is a one-time comparison of the zoom-13 tiles of the fixture bake, develop against the branch, as in P1 (trailview-features: the bake places the tunnel parts in the feature tiles (P1) #3732): every feature that today's app reads is the same, byte for byte, with its 99 levels tags; on test box B 268,225 features. It is not a committed test, because the bake needs osmium and an OSM extract that the repository does not hold.

Depends on #3678. Requirements: none


Generated by Claude Code

Activity

  1. timohueser commented on Nov 19, 2026

    @timohueser
    OwnerAuthor

    P1 (#3678): what changed for the readers of its records

    The build of P1 deviates from its design in these points. The full list is under "Deviation in the build" in #3678.

    • Chains. The bake builds the chains from the exact vertices of the ways of the kind tunnel. A chain goes on through each vertex where the ends of two such ways meet. An end opens only where no other such way has a vertex there. At a fork or a cross passage, the end has no part, and the tunnel-tube records run to that end vertex.
    • Shallow tunnels (a way of the kind tunnel in the map that the bake lays on the ground) belong to no chain. They have no records and draw on the ground, as on develop.
    • ends and parts. The end behind the record's first vertex comes first, in the rising metres of its way. none names an end with no part of its own: same tube, under a building only, a vertex of unknown height, or a fork.
    • Numbers. Wall tops in left and right are at least coping_m. The collar of a box is at most half the chain. The collar of a pair is the larger of its two tubes. In a pair, the nearer opening moves onto the frame line of the other, so its shift (or mate_shift) includes that move.
    • Open for the owner. On test box B, 41 of the 65 pair records have tubes that overlap. Their axes are nearer than both outer half-widths, for example motorway carriageways 9 m to 13 m apart with a half of 6.6 m, or double tracks 3.6 m to 4 m apart. Rung 2 as designed (half of the wider + same_tube_gap_m) does not take them into one tube. The builder of a pair must cut the two tubes where they meet, or rung 2 must change. The report to the owner gives the options.
    • For P4: graph::open matches the end vertex on the first or last vertex of a part. A cell whose grown square ends within shift of the vertex does not see it (the trim of graph::parts), so the stretch stays a tunnel there. This is more than 170 m from the square of that cell.

    Generated by Claude Code

  2. timohueser commented on Nov 20, 2026

    @timohueser
    OwnerAuthor

    Done in #3737 (merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions