Skip to content

TrailView ground plan GP3: faces of ways and junctions: carriageways, tight bends, junction areas, mouths, rail beds #3112

Closed

Description

@timohueser

Status: approved
Part of #3096. One pull request into ground-plan.
Depends on: #3098 (GP2)

TL;DR

Goal: For each cell and level, the crate gives one planar map of faces (carriageways, shoulders, verges, guest blend parts, corner fills, tip fills, rail beds, crossing faces, platforms, slopes, terrain) with no overlap, no gap and no part thinner than the minimum width, and two neighbouring cells give the same faces on their shared border.
Problem: The crate has the way graph (GP2) but no faces. Today the 2D shape of a road comes from five sets of special pieces (sweep sections, corner arcs, mouths, path ends, the stamp's own corners), and each new combination fails in a new way (#3095, section 3).
Decision: Each rule makes candidate polygons from GP2's samples: bands per layer, end caps, joint fans, one corner engine for junction corners, tight bends and kinks, guest blend parts, rail beds, platforms. One integer slice of the window by all candidate boundaries (i_overlay StringOverlay, absolute precision) gives patches. Each patch takes the label of its highest-ranked candidate, and equal labels merge. A pinch rule merges thin parts and sharp tips into the higher of their two sides. A second slice adds the slope bands of the outer edges. All geometry comes from global numbers, and every chain of rules stays at or below 191 m (section 9, GP1's reach table), so the cells agree.
Rejected:

  • i_overlay offsets: float only, with std trigonometry, so two cells can round one edge differently.
  • One difference per priority: each difference rounds the shared edge again, so faces can overlap or gap by a unit. One slice has one set of edges.
  • A morphological opening for the minimum width: it rounds every convex corner and needs an offset of every edge.
  • A constrained triangulation to find thin parts: with cocircular points its triangles depend on the order of insertion.
  • A closing of the whole carriageway in tight bends: it joins hairpin legs (the epic, section 5).
    Systems: trailview
    Contracts: none (the face plan is internal to the crate; features_format stays 4)
    Size: L (about 3,700 lines: types 150, frame 250, bands 400, corners 300, bends 150, junctions 350, rails 120, slice 350, width 250, slopes 200, mod 150, check 200, rule reader 150, tests 650)

Facts

