Repository navigation
Description
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
waysofbake. The deck depth of a bridge (tagdeck) is inextra, a map local to the block of the roads, which ends before the levels pass. The bake linksrstarfor spatial indexes. roads.jsongives 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_mofgraph/levels.rsis the least height of the way on top over the lower way's floor across their overlap.- P1 writes a
tunnel-tuberecord of two vertices per chord, withz= the road solver's height, and the tagsheight,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.
- Table.
bakeofdata/trailview/parts.jsongetsgrade_default0.15 (a class withoutgrade) andcross_sin_min0.2.slab_m(0.5) is there from P1.bakekeeps a map from way id to the deck depth of each bridge way (fromextra) for the pass. - 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 kindtunnelorgallery. ATopis each crossing of such a curve with the tube's polyline between its openings: itss, the sine of the angle (at leastcross_sin_min), the heightuof the way's underside there (its curve height less its tagdeck, or lessslab_mfor a way on the ground), and its window:s ± (outer_m of the way + half + shell_m) / sine. - Floor,
parts::floor::floor(tube, tops, grade, rules). Insert a vertex at each window's start and end. Per vertex i with metress_iand solver heightz_i:- Cap:
c_i = min(u) − shell_m − Hover the windows that holds_i, else no cap. Targett_i = min(z_i, c_i);t_0 = z_0andt_n = z_n: the openings do not move. - Grade envelope: a pass forward,
f_i = min(t_i, f_{i−1} + g·(s_i − s_{i−1})), and the same pass backward.gis the larger of the class grade (thegradeof the class of the chain's widest way, elsegrade_default) and the steepest grade of the chain's own chords. - Openings:
f_i = max(f_i, z_0 − g·s_i, z_n − g·(L − s_i)). Each of the three keeps the grade withing, so their maximum does too, and the ends keep their heights. - Section: where
f_i > c_i, the inside height there ish_i = max(Hmin, H − (f_i − c_i)). Wheref_i + h_i + shell_m > min(u)still, the pass counts a clash.
Becausegis at least the steepest chord,|z_i − z_0| ≤ g·s_iand|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.
- Cap:
- Records. The vertices'
zbecomef. Each chord record takes the lesserhof its two vertices as itsheight, where that is underH. A box chain (sectionbox) takes the same pass; itsheightfrom P1 is itsH. Thetunnel-endrecords keep theirz(step 3.3 holds them). P3 closes the step in the crown between two chords of different height. - Metrics.
partsin 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. - Contract. The section "Tunnel parts" gets the rule of steps 2 to 4 and the lower
heightof a chord. It states that the tunnel way's heights stay those of the road solver. - Revision.
PLANNER_TRAILVIEW_FEATURESinplanner.rs: the next revision. - Tests,
parts/tests.rs: a tube under a road on top keeps the crown's shellslab_munder its underside; along the result the grade is never overgand the openings keep their heights; a way on top too near an opening for the grade gives chords with aheightunderHand at leastHmin.
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
zof 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, lessdeckon a bridge, else lessslab_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_mingoes. 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_mof 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 kindtunnel. - 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-endtakes the height of the tube's chord at its vertex, and itsfacereads 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
tunnellowers 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,
developagainst 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 99levelstags; 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
timohueser commentedon Nov 19, 2026
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.
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 thetunnel-tuberecords run to that end vertex.tunnelin 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.endsandparts. The end behind the record's first vertex comes first, in the rising metres of its way.nonenames an end with no part of its own: same tube, under a building only, a vertex of unknown height, or a fork.leftandrightare at leastcoping_m. Thecollarof aboxis at most half the chain. Thecollarof apairis the larger of its two tubes. In a pair, the nearer opening moves onto the frame line of the other, so itsshift(ormate_shift) includes that move.pairrecords have tubes that overlap. Their axes are nearer than both outer half-widths, for example motorway carriageways 9 m to 13 m apart with ahalfof 6.6 m, or double tracks 3.6 m to 4 m apart. Rung 2 as designed (halfof 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.graph::openmatches the end vertex on the first or last vertex of a part. A cell whose grown square ends withinshiftof the vertex does not see it (the trim ofgraph::parts), so the stretch stays a tunnel there. This is more than 170 m from the square of that cell.Generated by Claude Code
timohueser commentedon Nov 20, 2026
Done in #3737 (merged).