Paths are under builder/web/src/lib/trailview/ unless they start with another root.

  • Old corners: radius 5 m in towns, 7 m rural, 4 m on tracks, at least 0.8 m (roads/corner.ts:10), shrunk by 0.8 until the arc fits (corner.ts:14). No corner where the through pair turns 150° or more (roads/junctions.ts:21).
  • A path stops where it leaves the roads' cores, carriageway plus shoulder or sidewalk (roads/path-ends.ts:25-52). OSM splits join on the bisector (roads/joints.ts:1-3).
  • The stamp has its own corners and keeps one sharp where another band reaches in (terrain/corners.ts:1-16); the two corner codes disagreed on 59 of 161 kerbed arcs (TrailView roads: why the road system tears, and a planar road map #3095, section 3 D).
  • Today a shoulder is paved beside main roads and ground beside minor ones (roads/section.ts:147-149); the band starts at the core's edge, with no verge (section.ts:156-161).
  • data/trailview/roads.json gives reach 10 m for roads and rails, 3 m for paths.
  • Every top-level key of roads.json is a class: the bake makes a solver row of each (host/obc-trailview-features/src/kinds.rs:205-211), and so does PROFILES (terrain/bins.ts:92-95). A field outside CLASS_FIELDS is no option of the feature step (kinds.rs:17, :202-204).
  • widen is what the half-width gains at a vertex (specs/trailview-features.md:282).
  • A platform is an area or a line with width; its vertices have heights, or none where no track is near (data/trailview/kinds.json:61-73, specs/trailview-features.md:361-363).
  • i_overlay 4.0.7 (paths in its src/): offsets exist only for float points (mesh/stroke/offset.rs:17) and call f64::sin_cos (mesh/rotator.rs:30). The integer crossing moves the picture to a segment's first point first (split/cross_solver.rs:237). Coordinates stay below 2^30 (:211). Precision::HIGH doubles the snap radius on each pass over the whole input (split/snap_radius.rs), ABSOLUTE keeps it at 1 unit (core/solver.rs:41). Above 16,000 segments, Tree changes to the fragment solver (core/solver.rs:141, :172-174). The default output drops collinear points (core/overlay.rs:373). StringOverlay (string/overlay.rs:21) slices shapes by string contours (:46, :165); a string segment keeps one bit per direction, so two candidates that share an edge do not cancel (segm/string.rs:6-12). No crate of the workspace turns on its threads (its Cargo.toml:36).
  • The fixture has 9 zoom-13 feature tiles (builder/web/tests/browser/trailview/fixture/features/13): 576 zoom-16 cells.
  • GP1: a cell reads every zoom-13 tile that its square plus MARGIN_M = 192 m touches, usually one and at most four, and keeps one copy of each element by the owner rule. Every chain of rules stays at or below 191 m; GP1's reach table lists them all, and its reader asserts them (GP1, Design 5). GP2's decisions read R_d: 8 m for hosts, 70 m for room_m (ROOM_MAX_M 30 m plus a snap foot's 40 m) (GP2, Reach budget). GP2's ids are cell-local, in an order of global positions.
  • GP6 owns the window, heights.window_m = 86 m past the cell, and a height reads faces within its H = 51.5 m (GP6).

Core v3 (current design)

This section replaces "Core v2" below for everything it names. Branch claude/gp3-faces-v3 (pushed, no PR). Pictures: /media/timo/OSM1/tmp/ground-plan/gp3/v2/ (step folders 14 to 18) and, on the second machine, /home/user/gp-pictures/gp3/ (step1/, item1/), each with an INDEX.md.

Owner decisions that shape it

  • Road and path corner radius (inner_radius_m) is 1 m. The inner edge of a carriageway next to land never turns tighter; junction corners use the class corner radius.
  • A junction corner's radius is a class rule: the lesser corner_radius_m of its two arms' classes (roads.json), or the lesser corner_radius_walk_m where either arm has a sidewalk on the corner's side of its first segment. Steps and rails have 0: a sharp corner. The owner sets the values.
  • Thin parts of correct geometry are valid (tapers, narrow land strips, a round that runs into an edge). Only artefacts are faults: overlaps, gaps, crashes, border differences between cells, shards across another way, stranded fragments, kinks.
  • No closings, no minimum-width rule, no pinch pass.
  • Bent ownership borders between related road faces (a junction and its arm, two junctions on a link, two ways that overlap without a graph point) are accepted. Check 1 counts them as their own kind (BentBorder), not as a fault. GP6 and GP11 treat one where it shows.
  • Short features are faults (orchestrator decision under owner rule 2): a step, a pocket or a needle of the paved outline under SUPPORT_M that the kink measure cannot see. Check 1 counts them (short_features).
  • Width changes taper (owner decision): where two arms of a point that run on into each other have different half-widths, the wider arm's edge runs straight into the narrower one's over a length set by a taper rate under CORNER_TURN, so no corner needs a round. One rule in the strokes; the rate is a rule value with its reason (plan.json taper_rate 0.15: the edge turns 8.5° at each end, 2° under CORNER_TURN). The taper area's material is a label question (the owner weighs dirt mouths for paths), not a shape one. Deviation: the taper applies at joints only, per layer (carriageway, paved shoulder, shoulder, verge, slope), over at most extent_m. At a junction's two hosts it made the rounds of three places overlap (4 more kinks, 1 sliver) for 2 fewer short features, so junction arms keep their widths until the overlapping-round rule exists. Before it, a round touched the wider arm's square-end corner and left an S-shaped step: concave round, sharp convex corner (/media/timo/OSM1/tmp/ground-plan/gp3/v3/short/decision/convex-touch.png).
  • Owner decision (2026-11-05, TrailView ground plan GP3 follow-ups: open decisions and review items #3132): the straight taper becomes a smooth S taper. The edge bends in and out smoothly, its ends meet both edges at the same slope (C1), with the same length and rate, and GP2's least sample spacing on the curve. Open: see TrailView ground plan GP3 follow-ups: open decisions and review items #3132.
  • Accepted case (owner): where a junction lies next to a joint and the two points share a seam, the joint's face meets the junction's face with a V-shaped ownership border (a round's fan paves land only, so the arms' carriageways reach each point's face through its region). Both sides are carriageway. The fan rule and the shared-seam rule stay as they are. Revisit only if a height crease shows along such a border in a shot. Picture: /media/timo/OSM1/tmp/ground-plan/gp3/v3/fragments/fragments-2.png, last row (g4).
  • Slivers and jogs go by one general precision rule in the final overlay (a grid of a few frame units), not by per-cause fixes (open).
  • The kink check measures a corner by the turn within SUPPORT_M (1 m) about each concave vertex, so a needle or a 1-unit jog is no corner (it stays in the sliver and jog counts), and judges it against the least inner_radius_m of the ways whose carriageway edge runs through it (a road/path corner against 1 m), not against the class of the face's material.
  • Slope faces stay (about 15 % of a town cell).

Operations

  1. Strokes: per way, the union of a quad per segment, a pie on the outer side of each joint at the global directions (a mitre point under one arc step), a half disc at a free end, a square end at a point or a level change. Band layers (paved shoulder, shoulder, verge, slope) are strokes of the same samples at the cumulative offsets. A band's square end, round-end sides and gap sides pass the corners of every layer inside it.
  2. Points: junctions and joints from GP2; a way's own turn is a corner of its stroke's inner edge tighter than inner_radius_m (grouped like the kink check), at its sharpest sample, except on a part of a junction's or joint's region.
  3. Rounds: for each pair of neighbouring arms (every sector), the circle tangent to the two facing carriageway edges: the corner radius, else the first of a descending ladder (each radius 0.85 of the one before) that fits, each radius tested in full (whether a circle fits is no monotonic function of its radius). A round may cut into its arms' strokes by their sag_plan_m. The crossings of the offset edges are tried by summed distance, so an arm's own sharp turn does not hide the corner. Where the facing edges do not cross, the circle is tangent to one arm's edge where it leaves the point's other pieces (square ends, gap fills). A round lies off every line's carriageway. A pair of radius 0 (steps, rail) records a sharp corner. The fan: the two centre lines to the feet, then the arc at the global directions.
  4. Regions and seams: a junction's or joint's arms belong to its face up to a straight seam, 0.5 m past the farthest foot. Junction and joint runs stop at the next junction or joint, not at a turn. Two points whose seams on their link would overlap share one seam, computed in sample order; that seam cuts the link's carriageway and both points' fans, and a fan's patch past it takes the other point's label. A seam cuts only its way's carriageway: it runs between the crossings of the way's ring nearest its middle, and each crossing becomes a vertex of that ring.
  5. Outline rounds: a corner of the union of the carriageway and rail-bed candidates (the turn within SUPPORT_M about a concave vertex) that is tighter than the least inner_radius_m of the ways whose carriageway edge runs through it, and that no point's round shapes, gets the circle tangent to its two edges, off the paved area: that radius or the first of the ladder that fits. Its ring (the corner, the edges to the feet, the arc) runs 32 units into the paved side, loses to every carriageway and rail bed, and takes the label of the face along its first edge. This covers corners between ways of different points, a third piece between a point's two arms, and a way's turn inside a junction's region.
  6. Slice and labels: one StringOverlay slice of the cell square by all candidate outlines and seams; seams and rings are snapped to the cell lines alike, and close cell-line crossings become one point. Per patch, the least key wins; a region gives its label to a patch of one of its ways that lies past none of that way's seams; a carriageway over a rail bed is a crossing.
  7. API: faces::build(graph, input, rules, cell, level, slopes) -> FacePlan, FaceStats::counters(). No stage clock, no std::time, libm only.

Deviations from the plan above

  • straight_deg and turn_deg are gone from plan.json: every sector gets a pair, and a turn is a corner of the inner edge.
  • i_overlay is 9.1.0 (was 4.0.7): 4.0.7 loops in its fragment solver on one fixture union (a unit test holds it). The WASM size effect is not measured yet (GP5's bridge budget had about 2 % headroom).
  • The root Cargo.toml has [profile.dev.package.obc-ground-plan] opt-level = 3: the fixture test takes 23 s instead of 399 s. i_overlay at opt-level 3 alone gave no gain. This makes obc test affected select the whole workspace for the PR.
  • The fixture bench and the fixture test build cells on 4 threads (Fixture::map); TileCache holds its tiles in Arc.
  • Bent ownership borders are a class of their own (owner decision above).
  • pairs in plan.json has no radii: the junction corner radius is a class field. pairs keeps mouth and blend for GP4 and GP6.
  • The kink check changed (owner decision above).
  • Strokes: an inner vertex whose inner mitre point would turn a segment's edge back (a segment shorter than the offset times the turn) is left out of the stroke, except next to the stroke's ends. Before, the two segments' own corners stood apart there, and on a taper the edge stepped by a few centimetres.
  • The joint taper narrows each layer to the other arm's offset of that layer (as planned above); before, the bands kept their widths, so a band that the narrower way lacks ended square at the joint.
  • Crossing faces (changes 4.7): a carriageway patch over a rail bed is a crossing only where the rail's centre line enters the patch, or where a carriageway covers the centre line's point nearest the patch (a rail in a street). Where a road only runs beside a rail and overlaps its bed, the bed wins.
  • Platforms (4.7): rank platform between carriageway and rail_bed; platform_half_m 1.5 m, platform_reach_m 0 in plan.json; Owner::Platform holds the feature's index in the cell input. The outline checks end at a platform's edge (a wall).
  • Left for later sub-issues: the GP4 hooks H1 to H9 (GP4 builds them in its pull request, as TrailView ground plan GP4: faces of sidewalks: kerbs, driveways, zebras, corners, ends and buildings #3099 allows), the edge flags SEAM, BLEND_JOIN and UNRELATED (GP3 v3 makes no blend parts; all flags are 0), the sub_window case and the other synthetic cases of Verification, the torture contact sheet.
  • A cell reads graph points out to points_m = input_m + extent_m (66.1 m); the points past input_m only end the runs of the points that it rounds. The reach table has the row faces points, and faces cell runs through it (PR ground-plan GP3: the faces of a cell (core v3) #3131 review, finding 2).
  • CornerArc: t_a and t_b are the feet (the tangent points, the ends of the arc on the circle); arc holds the points at the global directions strictly between the feet, as the fan has them. A sharp corner has the corner as centre, feet and arc.
  • Check 2 names a platform by its feature's first tile and its index there (check::feature_names), as Owner::Platform holds a cell-local index.
  • WASM size: faces::build in the bridge takes it from 663.6 to 1344.5 KiB raw and from 267.3 to 514.8 KiB gzipped (wasm and glue); i_overlay alone adds 279 KiB raw, 89 KiB gzipped. GP5's budget is 672 KiB raw, 272 KiB gzipped.

Open items before GP7 (review of PR #3131, findings 2 and 3)

  1. The off-line test of a far point's rounds reads only the ways within input_m. A round lies off every carriageway that its circle meets (points::off_lines). Its centre lies up to extent_m along an arm and a half-width and its radius off it; the carriageway lies another half-width and radius on. For a point at input_m (46.1 m) that is up to 114 m past the cell, but a cell reads only the ways with a sample within input_m. Reviewer's scenario: two points share a seam in the window. The far point P2 lies up to 30.5 m out (1.5 × extent_m + seam_m). Its round tests a carriageway that only one cell reads, so the cells give P2 another far, and the shared seam moves in one cell. Not seen in the fixture (check 2: 0 faults over 480 borders). The other half of the scenario, the run stops of P2, is fixed (points_m, above). Tried: read the ways out to input_m + extent_m + 2 × (HALF_MAX_M + the greatest radius) = 114 m. The fixture counts did not change, but one pair against 3f80504 gave ×1.069 over all cells and up to 2× in rural cells that a long way passes 46 to 114 m out: each off-line test walks every segment of such a way. Options: an index of the far ways' segments for off_lines only, or a tighter chain for the rounds whose far can move a seam in the window.
  2. The outline rounds depend on the order of the union's rings and on near. outline::rounds skips a place on a round made before (on(&made, v)). The order of the places follows the union's rings, which differ between cells. near (window + extent_m / 2) lets a round that only one cell makes skip a place that both cells see. Related: a round's band rings reach the widest band past its ring, past near; len is in units at the cell's west edge. Not seen in the fixture. Tried over the fixture, none kept: (a) the places in the order of their positions, no made skip: 5 cells get a second round of nearly the same circle (two arcs, gp3/v3/review/f3/); (b) position order with the made skip, and rounds made out to 2 × (len + the greatest inner radius) so that both cells make each round that can skip a place near the window: 4 such cells; (c) the rounds in the order of how many other places lie on their circles: 3 such cells; (d) (c) and two circles within 0.1 m as one: kinks 15 to 16. A robust rule needs a choice among the rounds that does not depend on an order (for example a cover of the places by the fewest circles), and a reach chain for the outline rounds (places to about 40 m, the paved union past that).

Measurements (256 fixture cells, release, 4 threads, 3 GB cap, best of 3; 8d2464c and the head run back to back on the second machine, timosPC equivalent = ratio × 8d2464c's timosPC time)

8d2464c 215e990
crashes / overlaps and gaps (partition) / check 2 (480 borders) 0 / 0 / 0 0 / 0 / 0
shards across a way 0 0
fragments 14 18
kinks (the check above) 43 9
slivers / jogs (for the precision rule) 72 / 62 63 / 74
bent ownership borders (accepted) 96 95
time per cell, rural 237 cells, median, timosPC equivalent 2.1 ms 2.6 ms
time per cell, town 19 cells, median, timosPC equivalent 34 ms 33.6 ms
cargo test -p obc-ground-plan 47 passed 48 passed

Core v2 (superseded by Core v3 where they differ)

This section replaces R2, R3 and R5 of the revised design and the special pieces of sections 4.4 to 4.6, 6 and 7 (corner fills, rings, tip fills, blend parts, behind runs, pinch passes). Branch claude/gp3-core-v2. Pictures: /media/timo/OSM1/tmp/ground-plan/gp3/v2/ (one folder per step, INDEX.md).

Invariants

  1. Valid by construction. Every face comes from one integer slice of the cell square by the outlines of all candidates. Each patch takes the label of the least key among the candidates that cover its inner point. So the faces tile the cell, with no gap and no overlap, for any input. A rule that cannot fit makes a smaller candidate or none; it never makes a face.
  2. No shared edge computed twice. Two candidates of different labels never meet along an edge that two booleans computed apart: a round is grown 3 units into its arms, so its only own edge is its arc; seams and partial strokes use the same samples as the way's own stroke (an inserted seam sample keeps its segment's direction).
  3. Global inputs only. Every point is an integer sample of GP2 plus a rounded offset; arcs step at fixed global directions (36, libm); every local boolean runs in a frame about a global anchor; keys read global names (span owner, positions). A vertex less than 2 units off a cell line moves onto it, and every ring gets an exact vertex where it crosses a cell line.
  4. Ways that do not meet are never joined. A closing reads only the strokes of two arms of one graph point.

Operations

  1. Strokes. A way is a list of samples with half-widths. Its stroke is the union of a quad per segment, a pie on the outer side of each joint at the global directions, a half disc at a round end (junction, joint, free end) and nothing at a level change (square end). Band layers are strokes of the same samples at the cumulative offsets: paved shoulder, shoulder, verge, slope.
  2. Point rounding. For each graph point (junction, joint, and a way's own turn: a sample whose turn over its half-width plus its inner radius passes turn_deg), for each pair of neighbouring arms with a sector under straight_deg: the closing of the two arm strokes with the pair radius (junction pairs, plan.json) or the class inner_radius_m (joints, turns). Arms run extent_m along their way and stop at the next point. What the closing adds is kept where it touches both arms, is more than 3 units off them, and lies in the corner zone: a disc about the point, radius = the farthest point where the two arms overlap + 2.5 r.
  3. Point faces. A junction or joint face is its arms up to a straight seam, 0.5 m past the foot of each round's centre on that arm or past the farthest overlap with another arm, plus the rounds. A turn's round has the way's own label.
  4. Rings. Each round is dilated by the band offsets of the arms it touches (the widest), cut square at the round's foot on an arm with a narrower band, and joins the band layer. Each band layer is one label (shoulder, verge, slope), so bands of different ways never leave thin parts between them.
  5. Slice and labels. One StringOverlay slice of the cell square; per patch an inner point (2 units in, else 1 unit in for a patch under 4 units wide); the label of the least key; a carriageway over a rail bed is a crossing.

Case distinctions that remain

  • Round end or square end of a stroke: a level change must not put a round cap under a deck.
  • Junction pair radius or class inner radius: the owner's rule (corners by group pair, turns by class).
  • Ring ends square at a narrower arm: a band that exists on one arm only must end blunt; a taper would be a sliver.
  • Thin patch inner point at 1 unit: a patch under 4 units has no point 2 units in.

Determinism

Inputs are GP2's global samples; every derived point is sample + round(offset); arc directions are global; booleans run about global anchors; keys use span owners and positions. Measured: check 2 on 480 shared borders of the fixture: 4 label differences (open, below).

Reach rows

Row Terms Sum
faces input extent_m 20 + seam_m 0.5 + HALF_MAX_M 15 + widest band 10.6 46.1 m
faces cell GP2 room_m 70 + faces input 116.1 m

The face window is the cell square: a plan holds the faces of its own cell only. GP6 and GP7 read neighbouring plans for context.

Measurements (fixture, 256 cells, release, shared PC, 3 GB cap)

Value
crashes 0 (i_overlay 9.1.0; 4.0.7 hangs in its fragment solver on one fixture union, saved as a unit test)
check 1 partition faults 0
check 1 pinch hits 7,274 in 129 cells (counted per segment pair)
check 2 border label differences 4 of 480 borders
kinks (concave corners or arcs under 0.9 × inner radius on a carriageway edge to land) 27,858 hits (see below)
time per cell, rural (237 cells) median 15 ms, p95 270 ms
time per cell, town (19 cells) median 650 ms, p95 1,990 ms
share of the point rounding in the time about 90 %

Open problems (next steps)

  1. Inner radius at every corner. A concave corner between arms of two different points (a land finger between a junction arm and a hairpin leg) is seen by no point closing. Agreed rule: corners are found on the outline of the carriageway union per level; each gets the closing with the class inner radius in its zone, shrunk (×0.6) until its round ends inside the zone, so land narrower than 2r keeps a smaller round end and is never paved along its length. A first implementation (branch claude/gp3-core-v2-corners-wip) still paves the bottom i07 hairpin and shrinks the v07 bay: not merged.
  2. Cost. The closings dominate. Plan: compute each round directly (the circle tangent to the two edges at a corner, with its foot points), build all primitives as polygons, and run one overlay per cell. Target: low tens of ms per town cell.
  3. Thin parts. Pinch causes by face (bench check1_pinch_causes): carriageway tips of ways (814 faces), carriageway strips of ways (495) and junctions (331), shoulder, slope and terrain tips and strips (the rest). Most are where the outlines of unrelated ways cross at shallow angles.
  4. Check 2: 4 border label differences (slope against shoulder or carriageway): one label decision reads data that differ between the two cells.
  5. Kink check: it also counts polygonal arc ends and 1-unit jogs; it needs a support length before it can gate.

Revised design

The owner chose (a) no built-in thin shapes and (b) a local pinch edit on the planar map, with a design review before more code. This section replaces 4.4 step 2 (circle placement), 4.5, 4.6 rings and behind runs, 5.2 to 5.3 (strings), 6 and 7, and adds the root causes and the cost model. Pictures of every problem and probe: /media/timo/OSM1/tmp/ground-plan/gp3/design/INDEX.md.

R1. Invariant

Let w* = 1.25 × min_width_m. Construction emits no candidate that has a part thinner than min_width_m, except where the input forces it (R5). Every taper that a rule makes ends where it reaches w*, and the part past that goes to a named face of the rule. The pinch rule then meets only input-forced thin parts.

R2, R3. Replaced by Core v2.

R4. Strings and determinism (the root causes of the faults)

  • Window and cell lines. A string vertex less than 2 units off a window line or a cell line, and not on it, moves onto the line. The rule reads only the vertex, and every cell has the same cell lines. Then i_overlay's 1-unit snap cannot bend the window or a cell line (the 4 area faults, area-*.png; the "no edge" borders).
  • Strip breaks. A strip piece breaks only at global places: at each span's vertex sample, and where a key changes. It never breaks at a count from the way's first sample, because each cell trims that sample differently (border 1 and 2).
  • Keys. No key or label key reads a way's first sample (s[0]). A piece's key comes from its own span. The pinch rule compares two targets by the keys of the pieces that cover a point next to the pinch (border 3).
  • Strings once. Each band boundary line goes into the slice once. Today the carriageway edge and the shoulder's inner edge both go in. This also saves cost (R7).

R5. Replaced by Core v2 (no pinch edit; thin parts are an open problem there).

R6. Root causes found (exact)

  • Area faults, 4 cells. Each cell has one window edge bent by one unit (from the probe):

    Cell Vertex Window line Patch sum less window (doubled units)
    34292/23099 (−53874, −2128) x = −53875 −53,688
    34294/23105 (−53852, 307168) x = −53853 +22,832
    34295/23105 (38131, 315998) y = 315997 +231,123
    34297/23105 (300275, 315998) y = 315997 −15,304
    • These vertices come from the stage 2b slope region: the union of buffer rectangles that reach past the window. i_overlay with Precision::ABSOLUTE snaps the window's own boundary to a vertex 1 unit away. The patches the slice returns then do not tile the window: their areas sum wrong already before my map is built. Two interior half-edges per cell have no twin.
    • Fix: R4, window and cell lines.
  • Borders, 5:

    • 34296|34297/23098 (60 and 50 vertices) and 34296/23098|23099 (41 and 42): about 20 border vertices are in one cell only. They come from strip piece sections, which break every 16 quads counted from each way's first sample, and from different thin pieces. Fix: R4 strip breaks, and R5 instead of window re-slices.
    • 34298|34299/23099, segment 4 (Slope against Shoulder of way 18): the pinch target order read a label key that came from s[0], which differs per cell. Fix: R4 keys.
    • 34306/23104|23105, two "no edge" segments: both cells agree, but the border bends one unit at a vertex next to the line, so two vertices that are on the line have no straight edge between them. Fix: R4 cell lines.

R7. Cost model

Measured in release with one run each, on the shared PC.

  • Rural cell 34292/23098: 60 candidates, 511 pieces, 9,556 slice segments, 729 patches, 147 faces.
  • Town cell 34297/23098: 1,262 candidates, 5,328 pieces, 63,500 segments, 8,876 patches, 1,370 faces, 23,888 vertices.
Stage (ms) Rural Town
Graph (GP2's bench over all cells) median 0.55, p95 3.4 (the p95 cells)
Candidates (points, corners, bands) 0.6 7.5
Slice of the window (i_overlay) 1.9 45.7
Labels 0.4 6.3
Map build 1.1 12.7
Pinch search, one pass 7.3 44.3
Slope region (i_overlay union) 14.3 124.3
Stage 2b slice, labels, map 8.1 136.3
Output 2.6 14.1
Final pinch search about 7 about 44
Total, no pinch pass about 43 about 435

Today each pinch pass re-slices the whole window: 300 to 1,300 ms per pass in the town cell, because the thin pieces add strings.

Path to lower cost, with estimates:

  1. No stage 2b. The slope band becomes a layer of each cross-section (from the verge's outer edge out to reach_m), with slope rings on corner arcs and turn shapes, a slope fan at caps, and a slope band on platforms. The key order (slope lowest above terrain) gives the union in the one slice. This saves the union and the second slice: about 260 ms in town, 22 ms rural. Cost of the change: the band follows each way's own edge, not the outer edge of the merged faces, so a thin-piece edit or a blend part does not move it.
  2. Strings once (R4): about 30 % fewer slice segments.
  3. Window = cell + GP6's H (51.5 m), not 86 m: 22 % less area. GP6 owns window_m.
  4. Map from i_overlay's own graph, with no shape extraction and re-indexing: about 12.7 → 3 ms in town.
  5. Pinch search: with R2 it meets few thin parts. A finer grid with orientation tests before distances: about 44 → 8 ms in town.
  6. Optional, owner's choice: a 10 cm plan sag instead of 5 cm for minor classes (GP2's rule) cuts band vertices by perhaps 30 %.

Estimate after 1 to 5:

Stage (ms) Rural Town
Candidates 0.6 8
Slice 1.5 28
Labels 0.3 5
Map 0.3 3
Pinch search 2 8
Output 1.5 8
Total about 6–7 about 60

8 ms holds for rural cells, not for town cells. The fixture's p95 is a town cell. With one exact window slice, about 50–70 ms native is the credible p95 for a town cell.

  • To get near 8 ms there, the arrangement must not be one global boolean: build the bands of each way directly (its layers share exact edges), and run i_overlay only in clusters where candidates of different owners overlap (junctions, crossings, close ways). That is a new arrangement builder, with its own robustness risk; I estimate 2–4 times faster than one window slice, not measured.
  • Caching per tile does not help much: neighbouring windows overlap, but the slice reads strings from the whole window.

The owner decides: a faces gate per cell type (rural ≤ 8 ms, town as measured in GP7 with WASM), or the cluster arrangement.

Design

1. Words used in this sub-issue

  • Layer: a band of a way's cross-section on one side, between two offsets from its middle line: carriageway (both sides), shoulder, verge. GP4 adds kerb and sidewalk.
  • Seam edge: the edge that a corner or a guest meets: the carriageway edge, or for a stop mouth the host's core edge (carriageway plus a paved shoulder; GP4 adds the sidewalk's back edge).
  • Candidate: a polygon that a rule makes, with a label and a key. Candidates can overlap.
  • Label: owner, surface, material way, height rule, crossing way. Key: the order in which candidates win (4.8); Terrain has the greatest key.
  • Chain: ways that run on into each other at joints, and the host pair through each junction.
  • Corner: where two edge chains meet: two neighbouring arms of a junction, the two sides of a tight bend, or the two ways of a kink. Foot: where a corner's arc touches an edge chain. Ring: the part of a layer that runs round the arc.
  • Tip fill: the corner fill on the inner side of a tight bend or a kink.
  • Room: how far a corner's feet can lie along an arm. Extent: how far an output of a junction, bend or kink can lie from its point.
  • Window: the cell square grown by GP6's heights.window_m (section 5).

2. Interfaces

GP3 takes, in GP1's and GP2's names:

  • From GP1: Sections::way per way (half-width with its width and gauge rules, shoulder_m, reach_m, rank), the class fields that GP3 adds (section 10), the cell's decoded platforms with vertex heights, the cell frame. town has no source yet (Questions): GP3 passes false.
  • From GP2: per way its id, class, level and Samples (pos, s_m, z_m, tangent, bank, widen_m, walk, kind) and how each end ends (junction arm, joint, end, level change); per junction its point and Arms (way, station, heading, host, room_m, next); joints with stroke; the link ways of snapped ends, which are guest arms like any other (GP2, stage 5). A 7 m corner of two roads of 8 m half-width has its feet 15 m along the arms, so GP3 needs GP2's ROOM_MAX_M (30 m) ≥ 15 m. GP3 reads no Crossing: a crossing face comes from an overlap (4.7).

GP3 gives:

pub fn build_faces(graph: &WayGraph, features: &CellFeatures, rules: &Rules,
                   cell: CellKey, level: i8, slopes: bool) -> FacePlan;
pub struct FacePlan { pub cell: CellKey, pub level: i8, pub vertices: Vec<[i32; 2]>, pub faces: Vec<Face>,
                      pub edges: Vec<Edge>, pub corners: Vec<CornerArc>, pub stats: FaceStats }
pub struct Face { pub id: u32, pub owner: Owner, pub surface: Surface, pub level: i8,
                  pub rule: HeightRule, pub material: Option<WayId>, pub crossing: Option<WayId>,
                  pub rank: u8, pub inside: bool, pub reach_m: f32,
                  pub rings: Vec<Vec<u32>> }   // ring 0 outer, then holes
pub struct CornerArc { pub owner: Owner, pub centre: [i32; 2], pub radius_m: f64,
                       pub t_a: [i32; 2], pub t_b: [i32; 2], pub arc: Vec<[i32; 2]> }
pub enum Owner { Terrain, Way(WayId), Junction(JunctionId), Bend(WayId, i64), Platform(FeatureId) }
#[repr(u8)] pub enum Surface { Terrain = 0, Slope = 1, Carriageway = 2, Shoulder = 3, Verge = 4,
                  CornerFill = 5, Crossing = 6, RailBed = 7, Platform = 8 }
#[repr(u8)] pub enum HeightRule { Terrain = 0, Slope = 1, Owner = 2, Blend = 3, KerbOffset = 4 }
pub struct Edge { pub a: u32, pub b: u32, pub left: u32, pub right: u32, pub kind: EdgeKind, pub flags: u8 }
#[repr(u8)] pub enum EdgeKind { Continuous = 0, Kerb = 1, Wall = 2, Headwall = 3, Portal = 4,
                  DeckEdge = 5, CellBorder = 6 }
pub const SEAM: u8 = 1; pub const BLEND_JOIN: u8 = 2; pub const UNRELATED: u8 = 4;
pub const OUTSIDE: u32 = u32::MAX;   // past the window
  • Coordinates are i32 in the cell frame, in 1/16 world unit. Ring 0 has a positive shoelace sum (x east, y south), a hole a negative one. left is the face where the shoelace sum of (a, b, point) is positive.
  • Bend(way, dm) names a tip fill by its way and the stroke decimetres of its tightest sample. material is the way whose class and tags give the look; crossing the rail way under a crossing face; reach_m the slope reach of the face's class (0 for slope and terrain). rank is the index of the face's rank in ranks (0 wins): the overlay priority for GP4 and GP7. inside: the face lies in the cell square.
  • CornerArc: the circle of a fill (4.4), for GP4's rings and GP6's ring frame. GP5 flattens it with the faces.
  • The enum codes and field widths are the bytes of the face plan. Later items append codes and never reuse one. GP3 sets the edge kinds Continuous and CellBorder; GP4, GP6, GP12 and GP15 set the others.
  • GP4 gets layers(way, side, s) -> [(Surface, width_m, paved)], the rank slots, the corner engine and the mouth kinds. GP5 gets the plan for its debug draw. GP6 gets the rules, reach_m, the edge flags, the corner arcs and the caps of section 9. GP7 gets the planar map of the window with rank and inside. GP12 calls build_faces(deck level, slopes = false). GP14 and GP15 add ranks and candidates to the same slice.

3. Frame and determinism

  1. Every derived point is computed in f64 from GP2's global samples (Web Mercator, 1/16 world unit), rounded half away from zero to i64, and then the cell origin is subtracted. A cell-frame number never enters a float computation.
  2. Metres become world units through the Mercator scale at the point (libm::cosh).
  3. Transcendental functions come from libm. The crate's clippy.toml forbids the std sin, cos, tan, atan2, hypot, exp, ln and powf (unless GP1 did so); sqrt is exact and stays.
  4. i_overlay runs with one fixed solver, Solver { strategy: Strategy::Frag, precision: Precision::ABSOLUTE, multithreading: None }, and the options preserve_output_collinear: true, min_output_area: 0. ABSOLUTE keeps the snap radius at 1 unit, so a vertex moves only by the crossings within a few units of it; Frag takes one path at every segment count (Facts). The test sub_window proves the locality (Verification); if it fails, the crate nodes every crossing itself before i_overlay runs.
  5. No output depends on the order of a hash map. An owner id compares as GP2's order, which compares global positions, so two cells order alike.
  6. Cell lines. Before a slice, each candidate ring gets a vertex where it crosses one of the cell square's four lines: for x = X, y = y0 + round((X − x0)(y1 − y0) / (x1 − x0)) in i128, half away from zero; the same for y = Y. The rule reads only the segment, so both cells make the same vertex.

4. Candidates (stage 2a)

4.1 Chains and samples

  • A chain follows joints and runs through each junction along its host pair. It stops at a guest end, a free end, a level change and the end of GP2's input.
  • At each of GP2's samples: the left normal n, the half-widths h = half(class, tags) + widen, and the offsets of layers() per side.
  • At a joint of two half-widths, each runs linearly to their mean over joint_taper_m, or half the way where the way is shorter: no notch at a class change.
  • A kink is a joint whose two tangents differ by more than 2°; the chain then has two sections at the joint point.

4.2 Layers and bands

  • Per chain and layer, one candidate: the carriageway (−h_right to +h_left), and per side each outer layer between its inner and outer offset. A layer of width 0 has no candidate.
  • A candidate is the union of span pieces. The piece between samples i and i+1 is two triangles, (L_i, R_i, R_{i+1}) and (L_i, R_{i+1}, L_{i+1}), each turned to a positive area; a piece of zero area is dropped. The outer points of one layer are the inner points of the next (the same computed points), so no gap opens between layers.
  • The pre-union (section 5) uses NonZero, so the loop of an inner offset disappears and no band folds.
  • A piece belongs to the way of its span, Owner::Way. Carriageway: surface Carriageway (RailBed for a rail class), rule Owner. Shoulder: Shoulder, rule Owner. Verge: Verge, rule Slope (GP6, section 3 and 6).

4.3 Ends and joints

  • Free end: each layer gets a cap: the section turns 180° about the end point in steps of at most 10°, its offset linear from the left to the right value.
  • Level change (a bridge or tunnel part starts): a square end on the vertex's section. GP12 makes it a deck edge or a portal.
  • Kink: on the outer side, a fan of sections turns from the one way's normal to the other's in steps of at most 10°, split between the two ways on the bisector. On the inner side, the corner engine with inner_radius_m of the lesser class makes a tip fill, owner Bend(lesser way, dm of the joint), as in 4.5.
  • End of GP2's input: a square end, at least 106 m outside the window (section 9).

4.4 The corner engine (changed by the Revised design)

Input: two edge chains A, B that start at the corner's point C; the construction's point X (the junction point, or C for a bend or kink); each chain's seam offset; the layers past the seam edge on the corner side; the radius r0; each chain's room; the extent; the fill's label and rank.

  1. r = r0. If r0 < least_radius_m, there is no corner.
  2. Move each chain's seam edge by r along its sample normals, toward the corner side. Take the crossing of the two moved chains with the least sum of stroke metres from C (a tie: the least metres on A). No crossing within the rooms: step 6.
  3. O is the crossing, on segment i of moved A. The foot station on A is that of the projection of O onto seam segment i (outside the segment: step 6). The band builder inserts a GP2 Station sample there, and F_A is its seam point; F_B likewise. So feet, rings and bands share their end points, and |F − O| is r within the rounding.
  4. Tests: the feet lie within their rooms; the arc from F_A to F_B about O (the sweep under 180°) crosses neither seam edge between C and the feet; every point of the fill and the rings lies within the extent of X. A failed test: step 6.
  5. Build. The arc has n = ceil(Δφ / 10°) steps; arc point j for 0 < j < n is O + r(cos φ_j, sin φ_j), and points 0 and n are F_A and F_B. So the arc is a circle of radius r about O. Ring k has ρ_k(j) = max(0, r − w_k(j)), with w_k linear in j from the summed layer widths up to k at F_A to those at F_B.
    • Fill: the polygon C, seam edge of A to F_A, the arc, F_B, seam edge of B back. A second lobe near C stays under the carriageways (higher keys).
    • Ring k: the foot section points k−1 and k at F_A, arc k, the points k and k−1 at F_B, and arc k−1 back. Where ρ_k is 0, arc k runs through O.
    • Cuts: each layer past the seam edge whose ring has ρ_k > 0 at the foot loses its band from C to the foot on the corner side. A layer whose ring is 0 there keeps its band, and the two bands meet in a sharp corner of that layer.
    • Output: Corner { fill, rings, cuts, arc: CornerArc }.
  6. Shrink: r = 0.8 r. Below least_radius_m there is no corner (stats corners_dropped by pair); else step 2.

Invariants: the fill and each ring are simple; neighbouring rings share their arc points; ring ends are the band sections at the feet; no output point lies past the extent. A dropped corner leaves the union of the bands, which is valid; the pinch rule cuts the sharp tip that remains.

4.5 Tight bends (changed by the Revised design)

  • Curvature at sample i: κ_i = the signed angle from tangent i−1 to tangent i+1, over s_{i+1} − s_{i−1} in metres (at a chain's end, the one neighbour).
  • A sample is tight on side σ (the side of the centre of curvature) where σκ (h_σ + inner_radius_m) > 1: the inner edge turns tighter than inner_radius_m.
  • A tight sample C is a bend's point where no tight sample on its side within tip_window_m along the chain has a greater |κ| (a tie: the least stroke metres), and no junction point lies between. So the decision reads only tip_window_m each way.
  • The corner engine runs with A the inner carriageway edge backward from C, B the same edge forward, room tip_window_m each way, X = C, extent extent_m, radius inner_radius_m. Fill label: Owner::Bend(way, dm of C), CornerFill, material the way, rule Blend, rank junction. Rings as in 4.6 step 5.
  • Legs closer than 2r over the whole window give no crossing, and the gap stays: legs are never joined. Overlapping legs join by the band union. Two bend points of one bend give two fills; the key decides their overlap.

4.6 Junction areas and mouths (changed by the Revised design)

For each junction J with point P and arms in heading order (a tie: the lesser way id). Every candidate of J is cut to the disk of extent_m about P, except the blend part (step 4).

  1. Hosts. The host pair is one chain through P; its carriageway stays an owner face. A snapped end is GP2's link way, a guest arm at P.
  2. Pair rule. A guest g of host H takes pairs["<group of H>/<group of g>"], else pairs["default"]. Mouth kinds:
    • reach: the guest's carriageway reaches the host's carriageway edge through the shoulder (GP4: and the sidewalk). Blend part rank junction, fill fill.
    • stop: the guest stops at the host's core edge. Blend part and fills rank junction_low: the guest crosses an unpaved shoulder and the verge, and the host's edge line runs on.
    • join: the bands meet by key only; no blend part, no fill (rails at a switch, a road on a rail).
  3. Behind. Each guest's carriageway runs on behind P along its tangent at P by h_H + h_g. Its part past the host's middle line within h_H + h_g + 1 m of P is removed (a half disk on the line through P along the host's tangent). So a wide or oblique guest leaves no notch and no overhang.
  4. Blend part (if blend). s_seam is where the guest's middle line crosses the seam edge, in metres from P; none within the arm's room (step 5) gives s_seam = 0 (stats seam_missing). Δz = |z_g(s) − (z_H(s_H) + bank_H(s_H) · a)| at s = min(s_seam, room_m), from GP2's z_m and bank (linear between samples), with s_H the host station and a the signed distance across of that guest point: the owner rule's formula (epic, section 6.1). L = heights.blend_steep · Δz / return_grade(class of g) (GP6, section 4). The blend part is the guest's carriageway from its behind start to e_g = s_seam + L; e_g stops at the guest's end, at its next point, and at ramp_end_m from P (stats ramp_capped). The guest's own carriageway starts at e_g. Label: Owner::Junction(J), Carriageway, material g, rule Blend. The guest's shoulders and verges keep Owner::Way(g).
  5. Corners, for each pair of neighbouring arms whose sector is under straight_deg:
    • A host and a guest take the guest's rule; two hosts take <group>/<group> of the higher host; two guests take the rule with the higher guest as host.
    • r0 = radius_walk_m where the rule has it and either arm has walk on its corner side on its first segment, else radius_m. walk stands in for today's town test (Questions).
    • Seam edges: the host's core edge for stop, else the carriageway edges.
    • Room of an arm: GP2's room_m, times room_share where it is below GP2's cap ROOM_MAX_M (the next point is that close), so two corners on a short arm meet halfway; at most extent_m. X = P, extent extent_m.
    • Fill label: Owner::Junction(J), CornerFill, material the lesser arm (later class in the table, then narrower, then greater id), rule Blend. Each ring: its layer's surface and rank, Owner::Junction(J), material the lesser arm; a shoulder ring rule Blend, a verge ring Slope.
  6. Close junctions need no merge: their candidates overlap and the key decides. A guest that is a host at its next junction ends its blend part there (step 4).

4.7 Rail beds, crossing faces and platforms

  • A rail's carriageway layer is its bed: RailBed, rank rail_bed, half-width by GP1's gauge rule, rule Owner.
  • Crossing face: a patch whose winning candidate has surface Carriageway (a way's or a blend part's) and that a RailBed candidate also covers becomes Crossing; owner, material and rule stay; crossing is the rail way (the least id). This covers level crossings with or without a shared vertex, and a light rail in a street.
  • Platform: an area's rings (NonZero pre-union), or a line's buffer (section 7) on both sides with half-width width / 2, else platform_half_m. Label Owner::Platform(id), Platform, rule Owner, rank platform, reach_m = platform_reach_m. One without heights is skipped (stats platforms_skipped). A platform beats the bed, so GP6 can stand a wall at their edge.

4.8 Ranks and keys

  • Key: (rank index, class order of the material way, owner kind order (Junction, Bend, Way, Platform, Terrain), owner id, candidate number within its rule). The least key wins.
  • ranks, high to low: carriageway, junction, platform, rail_bed, fill, shoulder_paved, junction_low, shoulder, verge, slope, terrain. A shoulder takes shoulder_paved or shoulder by its class's shoulder_paved. GP4 inserts sidewalk after shoulder_paved.
  • Why: a mapped surface beats an invented one; a host's carriageway beats a guest's blend part; a fill beats the shoulders that it rounds.

5. Slice, labels and merge (stage 2a) (changed by the Revised design)

  1. The window is GP6's: the cell square grown by heights.window_m (86 m; GP6 sets its size and its edges). It holds every face that GP6 reads.
  2. Each rule's pieces become one candidate: a pre-union (Overlay, Subject, NonZero) cut to the window, then the cell-line vertices.
  3. Slice the window square by the string contours of all candidates and of the cell square (StringOverlay::with_options, add_string_contour, StringRule::Slice). Each patch lies on one side of each cell line.
  4. Per patch, an inner point: for each edge of ring 0 in ring order from its least vertex, its middle moved 2 units along the axis nearest to the inward normal (doubled integer coordinates, exact). The first such point that lies inside the patch (holes included) and more than 1 unit from every patch edge (exact i128 distance test) is the inner point. A slice moves an edge by less than 1 unit from its candidate's segment, so the point lies on the same side of every candidate edge as the patch. Its cover is the candidates whose box (a uniform grid) and polygon (exact integer test) hold the point. The label is that of the least key, else Terrain. A patch with no inner point is under 4 units wide: it takes the least key of the candidates that hold any of its vertices (boundary included), and the pinch rule merges it. Then the crossing rule of 4.7 applies.
  5. Neighbouring patches with equal labels merge into one face; across a cell line they stay two (section 6 treats them as one).
  6. Build the planar map: dedupe vertices, pair each directed segment with its reverse, give each edge its two faces. Kept collinear points leave no T-junction.

Invariant: each window point lies in exactly one face, and each face edge is an edge of the map.

6. Minimum width (the pinch rule) (changed by the Revised design)

  • A pinch of face F is a pair of segments s1, s2 of F's rings with points p on s1 and q on s2 where |pq| < min_width_m, the open segment pq lies inside F, and s1, s2 lie on different rings or the shorter way along the ring from p to q is longer than |pq| / sin(tip_deg / 2).
  • So a strip or neck narrower than min_width_m is a pinch along its length, and a tip sharper than tip_deg is a pinch from where its width is min_width_m to its apex. A wider corner never is, and stays sharp.
  • A cell line between two patches of one face is no boundary here. A window edge is; pinches within 2 min_width_m of it lie more than 85 m outside the cell and are ignored.
  • Search: a uniform grid of size min_width_m over the boundary segments; for each near pair, the part of each segment within min_width_m of the other (f64 in the global frame, rounded). The ring walk stops at min_width_m / sin(tip_deg / 2): the rule reads about 0.5 m.
  • The thin piece of a pinch is the convex hull of the two parts, cut to F. Its two candidate targets are the faces across s1 and s2 at the middle of each part (the face on the other side of the edge that holds that point). It takes the one with the lesser key; overlapping thin pieces take the lesser key. So a strip between two ways goes to the higher way, a gore's tip to the higher arm, a fill's thin end to the carriageway.
  • Apply: add the thin pieces as string contours, slice again, relabel (a patch inside a thin piece takes its target), merge. Repeat while pinches remain, at most 3 passes. A pinch that remains is counted (stats pinches_left) and fails check 1.
  • Why it ends: a pass adds only each piece's two closing hull edges. A part is maximal, so F is at least min_width_m wide past a closing edge, which meets the boundary at 90° − tip_deg / 2 = 71.5° or more: no new tip and no new neck. A pinch after a pass lies where two pieces with different targets met; pass 2 merges it, pass 3 is the bound, and check 1 proves it on the fixture.
  • A target depends only on the two faces beside the piece, so two cells decide alike.

7. Slope bands (stage 2b) (changed by the Revised design)

  1. An outer edge is an edge between a non-terrain face and a Terrain face, not on the window's edge.
  2. Buffer: per outer segment, the rectangle on the side away from the face, of width R = reach_m + 2 units; at each convex outer vertex, a kite (v, v + R n1, v + (R / cos(Δ/2)) n_mid, v + R n2), Δ the angle between the normals, halved while Δ > 90°. So the buffer holds every point within reach_m of the edge.
  3. All buffers form one candidate (Owner::Terrain, Slope, rule Slope, rank slope), pre-unioned, cut to the window, with cell-line vertices.
  4. Slice the window by the rings of the stage 2a faces, the slope candidate and the cell square. A patch keeps its stage 2a label; a Terrain patch inside the slope candidate becomes Slope. Slope patches merge into slope faces, whatever edge made them.
  5. The pinch rule runs again with targets among Slope and Terrain only; the non-terrain faces stay. A thin terrain piece between two bands goes to the slope. A thin slope piece between two non-terrain faces cannot occur, as stage 2a merged every thinner gap; one that occurs is counted.
  6. With slopes = false (decks), stage 2b does not run.

Invariant: each window point outside the non-terrain faces and within reach_m of an outer edge lies in a slope face, so GP6's slope meets the terrain at or inside the slope face's outer edge.

8. Output and cell borders

  • Keep every face of the window. A face lies inside or outside the cell square (inside), as the slice splits patches at the cell lines. Edges on the cell square get CellBorder, the window's edge OUTSIDE beyond; all others Continuous. The border is split at every face edge that meets it. Faces outside the cell are context for GP6 and GP7; only the faces inside are the cell's.
  • SEAM: an edge between a guest blend part of J and the host face that is its seam edge (the host's carriageway for reach, its core face for stop). GP11 draws the give-way line there.
  • BLEND_JOIN: an edge between two Blend faces; GP6 forms one blend region across it.
  • UNRELATED: an edge between faces of different owners, neither slope nor terrain, that no relation joins (one way; a way and its junction or bend; two ways at one joint or junction; two blend faces). GP6 applies its rule 6 there.
  • Order: vertices by (y, x); faces by (surface code, owner, least vertex index); rings start at their least vertex; edges by (a, b); corner arcs by owner and centre. One input gives the same bytes on every platform.
  • FaceStats: candidates, patches, slice segments; faces, vertices, edges; corners built, shrunk and dropped by pair; tip fills built and dropped; seam_missing, ramp_capped, platforms_skipped; thin pieces merged by surface pair; pinches_left.
  • No rule reads the traffic side: the faces are mirror-symmetric, so left-hand traffic (epic, risks) needs no value here; GP11 sides the give-way line.

9. Reach budget

GP2's rule: a decision reads data within R_d of its point and changes faces within R_e of it. A cell has complete data within GP1's MARGIN_M (192 m), and every chain of rules stays at or below 191 m (the 1 m: the Mercator scale over a cell, the rounding, the pinch rule's 0.5 m). GP1's reach table holds the rows and chains below. GP3's values are the natural sizes of its shapes. GP3 reads an arm only within its room, at most extent_m (4.6 step 5).

Construction R_d R_e Sum
Junction corner, rings, behind runs 20 m: the arms within their room extent_m + greatest reach: 20 + 10 = 30 m 50 m
Hosts of a junction 8 m (GP2) 30 m 38 m
Blend part 20 m: the seam and the heights within the room ramp_end_m 20 m: the guest's outer edges do not move, so no slope band changes 40 m
Tip fill, kink tip_window_m 10 m each way of C 30 m 40 m
GP2's room_m at a point 70 m (GP2) 30 m 100 m
Band, cap, taper the span (GP2) half-width + shoulder + verge + reach GP1's check, with verge_m
  • extent_m 20 m holds a 7 m corner and the behind runs of two roads of 8 m half-width (four lanes): a foot lies 15 m along and 11 m across, a behind run 16 m along and 8 m across.
  • Reach: GP3's constructions reach B = 40 m (corner, blend part; H has the slope reach). A face's full reach: F = 100 m, GP2's room_m plus GP3's corner.
  • Chains end in a face and add F: window, 86 + 100 = 186 m, the longest; H, 51.5 + 100 = 151.5 m. GP4 adds its walk terms to these rows (GP4).
  • GP6's blend radius (heights.blend_radius_m, 10 m): a fill and its shoulder ring lie within r + the shoulder of their seam edges and feet, and the reader checks the greatest radius plus shoulder under it. A ramp from the seam to e_g is at most ramp_end_m long with a source at each end, and the reader checks ramp_end_m ≤ 2 · blend_radius_m. GP6 lowers a cap where blend_far finds a point (GP6).
  • GP2's input ends at the work area's edge, MARGIN_M − 86 m = 106 m past the window, farther than F.

10. Rule-table fields

data/trailview/roads.json, per class (outside CLASS_FIELDS, so no option of the feature step changes). GP3 adds them because it reads them first (GP1, section 6):

Field Unit Default Why
group name rail (5 rail classes); road (motorway to road, living_street, service); track; path (path, footway, cycleway, bridleway, pedestrian, via_ferrata); steps Pair rules by group, not by 30 × 30 classes
inner_radius_m m 5 motorway to tertiary_link; 3 unclassified, residential, living_street, service, road; 2 track; 1 paths; 0 steps, rails Least radius of an inner edge in a tight bend; 0 turns tip fills off
shoulder_paved bool true for motorway to tertiary_link, else false Today's main roads pave their shoulders (Facts)
verge_m m 0 Today's band starts at the core's edge (Facts); the owner sets widths from the pictures
return_grade m/m 0.15 roads and tracks, 0.3 paths (epic, section 6) The ramp length; GP6 reads it too

data/trailview/plan.json (new, read only by the crate):

Field Unit Default Why
min_width_m m 0.15 Under the narrowest face (0.16 m kerb top)
tip_deg ° 37 Sharper tips are cut; a right angle stays
least_radius_m m 0.5 Below this a fill is not worth its vertices
straight_deg ° 150 As junctions.ts:21
room_share share 0.5 Two corners on one short arm meet halfway
extent_m m 20 A 7 m corner of two roads of 8 m half-width (section 9)
ramp_end_m m 20 Section 9; twice GP6's blend radius
tip_window_m m 10 How far along the curve a tip fill looks
joint_taper_m m 5 Width change at a joint without a notch
platform_half_m m 1.5 A platform line without width
platform_reach_m m 3 The slope band of a platform
heights.blend_steep 1 1.5 GP6's block (GP6, rule block); GP3 reads it first, GP6 measures and sets it
heights.blend_radius_m m 10 GP6's value; section 9 checks against it
ranks names 4.8 The overlay order, as data
pairs map below Mouth kind, radius and blend per group pair

pairs (host/guest): road/road reach, 7 m, radius_walk_m 5 m (today's rural and town radii), blend; road/track stop, 3 m, blend; road/path stop, 1 m, blend; track/road reach, 3 m, blend; track/track reach, 3 m, blend; track/path stop, 1 m, blend; path/path reach, 1 m, blend; road/steps, track/steps, path/steps stop, 0, no blend; rail/rail, road/rail, rail/road join, 0, no blend; default join, 0, no blend (no invented geometry).

Code constants: the 10° arc step, the 0.8 shrink, the 2° kink, 3 pinch passes, the 2-unit pad and inner point. If GP1 supports values by place, GP3 uses that.

11. Edge cases

  • Empty input: one Terrain face, the window. Ways only in the window: faces outside the cell; their slope bands can reach it.
  • A junction, bend or kink outside the cell whose output reaches it: both cells build it from the same inputs (section 9).
  • Hairpins: overlapping legs join; legs closer than 2 · least_radius_m keep a strip whose tip the pinch rule cuts.
  • Snapped end: GP2's link, a guest arm.
  • Two arms with nearly one heading, or a sector of 150° or more: no fill; keys decide; the pinch rule cuts a gore's tip.
  • Wide roads: past 8 m half-width the extent test shrinks the radius; GP1's 15 m cap holds the band budget.
  • A path over a road with no shared vertex, or two ways on top of each other: the lesser key wins; the edges are UNRELATED.
  • A self-intersecting ring or a self-crossing way at one level: NonZero gives a valid region; the bend search ignores the crossing.
  • Bridges and tunnels: not at level 0; the ground ends square; GP12 calls with slopes = false.

12. When a rule cannot fit

  • A dropped corner leaves the band union; a capped ramp ends at ramp_end_m; a pinch left after 3 passes stays, is counted and fails check 1.
  • No rule emits a face to hide a case; every output is a valid planar map.

Plan

  1. data/trailview/plan.json: create (section 10). data/trailview/roads.json: group, inner_radius_m, shoulder_paved, verge_m, return_grade per class.
  2. GP1's rule reader (host/obc-ground-plan/src/rules.rs or GP1's name): PlanRules from plan.json, the new class fields in Sections, verge_m in GP1's band check; check that each class has a group, each pair names known groups and kinds, ranks names each rank once, and section 9 holds.
  3. src/faces/types.rs: section 2. faces/frame.rs: rounding, Mercator offsets, split_at_cell_lines, the inner point, point-in-polygon, buffer.
  4. faces/bands.rs: chains, curvature, layers(), span pieces, caps, kinks, tapers, foot samples, cuts.
  5. faces/corners.rs: corner(a: &EdgeChain, b: &EdgeChain, spec: &CornerSpec) -> Option<Corner>, with Corner { fill, rings, cuts, arc: CornerArc }.
  6. faces/bends.rs: bend points, tip fills. faces/junctions.rs: pair rules, behind runs with the half-disk cut, seams, blend parts, corners. faces/rails.rs: beds, platforms.
  7. faces/slice.rs: pre-union, window cut, slice, labels by key with the crossing rule, merge, planar map. faces/width.rs: pinches, thin pieces, passes. faces/slopes.rs: outer edges, buffers, stage 2b.
  8. faces/mod.rs: build_faces, output order, flags, stats. faces/check.rs: the checks of Verification, for the tests and the debug tool.
  9. GP1's debug tool: a faces layer (faces by surface, edges, seams in yellow, the cell border, junction points, corner centres with radius, thin pieces in magenta, capped ramps in orange) and a junctions mode for contact sheets by group pair.
  10. builder/web/tests/browser/trailview/road-views-top.json: add tears-zigzag-top with its centre, by GP0's method.
  11. Tests, READMEs, and the conditional changes of Files. The pull request carries Mode: change #<this issue>, Requirements: none and "public docs: unchanged".

Files

  • data/trailview/plan.json: create: the face and pair rules, GP6's two heights values.
  • data/trailview/roads.json: change: the class fields of section 10.
  • data/trailview/README.md: change: a row for plan.json.
  • host/obc-ground-plan/src/rules.rs, src/sections.rs (GP1's reader): change: new fields and checks.
  • host/obc-ground-plan/src/faces/{mod,types,frame,bands,corners,bends,junctions,rails,slice,width,slopes,check}.rs: create.
  • host/obc-ground-plan/src/lib.rs: change: pub mod faces.
  • host/obc-ground-plan/clippy.toml: create or change: section 3, item 3.
  • GP1's debug tool: change: the faces layer and junctions sheets.
  • host/obc-ground-plan/tests/faces.rs, tests/faces_fixture.rs: create.
  • host/obc-ground-plan/README.md: change: the face picture and check commands.
  • builder/web/tests/browser/trailview/road-views-top.json: change: tears-zigzag-top.
  • tools/testing/suites.toml: change only if obc suites check asks for plan.json.
  • Cargo.toml (root): change only if faces_fixture takes over 60 s in the test profile: [profile.dev.package.i_overlay] opt-level = 3, as at Cargo.toml:139-146.

Verification

  • Checks:
    • obc test -p obc-ground-plan:
      • faces_fixture, every fixture cell, target 0 each: (1) partition: face areas sum to the window area exactly (i128), their union has the same area, every ring is simple, every edge has its two faces, and the pinch search finds nothing; (2) neighbours: each shared border has the same vertex sequence in global coordinates, and on each border edge the inside faces of the two cells carry the same surface, rule, rank, owner, material and crossing (ways and junctions compared by global position); (3) every candidate of a junction, bend or kink lies within extent_m of its point, every ramp within ramp_end_m; (4) a cell built twice, alone or in the loop, gives equal bytes.
      • faces, synthetic inputs, each with the partition and its shape: two squares that share an edge give two faces; sub_window: a window and a sub-window give the same patches bit for bit in the sub-window less 1 m; a T of two roads (two 7 m circular fills, the seam on the host's carriageway edge); a Y at 20° (the fill shrinks, the gore's tip is cut); a track and a path into a road (stop, the host's edge whole); a hairpin with overlapping legs; one with legs 1 m apart (the strip stays); a kink; a free end; a link; two ways 0.1 m apart (no strip remains); a road over a bed (a crossing face); a platform beside a bed; a way along a cell line and a junction on a cell corner (check 2 on both cells).
    • obc exec cargo clippy -p obc-ground-plan --all-targets -- -D warnings; cargo fmt --all.
    • For roads.json: obc test -p obc-trailview-features (solver rows and step options unchanged) and, in builder/web, npx vitest run src/lib/trailview (bins.test.ts reads the table).
    • obc suites check if suites.toml changes; obc test affected --base origin/ground-plan if the root manifest changes.
  • Measurements (one release run of the debug tool's fixture mode): stage 2a and 2b native time per cell (median, p95, max, the five slowest cells); per cell candidates, slice segments, faces, vertices, edges (median, p95, max, sums) for GP7; the stats totals, with corner radii by pair; the run time of faces_fixture. Gate, provisional, from the epic's 2 s jump budget as GP2's 4 ms: stages 2a and 2b p95 ≤ 8 ms native per cell. GP7 sets the final gates with the whole cell build (epic, section 15).
  • Pictures: top-down from the debug tool at the centres of road-views-top.json, as wide as GP0's top shots, on one slider page with GP0's top shot and GP1's input picture as "before". No eye-height picture: faces have no heights until GP6. What the owner looks for:
    • v06, v07, v08, v11, v14, every conn-*: guests reach the host's carriageway edge or stop at the paved edge with a small fill; no wedge, notch or sliver; the host's edge runs on.
    • t-tertiary, x-tertiary, junction0, j-tt-a: 7 m corners on residential roads and primaries, smaller only past 8 m half-width or where an arm is short, 5 m where a sidewalk is; rings of shoulder round each arc; no fill over another way.
    • v17, i07-hairpin, d-hairpin, hp: tip fills round inner edges; the gap between close legs stays.
    • tears-zigzag: fans and tip fills, no shard. v16, rail-close: crossing faces, beds, platforms. b45-bridge-junction: square ground ends.
    • Contact sheets: each junction within 100 m of a place of road-views-top.json, a 40 m tile each, by group pair.

Done when

  • build_faces builds level 0 for every fixture cell, and checks 1 to 4 of faces_fixture report 0.
  • Every case of faces passes, sub_window included.
  • plan.json and the class fields exist, the reader checks them and section 9, and no rule value of section 10 lives in code.
  • The feature step's options and the viewer's tests do not change with roads.json.
  • The pull request shows the measurements under the gate, the slider page and the contact sheets, and the implementer has looked at each picture.
  • The review's findings are resolved, CI is green, and the pull request has merged into ground-plan.

Out of scope

  • Kerbs, sidewalks, driveways, zebras, buildings: GP4.
  • The WASM bridge, the viewer's debug draw, check 7: GP5.
  • Heights, walls, other edge kinds, the blend method, the owned region: GP6. The mesh, borders, strip, floors: GP7.
  • Decks and portals: GP12. Rail details: GP13. Water: GP14, GP15. Placement: GP16, GP17. The bake: GP18.

Questions for the owner

Owner decision (2026-11-03): every recommendation in this section is accepted.

Epic note: no item gives the town flag (GP1 names GP4; GP4 reads the bake's walk). GP3 passes town = false and takes the 5 m town radius where a sidewalk (walk) is. A footway in a town then takes the path cap of 0.6 m instead of paving's 1.0 m (GP1, finishes) until a town input exists.

Review notes

  • Kept: the reach budget: section 9 holds every chain at or below 191 m (epic, section 2; GP1's reach table).
  • Kept: GP4 expects the pair rules in roads.json: GP4.md:63 puts its walk block in plan.json, GP3's table, so plan.json stays their one home.
  • Kept: GP5 expects edges as polylines: GP5.md:85 flattens a, b, left, right, kind and flags, 6 words per edge, so segments stay.
  • Kept: a limit on segments per cell: Frag takes one path at every size (section 3), and the time gate bounds the cost.
  • Kept: Plan step 11 edits GP0's file: GP0 has no tears-zigzag place (GP0.md:27), and the debug tool takes its places from that file; the step adds one row after GP0 merges.

Generated by Claude Code

Activity

  1. timohueser commented on Nov 3, 2026

    @timohueser
    OwnerAuthor

    Deviations from GP2 (PR #3123), for this sub-issue: junctions, joints and ends carry group: Group (Way, Rail, Water) instead of family; Part also holds family, class and level; Span has a chord flag; graph::build(cell, input, &Sections) takes the sections. A snap foot that lands on the target's end makes a joint, not a junction (G2 needs 3 or more arms); a link's foot arm is always a guest. A Station sample sits at every crossing point on both ways and at each implicit junction, deck end and snap foot (an existing non-grid sample within 6.25 cm is reused). At a junction of paths only, the pair with the better class is the host, so a short footway stub can host a flight of steps (conn-path-off-road). The graph's build p95 is about 3.2–3.6 ms of the 4 ms gate on the shared PC; GP3's work adds to the same cell. See the "Implementation deviations" section of #3098.

  2. timohueser commented on Nov 3, 2026

    @timohueser
    OwnerAuthor

    Implementation plan

    The design of the body holds. This comment gives the order of the work, the invariants that the code keeps, and the places where the code takes a simpler path.

    Stages of build_faces(graph, input, rules, cell, level, slopes)

    1. Ways of the level. Level 0 takes the Ground ways of the road, path and rail families (Way::level, not Part::level). A level k > 0 takes the ways of deck k − 1. Water is GP14.
    2. Sections. Per sample of each way: the left normal n = (t_y, −t_x) (the spec's left, x east, y south) and per side the offsets of the layers (carriageway edge, shoulder, verge). Each derived point is global sample + round(offset · n / metres_per_unit(y)), rounded half away from zero, then minus the cell origin. No cell-frame number enters a float.
    3. Corners first (junction corners, tip fills of bends and kinks). Each corner gives its foot stations. A foot is a new sample on its way, linear between its two neighbours. Then the bands read the samples with the feet, so a fill, its rings and the bands share each foot point.
    4. Candidates. A candidate is a label, a key and a list of pieces. A piece is a polygon with a positive winding everywhere it covers: a strip of convex positive quads, or a triangle turned positive, or the rings of a platform area. A point is in a candidate when a piece covers it (and the candidate's minus, the half disk of a behind run, does not).
    5. Slice. One StringOverlay slices the window square by the outline of every piece and by every zoom-16 cell line in the window. Before the slice, each piece ring gets an exact vertex where it crosses a cell line (the rule of section 3.6, on every cell line, so all cells make the same rings). Solver Frag, Precision::ABSOLUTE, no threads, collinear points kept.
    6. Labels. Each patch takes its inner point (section 5.4) and the least key of the candidates that cover it, else Terrain. Then the crossing rule (4.7).
    7. Planar map. Dedupe vertices, pair each directed segment with its reverse, join patches of one label across a shared edge that is not on a cell line. Rings come from the half-edge cycles, split at a repeated vertex.
    8. Minimum width. The pinch search of section 6 on the map. The ring walk goes along the face's boundary across cell lines up to min_width_m / sin(tip_deg / 2): a pinch is a pair of facing segments closer than min_width_m that the walk does not join within |pq| / sin(tip_deg / 2). Thin pieces go back as strings with their targets; slice, label and map again; at most 3 passes.
    9. Slopes (2b). Buffers of the outer edges, pre-unioned once, slice again with all strings, terrain patches in the buffer become Slope; then the pinch passes with Slope and Terrain targets only.
    10. Output. Vertices by (y, x), faces by (surface, owner, least vertex), edges by (a, b), the flags, the stats.

    Invariants

    • Planar partition. Every face comes from one slice of the window: each window point lies in exactly one patch, each patch in one face. Checked: areas sum to the window area (i128), the union of all faces has the same area, every ring is simple, every edge has a face on each side (or OUTSIDE on the window edge).
    • No gap, no overlap by construction. Candidates overlap freely; only the slice makes edges, and the key decides each patch. A rule that cannot fit makes no candidate (or a smaller one); it never makes a face.
    • Minimum width. After the passes, the pinch search finds nothing (check 1). A pinch left after 3 passes is counted in pinches_left.
    • Cell borders. Every input of a decision is global (GP2's samples, global positions, libm). The cell-line vertices are exact and read only their segment. The window is 86 m past the cell, and every chain stays at or below 191 m (section 9). So two neighbouring cells see the same pieces near their border, and i_overlay's ABSOLUTE snap changes a vertex only by crossings within a few units. Checked: the same vertex sequence on each shared border and the same attributes on each side (check 2), and sub_window.
    • Owners in keys. GP2's way ids are cell-local, and two cells can order them differently (a part is trimmed to each cell's work area). So the key's owner term is global: the owner tile and feature of the piece's span, then the span's start vertex; a junction's global position.

    When a rule cannot fit

    • Corner engine: no crossing of the moved chains within the rooms, a foot outside its segment or room, an arc that crosses a seam edge, or a point past the extent: shrink r by 0.8; below least_radius_m no corner (corners_dropped). The bands' union stays.
    • Blend part: no seam crossing in the room gives s_seam = 0 (seam_missing); a ramp past its caps ends there (ramp_capped).
    • Pinch: 3 passes, then counted.

    Simpler than the body, same result

    • No pre-union per candidate (section 5.2): the slice takes the pieces' outlines, and a patch's label reads the pieces that cover it. NonZero is the same as "some piece covers it", because every piece has a positive winding. Only the slope buffers get one pre-union (they overlap much).
    • The slice cuts at every cell line in the window, not only the cell's four lines: each patch lies in one cell, and every cell slices the same way.
    • heights.window_m (86) goes into plan.json next to GP6's two other values, so the reader checks the window chain.

    I report every further deviation in the pull request.

  3. timohueser commented on Nov 3, 2026

    @timohueser
    OwnerAuthor

    Owner decision (in the orchestrating session), after the first implementation stopped (two failed attempts at the minimum-width rule; about 480 ms per cell against 8 ms): continue with (a) + (b), with a design review before more code.

    • (a) No thin piece by construction: a corner fill ends where its width reaches 1.25 × min_width_m, and its cusp becomes part of the arm's carriageway; rings and other built-in tapers end the same way. The pinch rule then meets only slivers from the input.
    • (b) The pinch rule edits the planar map locally (split along the closing edges, relabel, merge) instead of re-slicing the window per pass.
    • First the implementer writes the revised design into this issue (cost per stage against the 8 ms gate, and the root causes of the 4 area-fault cells and the 5 border differences of the first attempt); then a fresh adversarial review at xhigh; then the code on claude/gp3-faces.
  4. timohueser commented on Nov 3, 2026

    @timohueser
    OwnerAuthor

    Revised design is in the body: section "Revised design" (R1 to R7), before "Design". It covers built-in tapers that end at 1.25 × min_width_m, one corner engine with a clearance rule (turn shapes for hairpins), the local pinch edit on the planar map, the exact root causes of the 4 area faults and 5 border differences, and the cost model. Sections 4.4 to 4.6 and 5 to 7 are marked where it changes them. Pictures of every problem and probe: /media/timo/OSM1/tmp/ground-plan/gp3/design/INDEX.md. No implementation code changed for this; the probes are not in the branch.

  5. timohueser commented on Nov 3, 2026

    @timohueser
    OwnerAuthor

    Owner decision (in the orchestrating session), after the probes of the patched piece approach: the probes showed new breaks at unusual inputs (the v07 V apex cut a leg square; a blend part stuck out as a flap at the i07 junction). Before the design review, the implementer probes a core that is valid by construction: carriageways as exact offsets of the centre lines with round joins, junction faces where carriageways overlap, corner fills by a closing (offset out by the corner radius, then in) that joins the carriageway, shoulders and slopes as outward offset bands. The probe shows before and after pictures of the worst places, checks 1 and 2 over the fixture, and the time per cell. The design that goes to review follows the probe's result.

  6. timohueser commented on Nov 3, 2026

    @timohueser
    OwnerAuthor

    Handover state (orchestrating session, end of day):

  7. timohueser commented on Nov 3, 2026

    @timohueser
    OwnerAuthor

    Core v3 status

    Branch claude/gp3-faces-v3 @ dec9870 (pushed; the last commits are WIP), no PR. The design is the "Core v3" section of the body. Pictures (second machine): /home/user/gp-pictures/gp3/ (step1/, item1/ with shoulder-ring.png, each with an INDEX.md). Older pictures: /media/timo/OSM1/tmp/ground-plan/gp3/v2/. The work moves to timosPC.

    Numbers

    8d2464c 215e990 (item 1, best of 3, back to back) dec9870 (item 2 WIP, one run, not calibrated)
    crashes / partition / check 2 (480 borders) 0 / 0 / 0 0 / 0 / 0 0 / 0 / 0
    shards 0 0 0
    kinks 43 9 (per face ring) 30 (along the paved outline, see below)
    fragments 14 18 8
    slivers / jogs 72 / 62 63 / 74 4 / 0
    bent borders (accepted) 96 95 89
    town median, timosPC equivalent 34 ms 33.6 ms not measured (raw 57 ms on this machine, one run; 8d2464c was 77–87 ms raw here)
    rural median, timosPC equivalent 2.1 ms 2.6 ms not measured (raw 4.1 ms; 8d2464c 2.9–3.5 ms raw)

    Done since 8d2464c

    • Step 1: the junction corner radius is a class rule (corner_radius_m, corner_radius_walk_m in roads.json; the lesser value of the two arms). pairs keeps mouth and blend. The values are proposals.
    • Item 1: a descending ladder of radii for every round (each radius tested in full); a round may cut into its arms' strokes by their sag_plan_m; rounds at the corners of the paved outline that no point's round shapes; the kink measure (owner decision): the turn within SUPPORT_M about a concave vertex, judged against the least inner_radius_m of the ways at the corner.
    • Item 2 (half done, WIP): the precision rule. After the one slice and the labels, the patches are snap-rounded to a global grid of PRECISION = 4 units (about 6 mm): every vertex moves to its grid point, and every edge runs through the grid point of each vertex whose open grid square it passes. A vertex that only one cell holds never rounds onto a cell line, and a grid square on a cell line holds only the edges on that line, so two cells round their shared border alike. A segment and its reverse in one patch cancel; a group that falls apart gives one face per outer loop, with each hole in the least outer loop that holds it. Result: jogs 0, slivers 4, fragments 8, check 1 and check 2 hold.
    • Owner decision (b) started: an outline round gets band rings, the same operation as a point round (band_rings), at the band offsets of the ways along its two edges.
    • The kink check now walks the paved outline across the borders of paved faces (a face-border vertex no longer hides a corner). This raised the count from 12 to 30: about 12 are needle tips of land between ways that overlap without a graph point (a GP2 item), 3 are junction corners beside a rail bed, and the rest are corners at joints and junctions with paths. This change needs the owner's view.
    • The bent-border check allows the precision: a border is straight within 2 × PRECISION.

    Unfinished in item 2

    • A calibrated bench against 8d2464c and a stage profile (snap rounding was 54 ms of a town cell in its first form; the grid lookup of dec9870 brings one run to 57 ms town in total, not yet calibrated).
    • cargo test, clippy and fmt on dec9870 (215e990 passed all three).
    • Synthetic tests of the precision rule; the remaining 4 slivers and 8 fragments; the i07 and p00–p02 markers checked again; the shoulder-ring picture after the change.

    Next, in order

    1. Finish item 2 (above), with pictures and the calibrated bench.
    2. Owner decision (b): finish and show the shoulder ring on outline rounds (same place as shoulder-ring.png, before and after).
    3. Slice cost bound: one shallow crossing near other edges can make the one slice 25 times slower (GP4 probe: 31 to 760 ms; GP3 met it with outline-round sides 3 units inside the paved edge, now 32). Find a general bound and measure it with a worst-cell table (p95 and max per cell).
    4. Junction region pieces (a region relabels a patch of its way that another way's carriageway cuts off) and the remaining corners (joints of a road and a path, paths along a road arm, rail beds beside a junction).
    5. GP2 items, as a comment on this issue: grazing overlaps without a graph point (they make the land needles above); short links between close junctions.
    6. Rail beds (gauge width rule), level-crossing faces, platforms, edge flags (SEAM, BLEND_JOIN, UNRELATED), CornerArc fields, the synthetic faces tests and sub_window, the torture set as one 2x contact sheet.
    7. Before the PR: remove the 16 stray files under v4/ (added in eae4b9b).
    8. PR body notes: i_overlay 4.0.7 → 9.1.0 with its measured WASM size effect on GP5's bridge, the root Cargo.toml profile change, the bent-border decision, the kink-measure decision, the precision rule.

    Time gate (owner): the timosPC-equivalent town median stays near 34 ms (8d2464c), with no regression near 2×; any increase needs a reason; 50 ms is the ceiling for the whole face stage with GP4's sidewalks. Every bench reports 8d2464c and the head run back to back, with the ratio × 34 ms (town) and × 2.1 ms (rural).


    Generated by Claude Code

  8. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Owner rule (in the orchestrating session) for a way's own turns: the inner edge of a turn never has a radius smaller than the class's inner_radius_m. One general rule: the closing of the way's own stroke at each turning point, with r = inner_radius_m, clipped to the turn's corner zone. The land between hairpin legs is paved only where the legs are closer than 2 × inner_radius_m, and stays terrain beyond that. This replaces the step-04 rule that filled between a point's two arms up to extent_m (that rule paved whole hairpins; rejected). Junction corners keep the pair radius, in their corner zone only.

  9. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Core v2 decision (orchestrating session): the rounding is scoped by the carriageway outline, not by graph points. Every concave place of the carriageway union per level (a corner, or an arc tighter than the class inner_radius_m) is a corner feature. Each gets r = inner_radius_m (the lesser class of the edges that meet), clipped to its zone. This sees land tips between arms of different graph points, V apexes, U-turns and junction inner corners alike. Land strips between min_width_m and 2r end in a tangent semicircle of half their width; thinner strips are paved by the sliver guard. A fixture check counts kinks (concave corners or arcs tighter than inner_radius_m − 10 %) along every carriageway edge next to land; the target is 0. Junction pair closings keep the pair radius. Next: a profile of the engine calls and a restructure to direct roundings plus one overlay per cell (the town cost of 650 ms median is too high).

  10. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    The body now has a "Core v2" section (before "Revised design"). It replaces R2, R3 and R5 and the special pieces: invariants, the operation list, the case distinctions that remain with their reasons, the determinism plan, the reach rows, the measured fixture numbers and the open problems. Code: branch claude/gp3-core-v2 at 24a0877. Work in progress on the inner-radius corners of the carriageway union: branch claude/gp3-core-v2-corners-wip (not merged; it regresses i07 and v07). Pictures and their index: /media/timo/OSM1/tmp/ground-plan/gp3/v2/INDEX.md.

  11. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Handover (orchestrating session, 2026-11-04), written so a fresh session can continue:

    Branches

    • claude/gp3-core-v2 @ 24a0877: the last good state, no PR.
    • claude/gp3-core-v2-corners-wip @ 140fae6: rounding scoped by the carriageway outline. Not merged; it makes i07 and v07 worse.
    • The design is the "Core v2" section of this body. The pictures are in /media/timo/OSM1/tmp/ground-plan/gp3/v2/INDEX.md.

    What holds

    • Integer, deterministic strokes with round joins and a union per way. This is the owner's "no special cases" principle, and it handles the v07 V apex and keeps i07's hairpin legs apart.
    • Crashes 0 and partition faults 0 over the 256 fixture cells. The bench runs under a 3 GB cap.
    • i_overlay goes from 4.0.7 to 9.1.0. The old version loops on one fixture union (now a unit test) and OOM-crashed the PC. This dependency change needs a review, including the WASM size.

    Open, in order

    1. Thin parts: 7,274 hits in 129 cells. Most are tips where the outlines of unrelated ways cross at shallow angles. Proposed general rule: a face that loses an overlap ends with a straight seam across itself, the same rule as at junction seams, so no tip can exist.
    2. Owner rule, minimum inner radius at every concave corner: not yet held. A land tip between arms of two different graph points is never rounded. Scoping by the carriageway outline is the approved direction (see the comment above), but the WIP is unstable.
    3. Cost: town cells take 650 ms median and 1,990 ms p95, and 90 % of it is the per-point closings. The approved plan: compute every rounding directly (the tangent circle to two edges), build all primitives as polygons, then ONE overlay per cell with priority labels. First, profile the engine calls and vertices per cell.
    4. Borders: 4 of 480 still differ.
    5. Not done yet: the torture set (only the hairpin cases exist) and a definition of the kink check that can gate (27,858 raw hits; it needs a support length).
    6. Not built: platforms, mouths and edge flags.

    Owner questions

    • Is road/path r = 1 m right? It gives small corners at j0.
    • Shoulder rings end square where a narrower arm begins; a taper would be a sliver.

    Rules for the next agents

    • "No special cases".
    • Run every geometry run under systemd-run --user --scope -p MemoryMax=3G -p MemorySwapMax=0 timeout 600.
    • Print one line per cell in a bench.
    • Push after every step.
  12. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Owner clarifications (orchestrating session, 2026-11-04). They change the Core v2 design:

    1. Road/path corner radius: 1 m is right.
    2. "Sliver" was misread. The fault the owner wants impossible is garbage geometry: random shards stretched across a road, slivers from numerical leftovers or from mismatched pieces, any face that no rule shaped. Intended narrow geometry is valid and wanted: a shoulder that tapers out where the next arm has none, a strip of land that narrows to a point, a corner round that runs tangentially into a road edge.

    Consequences:

    • The "no face thinner than min_width_m" reading of check 1 is wrong. Its 7,274 "thin-part hits" mostly count legitimate tapers. Check 1 keeps no overlap, no gap and valid polygons. Its thin-face part becomes a check for faces that no rule shaped: numerical slivers and 1-unit jogs, near-coincident edges from separate operations, shards across a way. Measure that count again.
    • Simplify what only existed to avoid legitimate tapers: shoulder rings taper out instead of ending square; drop "pave land strips thinner than min_width_m" unless the strip is a numerical leftover; reconsider seams placed past the rounding only to swallow cusps.
    • GP7's mesh must triangulate tapers cleanly; at a taper's tip the minimum-angle bound follows the input angle.
  13. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Review: the GP3 approach against other road engines and the literature

    Question (owner): GP3 does not get good hairpins and junctions with simple rules and a reasonable time per cell. Is the approach wrong, in GP3 or in the epic? Does the latest approach agree with the literature?

    Clarification (owner): thin parts of correct geometry are valid. Only artifacts are faults: numerical slivers, 1-unit jogs and shards. So GP3 has no minimum-width rule and no pinch pass.

    Answer

    1. The latest approach is right. It has strokes with round joins, a tangent circle at each inward corner of the merged carriageway, priority labels and one integer overlay per cell. Each robust system in the survey makes a corner with a tangent arc (or a Bézier on the two tangents) of a radius by class:

      • StreetGen (Cura, Perret, Paparoditis 2015) is the closest match. It builds street surfaces in PostGIS, for all of Paris in under 10 minutes on one core.
        • A corner centre is where the buffers (half-width + r) of two roads cross. The radius shrinks until it fits, then falls back to 0.15 m, else the corner gets no arc.
        • The surface comes from all edges at once (ST_BuildArea). The authors found it too difficult to link edges to arcs by hand.
      • Other systems use the same primitive:
        • Civil 3D: curb returns;
        • SUMO: a corner radius of 4 m by default, a Bézier on the two edge tangents (NBNodeShapeComputer);
        • Cities: Skylines: corners against the left and right neighbours of each segment end;
        • X-Plane: corner pieces per pair of adjacent arms;
        • RoadRunner;
        • Wilkie, Sewall and Lin 2012: a turning circle at each node.
      • No road system in the survey makes its corners with a morphological closing. A closing fills each gap narrower than 2r, so it joins hairpin legs. Zones only limit where this happens.
    2. Why the two earlier attempts failed. Most of their time and most of their open faults came from three rules that act on the whole shape:

      • the minimum width (an opening): this rule goes, by the clarification above;
      • the closings for rounds: 90 % of core v2's time in a town cell;
      • the slope buffers (a dilation): about 260 ms of a town cell in attempt 1 (R7).

      The latest approach removes the first two. The third stays (point 3).

    3. The epic's structure holds: one 2D plan, then heights, then a mesh, with floors under it. The literature adds one rule for the order of work: robust systems decide the topology before the geometry. On the whole graph they do three things:

      • they fit the centre lines to a minimum radius;
      • they merge close or near-parallel arms;
      • they collapse short links.

      Then they build each junction locally.

    Points to add or measure

    1. Minimum radius of the centre line. This is a bake item after GP3, and GP3 does not wait for it.
      • Today: the bake's plan fit (host/obc-trailview-features/src/roads/align.rs, fitted) holds each sample within plan_tol_m (0.3 to 1.5 m) of OSM and has no curvature bound. So a mapped V keeps its tip: a 30° V on a residential road gets a radius of about 0.2 m.

      • The result: the stroke gives the outer edge a radius equal to the half-width (2.5 m), with a large paved wedge inside. That geometry is valid, but no road has that shape.

      • Real hairpins have radii of 6 to 15 m. SN 640 198a uses an inner radius of 6.05 m, and EU vehicles turn within an outer radius of 12.5 m (Ciampa and Olita 2022).

      • Other systems limit the curvature before they build edges:

        • Outerra's road interpolator limits it; before that, "centre lines in tight turns would deform and vanish";
        • SUMO has --geometry.min-radius (9 m) with .fix;
        • Cities: Skylines adds a node at a turn that is too sharp;
        • Wilkie et al. fit each centre line as lines and arcs with the largest smallest radius.

        An offset at distance d is clean only where the curvature is less than 1/d.

      • Proposal: the fit holds |κ| ≤ 1 / (half + widen_m + inner_radius_m), with a cap on the move from OSM. That is 7 m for residential roads, 10 to 11.5 m for main roads and 2 m for paths. Then most turns need no round, and GP6's way frames stay valid there.

      • Open question: at a very sharp V, does the fit cut the tip or move the curve outward? Pictures decide.

    2. Grazing overlaps.
      • Today: GP2 makes a same-level crossing an implicit junction (graph/crossings.rs, Outcome::Implicit). It skips crossings under GRAZE_DEG (20°, sections.rs) and leaves them to the overlay. There, "the better key wins" leaves long tips. Open problem 3 of this issue traces most pinch hits to these places.
      • Other systems decide them in the graph:
        • SUMO joins arms within 20° into one direction;
        • OSM2World skips pairs within 10°;
        • blosm clusters parallel ways;
        • osm2streets folds side paths into the road.
      • Proposal: if the pictures show shards there, GP2 decides them (a joint or a merge where two ways run together), not the faces.
    3. The slope band as a face.
      • Cost: it is a 10 m outward offset of each carriageway, the most expensive band.
      • GP6 does not need it as a face. Its slope rule gives G = T at and past the reach. So the rule can run on terrain faces within the reach, and the owned region can come from a distance test.
      • No engine in the survey has slope faces. They change the heights with a blend zone (Outerra, Proland, Unreal landscape splines, Cities: Skylines).
      • Proposal: measure the band's cost. If it is large, remove slope faces. verge_m is 0 for each class, so verge faces are not necessary either.
    4. Corners on a polygonal outline.
      • The stroke's 10° steps and the union's output give many small concave vertices. Group them into one corner by their summed turn within a support length.
      • Choose the radius (the pair radius at a junction, else inner_radius_m) from the graph identity of the two edges, not from the shape.
      • The kink check needs the same support length. Today it counts 1-unit jogs (faces/check.rs, kinks).
      • If the union takes most of a town cell's time: make each node's corners per pair of adjacent arms, as SUMO, X-Plane, OSM2World and Streets GL do. Keep the outline only for corners between arms of different graph points.
      • osm2streets tried a union of the thick roads to find a junction's shape, and dropped it ("doesn't work for three-way intersections"). The latest approach takes the junction's extent from its straight seams, so that problem does not apply.
    5. Determinism. The rounds read the vertices of the union's output. Compute them about a global anchor, as stroke::boolean does; check 2 guards it. Proland uses the same rule: it computes on the unclipped features, then clips.
    6. Time per cell. The 8 ms gate can hold for rural cells. For a window-wide overlay in a town cell, this issue's own estimate (R7) is 50 to 70 ms. Report rural and town cells apart. The owner then sets a gate per type, or GP7 sets 1 to 3 workers against the real budget (2 s per jump).

    Considered, not recommended

    • Rasterize the roads into the terrain tiles, as Proland, Outerra, MapLibre and MSFS do. This is the usual real-time method.
      • These engines draw the terrain near the eye as finely as the road detail, and they have no vertical kerbs or walls.
      • TrailView's near grid (1.63 m) is 4 times coarser than its height pages (0.41 m). Kerbs and walls would again need stitched meshes: the fault "two surfaces for one ground" of TrailView roads: why the road system tears, and a planar road map #3095.
      • Open this again only with a measurement that shows finer CDLOD levels in owned nodes inside the 0.8 ms budget.
    • Keep core v2's closings. A closing acts on the whole shape. The zone constants (REAL, ZONE, SHRINK) are special cases, and a closing gives no exact circle for GP4's rings or GP6's ring frame.
    • Bake the whole plan. Offline tools do this (StreetGen, SUMO). But the tiles would grow far past the 2 % budget, and each rule change would need a rebake. Use it only if GP7's jump budget fails.
    • A distance-field plan on the device. About 0.2 to 0.4 s per town cell on the CPU (estimate), and GP7 would need contours.

    The changes to the epic's text that follow from this review are proposals on #3096.

    Sources

    [V]: read in the code, the docs or the paper. [S]: a secondary source.


    Generated by Claude Code

  14. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Owner decision (orchestrating session): the junction corner radius is a class rule. A junction corner takes the smaller value of its two arms' classes, from the new class fields corner_radius_m and corner_radius_walk_m in data/trailview/roads.json. The walk value applies where an arm has a sidewalk bit on the corner side. The round still shrinks to the largest radius that fits. Joints and a way's own turns keep inner_radius_m. The owner accepted the proposed values (commit bc4f0a8 on claude/gp3-faces-v3):

    Class corner_radius_m corner_radius_walk_m
    motorway, trunk (and links) 9 9
    primary, secondary (and links) 9 6
    tertiary (and link) 7 5
    unclassified 5 3
    residential 4 3
    road 4 4
    living_street, service, track 3 3
    path, footway, cycleway, bridleway, pedestrian, via_ferrata 1 1
    steps, rail classes 0 0

    Consequences:

    • The radii leave pairs in plan.json. pairs keeps mouth and blend, because GP4 and GP6 read them.
    • The radius is at most 9 m, because the table check needs the corner radius plus the shoulder to be at most heights.blend_radius_m (10 m).
    • A path or track host with a road or track guest gets a round of 1 m. It fell to default (0 m) before.

    The search for the largest radius that fits is not monotonic: a smaller circle can fail where a larger one fits. It loses a round at i07 and at three other places. Open item 1 fixes the search as a general operation.

    Contact sheets (current against proposed): /home/user/gp-pictures/gp3/step1/ on the orchestrating machine.


    Generated by Claude Code

  15. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Owner decisions (orchestrating session) after item 1, head 215e990:

    1. New kink measure: approved. A corner is the summed turn within 1 m (SUPPORT_M) around a concave vertex. It is judged against the least inner_radius_m of the ways whose edges run through it, so a road/path corner is judged against 1 m. A needle or a 1-unit jog counts as a sliver or a jog, not as a kink.
    2. Outline rounds get a shoulder ring now. It is the same ring operation as the point rounds, at the band offsets of the edges that the round meets. Today the paved fill of an outline round meets the land directly along its arc, and the shoulder starts again only past the tangent points. A picture of this is in scratch/gp-pictures, gp3/item1/shoulder-ring.png.

    Generated by Claude Code

  16. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Owner decision (orchestrating session on timosPC): the kink check keeps the walk along the whole paved outline, across the borders of paved faces. It measures the edge that a rider sees. A corner on the border between two paved faces is a kink like any other. The gate is 0 kinks by this measure. The needle tips of land between ways that overlap without a graph point (about 12 of the 30 at dec9870) are a GP2 item; GP3 reports them in its GP2 comment.


    Generated by Claude Code

  17. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Core v3 status: time work done

    Branch claude/gp3-faces-v3 @ 203b112 (pushed), no PR yet. Pictures: /media/timo/OSM1/tmp/ground-plan/gp3/v3/ (INDEX.md).

    Numbers (256 fixture cells, release, 4 threads, 3 GB cap, best of 3; 8d2464c and the head run back to back on timosPC, two pairs)

    8d2464c 203b112
    crashes / partition / check 2 (480 borders) 0 / 0 / 0 0 / 0 / 0
    shards 0 0
    kinks (walk along the paved outline) – 31
    fragments / slivers / jogs 14 / 72 / 62 9 / 4 / 0
    bent borders (accepted) 96 89
    town median (19 cells), raw, pair 1 / pair 2 33.66 / 33.74 ms 31.31 / 31.32 ms (x0.93, 31.6 ms timosPC equivalent)
    town p95 / max, raw 70.1 / 71.5 ms 60.0 / 66.4 ms
    rural median (237 cells), raw 2.07 ms 1.43 ms (x0.69, 1.4 ms equivalent)
    rural p95 / max, raw 14.6 / 30.5 ms 14.2 / 31.1 ms
    cargo test -p obc-ground-plan 47 passed 54 passed

    What changed (three commits after ed76b35; the face plans of the fixture do not change, except one fragment and one kink at a tile line)

    • The precision rule (snap rounding) sorts the segments of all patches by edge once and finds the hot squares in a slab along each edge. The map takes the vertex indices from it. Snap rounding plus map: 13.4 to 5.3 ms in a town cell (median).
    • The label cover reads very large candidates (band layers, long ways) on every query instead of entering them in each grid cell: 2.7 to 0.5 ms.
    • An outline round is built once per circle (two vertices of one bend found the same circle).
    • The slice works in 8 x 8 tiles (about 50 m) per cell. Each tile reads the segments whose box meets it. The snap rounding of all patches together joins the tiles.

    Slice cost bound. The overlay's solver repeats its passes over all its segments until no new crossing appears. One crossing at a small angle near a vertex can need hundreds of passes. Reproduced: one 3 m quad that crosses a fan side at 2 degrees, 32 units from its corner, in cell (34296, 23098): the slice goes from 13 ms to 478 ms. With tiles the passes read one tile: 17 ms. Fixture slice cost per segment (cells over 500 segments):

    median p95 max slowest cell
    one slice per cell 0.48 us 1.01 us 1.61 us 30.8 ms
    8 x 8 tiles 0.46 us 0.66 us 0.83 us 12.6 ms

    GP4 keeps its per-cell gate. Note for GP4: a tile can still need many passes. A 169-segment tile took 14 ms when a degenerate rail-bed fan (a needle 1.5 m long and 3 cm wide) lay along a carriageway edge. Such needle fans are a GP3 fault; I trace them with the other corner faults.

    Tried and not kept: a slice without the region outlines (the stubs about each junction arm) is about 6 ms faster in a town cell. Then a patch of a way that passes through the stub of another arm of its own point (a loop, a hairpin, two ways that run together) gets the wrong label. A relabel by the nearest station or by the distance to the arm's centre line fails at the inner side of bends. The region outlines stay.

    Next, in order: the kink check fix (classes C and E), the GP2 comment (class A, 13 land needles), the tracing of classes B, F and D and of three visible notches (sr2, sr4, the valley-eye junction), then the rest of the plan (junction region pieces, rail beds, crossings, platforms, edge flags, GP4 hooks, PR).


    Generated by Claude Code

  18. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    GP2 items from GP3: ways that run together (class A), short links

    Problem. Two ways of one level sometimes run together without a graph point: a mapped footway or path inside or along the edge of a road, or a cycleway along a track. GP2 skips their crossings under GRAZE_DEG (20°) and does not see an overlap without a crossing. In GP3, both carriageways are strokes, and their edges cross at a very small angle. The land between the two edges ends in a needle tip, and no round can shape it (no graph point gives the pair a corner).

    Where (head 91b24fa, walk along the paved outline): 11 of the 15 kinks are such needle tips, at 7 way pairs in 5 cells. Sheet: /media/timo/OSM1/tmp/ground-plan/gp3/v3/gp2-needles/needles.png (tiles 30 m, 8 m, 2 m per place).

    Pair Kinks Shape
    unclassified #106 + path #39 (34296, 23097) k02, k03, k04 a land lens 0.6 m long: the path's edge crosses the road's edge twice
    residential #30 + footway #29 (34301, 23097) k08 to k12 the footway runs inside the road's edge for 60 m: needle tips where its edge leaves and enters the road
    residential #86 + path #107 (34298, 23098) k19 the path leaves the road 35 m from their junction
    tertiary #96 + footway #97 (34300, 23098) k21 a needle of paved shoulder
    unclassified #53 + footway #24 (34301, 23098) k22, k23 as #30 + #29
    track #3 + cycleway #12 (34294, 23108) (no kink: the needle is 0.15 m long, shorter than the support) a land needle inside a junction face

    These pairs also give some of the accepted bent borders ("two ways that overlap without a graph point").

    Proposed rule (GP2, general). Two ways of one level and of the road or path families run together where their centre lines stay closer than the sum of their half-widths, at an angle under GRAZE_DEG.

    1. GP2 finds each such run with the chord grid that it already builds for crossings: for each pair of chords under 20° in one bucket, the stretch where they are closer than the sum of their half-widths. Stretches of one pair that touch are one run.
    2. At each end of a run, where the two carriageways meet or part, GP2 puts a joint: an implicit junction with the stronger way as host and the weaker way as guest.
    3. Between the two joints, the weaker way is folded into the host: it keeps its samples and tags, but GP3 builds no carriageway for it (its ground is the host's carriageway). This is what osm2streets does with side paths, and what SUMO does when it joins arms within 20°.
    4. GP3 then makes the corners at each joint with the class corner radius (1 m for road and path). The land between the parting edges ends in a round, not in a needle.

    Variant (smaller). Only step 2: joints at the ends of a run, and both strokes stay. That removes the needle tips at the run's ends but keeps the overlap of the two carriageways. In a 60 m run like #30 + #29, the edges then cross once more inside the run and leave new tips.

    For GP4. A folded footway is often a mapped sidewalk. GP4 can take its side and width as a sidewalk band of the host, or leave it folded.

    Cost (estimate, not measured). GP2: one distance test per chord pair under 20° in the existing buckets, about 0.1 to 0.3 ms per town cell. GP3: fewer strokes and fewer edges in the slice, so it gets a little faster.

    Effect (expected, not measured). The 11 needle kinks go: k02, k03, k04, k08 to k12, k19, k21, k22, k23. The track and cycleway needle goes too, and some bent borders.

    Short links between close junctions (from the status comment): two junctions a few metres apart on one link share a seam. Their faces then cover the whole link, and the rounds of both points crowd the link (k20 and the 31.6° corner at 46.81631, 8.42696 are on such links). A GP2 rule could merge two junctions closer than the sum of their corner radii into one point. I did not measure it.


    Generated by Claude Code

  19. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Owner decision (orchestrating session): the GP2 rule for grazing ways is approved (proposal #3112 (comment)). Where two same-level road or path ways run within the sum of their half-widths at an angle under 20°, GP2 puts a joint at each end of that stretch. Between the joints, the weaker way folds into the host. GP3 then rounds both ends. This removes the land needles (class A kinks). It is one general rule in the graph, with no case code. GP3's PR implements it in GP2's code, with a fixture count (stretches folded, kinks before and after) and before/after pictures of k02–k04, k08–k12, k19, k21–k23, k30.


    Generated by Claude Code

  20. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Core v3 status: fragments step

    Branch claude/gp3-faces-v3 @ 434f1ad (pushed), no PR. Pictures: /media/timo/OSM1/tmp/ground-plan/gp3/v3/fragments/ (fragments-1.png, fragments-2.png: before at ca0ad83 on the left, after on the right).

    Numbers (256 fixture cells, release, 4 threads, 3 GB cap; ca0ad83 and 434f1ad back to back, best of 3)

    ca0ad83 434f1ad
    crashes / partition / check 2 0 / 0 / 0 0 / 0 / 0
    kinks (outline walk) 22 22 (the same places)
    fragments / slivers / jogs 9 / 3 / 0 3 / 1 / 0
    bent borders (accepted) 87 89
    town median, raw 37.5 ms 44.4 ms (x1.18)
    rural median, raw 1.90 ms 2.13 ms (x1.12)
    cargo test -p obc-ground-plan (head only) - 57 passed (49 unit, 8 integration)

    The time numbers are not calibrated: the load average was 16 to 18 on 12 cores during the pair. The increase can be real (more patches go through the region rule). Bench the pair again at low load before the PR.

    Done since ca0ad83

    • A round's fan paves land only: it loses to every carriageway and rail bed. The arms' carriageways reach the point's face through its region. Before, a fan lay over other ways and over its own arms past their seams, and the region and the seam cut disagreed there (f1 to f4, f7, s9, s10).
    • An arm's seam moves past the farthest fan vertex over its carriageway: a fan of two other arms can reach over an arm that runs beside one of them.
    • Check fix: a joint's face takes the label of one of its two ways and covers both, so the fragment check reads the centrelines of both ways (f5 was a check artefact).
    • Tried and not kept: a region that claims a patch only when it is past none of the point's seams (fragments 5 to 12); a region that gives its patch past a shared seam to the point across it (fragments 4 to 6, slivers 1 to 4); exact vertices at the slice's tile lines and a half-unit inner point for thin patches (no change).

    Question for the owner (g4, fragments-2.png, last row): a track x cycleway junction lies next to the joint where the cycleway becomes a path. With the new fan rule, the joint's face meets the junction's face at their shared seam with a V-shaped ownership border. Both sides are carriageway; only the owner differs. The check counts it as an accepted bent border. Is this acceptable, or must the shared seam cut every arm of both points (a straight border)?

    Left, in order

    1. Fragments: f0 (a 5 cm wedge of a pedestrian zone between a footway's square end and the zone's edge, inside the junction's stub); f6 and f8 (one-grid crumbs after the precision rule: f6 at the tip of an outline round's ring, f8 a 4-unit triangle); the slope sliver.
    2. The short-feature check in check 1 (orchestrator decision): a stretch of the paved outline under SUPPORT_M whose incoming and outgoing directions agree within CORNER_TURN, with a vertex or the outgoing line more than about 2 cm off the incoming line, and one vertex sharper than CORNER_TURN. Count them, then fix their causes (k26's step, k13's pocket, short needles). Not started.
    3. The named kinks: sr2's V notch (two rounds whose circles overlap), the degenerate rail-bed needle fan, k06, k26, m05, m14, m21, k13, k01.
    4. The GP2 fold rule for class A (owner approved): joints at the ends of a stretch where two same-level ways run within the sum of their half-widths under 20 degrees, the weaker way folded between them; a focused test, a fixture count, before/after tiles of k02 to k04, k08 to k12, k19, k21 to k23, k30; bench back to back.
    5. Rail beds (gauge width rule), level-crossing faces, platforms, edge flags, CornerArc fields.
    6. Synthetic faces tests of invariants, sub_window, the torture set as one 2x contact sheet.
    7. GP4 hooks H1 to H9.
    8. Remove the 16 stray files under v4/; merge origin/ground-plan; the WASM size of i_overlay 9.1.0; test, clippy, fmt; the PR into ground-plan.

    Generated by Claude Code

  21. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Orchestrator note for the next session:

    • GP3's scratch tools (build.sh, run.sh, the tile and sheet scripts, the probe patches, the back-to-back benches) are copied to /media/timo/OSM1/tmp/ground-plan/gp3/v3/tools/. The session scratchpad will not survive.
    • The pair ca0ad83 → 434f1ad measured ×1.18 in town under load 16–18. Before more work on the hot path, run that pair again at low load, to confirm or refute the regression.

    Generated by Claude Code

  22. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Timing pair again at low load: no regression

    ca0ad83 and 434f1ad, release, 4 threads, 3 GB cap, 256 fixture cells, best of 3 per cell. Two pairs back to back, the second in the reverse order.

    run load before / after town median rural median
    ca0ad83 1.03 / 2.43 30.3 ms 1.46 ms
    434f1ad 2.43 / 3.23 30.7 ms 1.46 ms
    434f1ad 2.58 / 3.35 32.6 ms 1.41 ms
    ca0ad83 3.35 / 4.16 30.0 ms 1.40 ms

    The town median is the time of one cell and moves by up to 8 % between runs. The per-cell least time of both runs is a steadier measure:

    • sum over all 256 cells: 1551 ms before, 1544 ms after (x0.996);
    • sum over the 45 cells over 10 ms: 1079 ms before, 1073 ms after (x0.994);
    • median per-cell ratio: 1.00.

    The x1.18 of the first pair was the load of 16 to 18. The fan rule costs no measurable time. Check 1 is the same as in the status comment (fragments 9 -> 3, slivers 3 -> 1, bent borders 87 -> 89, kinks 22 at the same places, no crashes, no partition or check 2 faults).


    Generated by Claude Code

  23. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Core v3 status: short features and the joint taper

    Branch claude/gp3-faces-v3 @ ccec574 (pushed), no PR. Pictures: /media/timo/OSM1/tmp/ground-plan/gp3/v3/ (short/, taper/; INDEX.md has one line per sheet).

    Numbers (256 fixture cells, release, 4 threads, 3 GB cap)

    434f1ad ccec574
    crashes / partition / check 2 0 / 0 / 0 0 / 0 / 0
    kinks (outline walk) 22 22 (the same places)
    short features (new check) 233 164
    fragments / slivers / jogs 3 / 1 / 0 2 / 0 / 0
    bent borders (accepted) 89 90
    per-cell least time, sum of the 47 cells over 10 ms, ABBA pair 1128 ms 1206 ms (x1.07)
    cargo test -p obc-ground-plan 57 58 passed; clippy clean

    The time pair ran at a load of 3.5 rising to 7 (other agents built), and both head runs fell in the higher half, so x1.07 is an upper bound. Run it again at low load before the PR.

    Done

    • Check 1 counts short features: along the paved outline, a vertex that turns past CORNER_TURN where the directions from 1 m to 0.5 m back and from 0.5 m to 1 m ahead agree within CORNER_TURN, more than SHORT_M (2 cm) off either line; vertices within SUPPORT_M are one feature. All samples looked at are real shapes.
    • Joint taper (owner decision (a)): at a joint, the wider arm's carriageway edge runs straight into the narrower one's at taper_rate 0.15 (8.5° at each end), or steeper where the way widens in a bend, so it meets the own edge within extent_m. The bands keep their widths past the tapered edge. A vertex is added at the taper end, never closer than half GP2's finest step to another. A residential road into a footway (0.6 m, its finish's cap) tapers over 12.7 m. Junction arms keep their widths (deviation in the body).
    • Stroke: on the inner side of a small join, a mitre point that would turn a short segment back is left out. It made a needle at a 6 cm GP2 sample pair on a bend once the taper changed the width there.

    Open, in order

    1. sr2's V notch: two rounds whose discs overlap (at sr2, two junction rounds of 3 m and 0.69 m). Proposed rule: the land between them is the hull of both discs (a rolling ball passes from one to the other); a land candidate of that hull beats the fans and loses to every carriageway, with band rings along the hull's two tangent lines. Not started.
    2. The remaining short features (164): mostly at junctions. A round's arc ends in a convex corner where it touches an arm's square-end corner, or where it cuts an arm by sag_plan_m (a 5 cm cut makes a 1 m round cross the edge at 18°); V notches; seam steps. Also the small notch in the shoulder's outer edge at the taper place taper/fix/fix.png (ck).
    3. The named kinks m05, k06, m14, k26, m21 (still kinks) and k13, k01 (now short features).
    4. Junction-host tapers, after item 1 (they made rounds overlap at three places).
    5. The GP2 fold (owner approved). Notes from reading GP2: grazing pairs are skipped in crossings() under GRAZE_DEG; an Anchor carries a position apart from its station, so run-end anchors on both ways at the host's foot make one junction there; split the weaker piece at the run ends as for synthetic decks and mark the middle folded; GP3's lines() then skips folded ways and their junction arms drop out. Place each run end where the weaker carriageway is fully inside the host (centre distance = host half-width less its own): there its square end is hidden. At the touch point (the sum of the half-widths) the square end sticks out as an S step.
    6. Rail beds, crossings, platforms, edge flags, CornerArc fields, the synthetic tests, sub_window, the torture sheet, GP4 hooks, v4/, the merge of origin/ground-plan, the WASM size, the PR.

    Not checked: the 8.5° turns at taper ends at eye height in the one-model viewer.


    Generated by Claude Code

  24. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Core v3 status: night round 1 (outline rounds per place; two owner decisions)

    Branch claude/gp3-faces-v3 @ 3a5472d (pushed), no PR. Pictures: /media/timo/OSM1/tmp/ground-plan/gp3/v3/ (place/, sr2/, decision/, fold/, holes/, census/; INDEX.md has one line per sheet).

    Numbers (256 fixture cells, release, 4 threads, 3 GB cap)

    ccec574 3a5472d
    crashes / partition / check 2 0 / 0 / 0 0 / 0 / 0
    kinks 22 15 (14 class A, and k06)
    short features 164 165
    fragments / slivers / jogs 2 / 0 / 0 2 / 0 / 0
    bent borders (accepted) 90 98
    cargo test -p obc-ground-plan 58 58 passed; clippy and fmt clean

    Done: an outline round is judged per place. A corner of the paved outline that had one vertex on a point's round was taken as that round's, also where the round's arc ended in a sharp tip that it did not shape. Each place of a corner is now judged by itself, as the kink check reads it. This removes m05, m14, k26, m21 and 3 class A kinks, with no new kink. Costs: 8 more bent borders (k26: the paved wedge takes the way's label and meets the junction face with a V border, both carriageway, place/a/zoom/k26z.png) and one short feature (s05: an 8 cm step where the new 3 m round's ring meets the shoulder). Sheet: place/a/sheet.png.

    Decision 1: sr2 is not an overlap of two rounds. Cause (probe, decision/sr2.png): the service guest (half-width 3.26 m) is wider than its residential host (2.5 m) and meets it at 25.6°. Its square end's corner sticks 0.44 m out of the host's far edge as a tooth. Two outline rounds (3 m and 0.69 m) round the tooth's two bases and leave its tip: a convex V. No check counts a convex corner. So the proposed hull rule ("loses to every carriageway") cannot remove it. Options:

    • (a) A guest wider than the widest other arm of its junction tapers to that width at the point, at taper_rate (as the joint taper). 51 guests in the fixture are wider than every other arm; only shallow ones make a tooth.
    • (b) The hull of two overlapping rounds is land and beats the carriageway between them (it cuts the tooth). 161 disc overlaps in the fixture, most of them harmless (same circle twice).
    • (c) Accept, and add a check for sharp convex corners (census: 94 over 30° within 1 m, mostly round outer sides of tight turns; census/convex/sheet-a.png).

    Decision 2: the GP2 fold as approved does not fit the class A places. I measured each run (two ways closer than the sum of their half-widths at under 20°). At none of the class A kinks does the weaker way come fully inside the host (centre distance under the host's half-width less its own): the footways and paths run along the host's edge and overlap it by 0.16 to 0.3 m. A prototype that folds the overlap stretch and puts a junction at each touch point (fold/try1/sheet.png, patch tools/fold-try1.patch) made things worse: kinks 22 → 25, fragments 2 → 4, one sliver, 9 more short features, 29 more bent borders. The weaker way loses visible pavement (it lies mostly outside the host), and the new junctions make teeth and needles. Not kept. Options:

    • (a) Fold anyway and accept the loss of the weaker way along the host (the footway at k08 is gone for 60 m until GP4 makes a sidewalk band from it), with a fix for the fold ends still to find.
    • (b) Pave the land holes into which no round of their ways' least inner radius fits (prototype, holes/sheet.png, patch tools/holes-try1.patch): kinks 15 → 7 (k06 and 8 class A go), but 1 check 2 fault (border 34295/23098 to 34295/23099), bent borders 98 → 166, and 59 holes paved, some up to 4.8 m wide (islands inside junction loops of 3 m ways). A width limit (for example under 2 × MIN_RADIUS) would keep the islands.
    • (c) Accept the class A needles as GP2 data faults and count them as their own kind.

    Not done: junction-host tapers (they wait for decision 1); the shoulder notch at the taper curve place (taper/fix/fix.png, ck); the timing pair at low load (the load stayed at 3.9 to 6.2 all round, so I did not run it).

    Deviation: the private target is /media/timo/OSM1/cache/cargo-target-gp3v3 (the one the earlier GP3 session used), not cargo-target-gp3.


    Generated by Claude Code

  25. timohueser commented on Nov 4, 2026

    @timohueser
    OwnerAuthor

    Core v3 status: night round 2 (context limit reached)

    Branch claude/gp3-faces-v3 @ 126cbc1 (pushed), no PR. Pictures: /media/timo/OSM1/tmp/ground-plan/gp3/v3/ (guest/, shapes/; INDEX.md).

    Fixture (256 cells) at 126cbc1: crashes 0, partition 0, check 2 0, kinks 15, short features 165, fragments 2, slivers 0, jogs 0, bent borders 98. cargo test -p obc-ground-plan: 59 passed; clippy and fmt clean.

    Done

    • Material tie-break (shapes item 2): on a class tie, a host arm's material wins over a guest's (it was the least way id). Test a_junction_of_one_class_takes_a_host_arms_material (both feature orders). No fixture count changed.
    • Shapes item 1 (conn-road-into-path): the two concave bites into the wide way's end are gone at the head (joint taper); before|after in shapes/crp-joint.png. Left: the wide way's shoulder band ends square at the joint where the path has no shoulder (a 0.4 m step in the shoulder's outer edge). The bands keep their widths past a taper; they should taper out at the joint too.

    Prototype 1(a) for the owner (patch only, tools/guest-taper-try1.patch, not in the branch). A junction guest wider than every other arm tapers to the widest other arm's width at the point (the joint taper's rule). Fixture against 3a5472d: kinks 15 → 15, short features 165 → 163, bent borders 98 → 94, fragments 2, check 2 0, no crash. Sheet guest/sheet.png (sr2, the round below it, and 5 of the 51 wide guests, 16 m and 5 m): sr2's tooth and V are gone; g0 to g4 show little change and no new fault. The taper alone turned the round below sr2 into a paved disc (guest/sr2b.png): its arc took the long way round. The patch therefore also requires a point round's arc that faces its corner to turn under half a turn (as outline rounds already do); with it the disc is gone and the counts above hold.

    Not done, in order (the coordinator's list): the shoulder notch at the taper curve place (ck) and the shoulder step above; shapes items 3 (the 0.9 m × 4 cm terrain needle in the slope band at v17/i07) and 4 (the small loop in an outline round at t-tertiary, r4/tt-edge-round.png); rail beds (gauge width rule), level-crossing faces, platforms; edge flags; CornerArc fields; synthetic face tests; sub_window; the torture sheet; GP4 hooks H1–H9; delete v4/; merge origin/ground-plan; the WASM size of i_overlay; the timing pair (waits for a quiet machine); the PR.

    Open owner decisions: 1 (sr2: guest taper, hull, or accept) and 2 (class A needles: fold, pave narrow holes, or accept), comment 6645427679.


    Generated by Claude Code

  26. timohueser commented on Nov 5, 2026

    @timohueser
    OwnerAuthor

    Core v3 status: night round 3, pull request open

    Pull request #3131 into ground-plan (no auto-merge), branch claude/gp3-faces-v3 @ 3f80504 (origin/ground-plan merged). Pictures: /media/timo/OSM1/tmp/ground-plan/gp3/v3/n3/ (INDEX.md, section "Night round 3").

    Fixture (256 cells) at the head: crashes 0, partition 0, check 2 0, kinks 15, short features 165 to 163, fragments 2, slivers 0, jogs 0, bent borders 98. 66 tests pass; clippy and fmt clean.

    Done: the layer taper at joints (a band that the narrower way lacks tapers out; crpj, g2, ck); a stroke leaves out an inner vertex whose inner mitre would turn a segment back (the ck notch); a crossing only where the rail runs through a road (v16: the strip beside the track is bed now); platforms; CornerArc feet and arc; v4/ deleted; WASM size measured (the faces stage doubles the bridge: 1344.5 KiB raw, 514.8 KiB gzipped against a budget of 672 / 272).

    Not reproduced at this head: shapes item 3 (the v17/i07 needle came from the prototype branch on an older GP3) and item 4 (no outline round near t-tertiary; probably one of two short features where the junction arc meets the edge).

    Left: GP4 hooks H1 to H9 (GP4's pull request), edge flags, sub_window and the synthetic cases, the torture sheet, the timing pair (pending), the deviation comments on #3099, #3113 and #3101. Open owner decisions 1 and 2 stay (comment 6645427679).


    Generated by Claude Code

  27. timohueser commented on Nov 5, 2026

    @timohueser
    OwnerAuthor

    Timing pair: 434f1ad against the PR head 3f80504, no regression

    Reviewer run for #3131. Release build of the debug tool, 4 threads, 3 GB cap (systemd-run --user --scope -p MemoryMax=3G -p MemorySwapMax=0), 256 fixture cells, --faces-bench --runs 3 (best of 3 per cell). Two pairs back to back, the second in the reverse order. Each commit has its own detached worktree; the binaries come from the private target /media/timo/OSM1/cache/cargo-target-review.

    run load before / after town median rural median town p95 rural p95
    434f1ad 1.02 / 2.01 31.8 ms 1.44 ms 62.9 ms 14.1 ms
    3f80504 2.01 / 2.66 31.6 ms 1.49 ms 61.2 ms 13.7 ms
    3f80504 2.66 / 3.20 31.9 ms 1.48 ms 62.2 ms 14.9 ms
    434f1ad 3.20 / 3.63 31.4 ms 1.39 ms 64.9 ms 13.6 ms

    Per-cell least time of the two runs of each commit:

    • sum over all 256 cells: 1552 ms before, 1562 ms after (x1.007);
    • sum over the 46 cells over 10 ms: 1090 ms before, 1098 ms after (x1.007);
    • median per-cell ratio: 1.000 (1.001 for the cells over 10 ms).

    Against the GP3 time gate of this body: the rural median is 1.4 to 1.5 ms, under the 8 ms of the per-cell-type option. The town median (about 32 ms) has no gate before GP7. The provisional p95 gate (8 ms native per cell, Verification) does not hold at either commit: rural p95 is about 14 ms. The PR does not change it.

    Check 1 at the head, both runs: crashes 0, partition 0, check 2 0, kinks 15 (22 before), fragments 2 (3), slivers 0 (1), bent borders 98 (89).

    A trap of the method: two worktrees that build into one target dir share the unit hashes of the workspace crates. The second build was "Finished in 0.14 s" and gave the same binary as the first. A touch of the second worktree's host/obc-ground-plan sources forced the rebuild; the two binaries then differ (md5 checked). Build each commit into its own target dir, or touch the sources, and compare the binaries before a pair.


    Generated by Claude Code

  28. timohueser commented on Nov 5, 2026

    @timohueser
    OwnerAuthor

    PR #3131 is merged into ground-plan (61bfb3b), after an adversarial review (#3131 comment 6646966480), its fix round (comment 6647698562) and green CI. Timing at low load: ×1.007 against 434f1ad. The open decisions and review items move to #3132.


    Generated by Claude Code

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