maps: document the miter normal and the junction lane-count contract
- Commit
5300c16204707ba605d6fa9deb244181b066f47e- Author
- vayun-mathur <[email protected]>
- When
- 2026-09-11 21:57 UTC (2 months ago)
- Parents
d4f2efb
Diff
library/map/src/main/rust/shaders/road_surface.vert
diff --git a/library/map/src/main/rust/shaders/road_surface.vert b/library/map/src/main/rust/shaders/road_surface.vertindex 862f55ecf3..6a861929bb 100644--- a/library/map/src/main/rust/shaders/road_surface.vert+++ b/library/map/src/main/rust/shaders/road_surface.vert@@ -22,13 +22,25 @@ // screen measurement that ramps continuously with zoom, so baking it into vertices // would re-tessellate every road in every visible tile on every zoom step, while // panning, on the critical path. The tessellator emits the centreline point, the-// unit normal of the join and `t`; the half-width arrives as a push constant and the-// offset is+// join normal and `t`; the half-width arrives as a push constant and the offset is // // offset = normal * (t * halfWidth) // // `t` doubles as the extrusion multiplier and as the fragment stage's marking // coordinate, which is what keeps the vertex to six floats.+//+// # Do not normalise `inNormal`+//+// It is the *miter* normal, not a unit vector: `tess::ribbon::join_normal` lengthens the+// bisector by `1/cos(theta/2)`, clamped at `stroke::MITER_LIMIT`, and the taper scales it+// again below 1 where a section abuts one of a different lane count. Unit length holds+// only on a straight run.+//+// That extra length is load-bearing. It is what keeps the kerb at `|t| = 1` through a+// bend; with a unit normal the carriageway pinches at every join and every marking slides+// sideways with it, because a marking's position is a fraction of a width that is no+// longer the width it should be. `normalize(inNormal)` compiles, warns about nothing, and+// silently breaks the joins and the taper together. layout(location = 0) in vec2 inPosition; layout(location = 1) in vec2 inNormal; layout(location = 2) in float inT;@@ -59,8 +71,9 @@ void main() { // the difference back off as alpha. Identical to `line.vert`, so a hairline road at // low zoom fades rather than snapping to full strength. float halfWidthPx = max(wantHalfPx, MIN_HALF_WIDTH_PX);- // The offset is a pixel distance and the normal is a unit vector in tile-local- // space, so dividing by the tile's pixel size converts one to the other.+ // The offset is a pixel distance and the normal is in tile-local space, so dividing by+ // the tile's pixel size converts one to the other. The normal's own length is a+ // deliberate miter/taper factor and is meant to survive this — see the header. vec2 offsetTile = inNormal * (inT * halfWidthPx / tilePx); gl_Position = push.tileToClip * vec4(inPosition + offsetTile, 0.0, 1.0); outT = inT;
library/map/src/main/rust/src/style/mod.rs
diff --git a/library/map/src/main/rust/src/style/mod.rs b/library/map/src/main/rust/src/style/mod.rsindex c15e236802..17acc03026 100644--- a/library/map/src/main/rust/src/style/mod.rs+++ b/library/map/src/main/rust/src/style/mod.rs@@ -972,6 +972,9 @@ mod tests { if LANE_RENDERING { Vec::new() } else { vec!["roads-carriageway", "junction-connector"] }; assert_eq!(dropped, expected); }++ /// A kind the authored `case` gives its own colour has its own layer, and a kind that shares+ /// a colour with another sits in the same layer rather than adding a draw. #[test] fn a_data_driven_fill_is_one_layer_per_colour() { let park: Vec<&Layer> =
library/map/src/main/rust/src/tile/geometry.rs
diff --git a/library/map/src/main/rust/src/tile/geometry.rs b/library/map/src/main/rust/src/tile/geometry.rsindex c20e07ddbf..d9895b8efc 100644--- a/library/map/src/main/rust/src/tile/geometry.rs+++ b/library/map/src/main/rust/src/tile/geometry.rs@@ -1579,6 +1579,8 @@ mod tests { assert_eq!(mesh.carriageways.len(), 2); } + /// A road with no `lanes` tag — most of OSM — still gets a carriageway, because a zero lane+ /// count would push a zero width and draw nothing at all where a road plainly is. #[test] fn an_untagged_road_falls_back_to_one_lane_each_way() { let mesh = build(&carriageway_body(&[(0, false), (0, true)]), carriageway_only(), 16, 0, 0, false);
scripts/maps/mamaps_build/src/schema/junction.rs
diff --git a/scripts/maps/mamaps_build/src/schema/junction.rs b/scripts/maps/mamaps_build/src/schema/junction.rsindex 0ea648b92d..7721867496 100644--- a/scripts/maps/mamaps_build/src/schema/junction.rs+++ b/scripts/maps/mamaps_build/src/schema/junction.rs@@ -111,6 +111,26 @@ //! The practical consequence: do not judge a change to the geometry above by how much asphalt //! appears. Judge it by where the markings fall. //!+//! **First, though, check that connectors are drawn at all.** `style::LANE_RENDERING` is a release+//! kill switch that defaults to `false`, and it works by dropping every `carriageway: true` layer+//! from `style::layers()` — which is `roads-carriageway` *and* `junction-connector`. It is a+//! *drawing* gate and it is not this module's. The tiler does not link the renderer, so connectors+//! are written into the archive exactly as before and only the painting stops: the screen goes+//! empty rather than going wrong.+//!+//! **So a blank connector screenshot is not evidence about [`MIN_ZOOM`], and must not be read as+//! any.** The two gates are independent and are currently in opposite states — [`MIN_ZOOM`] decides+//! what reaches the archive and is satisfied; the style layer decides what is painted and is+//! switched off. Debugging an empty screen inward lands on the tiler, and "fixing" a tiling gate+//! that is already right is what silently shipped an archive with zero junction features once+//! already. That failure is documented at [`MIN_ZOOM`]; this is the same confusion running the+//! other way. Nothing in this module can cause a blank screen and nothing in this module can fix+//! one.+//!+//! The renderer's own tests read `style::layers_with_lane_rendering()` so they keep asserting+//! against the real style, which is right — but it does mean a green test run says nothing about+//! whether the switch is on.+//! //! # Lateral offset is baked in projected units, not ground metres //! //! Each connector's polyline already carries its lane's offset across the carriageway. That offset@@ -1130,6 +1150,16 @@ mod tests { /// Distinct endpoints are deliberately *not* asserted. With one real lane per direction the /// movements out of an arm share it, so `d` distinct endpoints at a degree-`d` junction is the /// correct answer; separating them would mean drawing lanes that are not there.+ ///+ /// **This test assumes the carriageway is one lane each way, and that assumption is no longer+ /// universally true.** It holds here because the fixture is untagged and [`effective_lanes`]+ /// and the renderer then agree on 1. [`crate::lanefill`] now fills the lane *count* of a+ /// junction stub from the road it interrupts, so at a divided arterial the carriageway is+ /// painted several lanes wide while this layer, which reads `turn:lanes` masks that `lanefill`+ /// deliberately does not write, still lays connectors out one lane per direction. The two+ /// disagree there and this test cannot see it: connectors hug the centreline of a wide+ /// intersection rather than running off it, so nothing here fails. Closing that needs the+ /// filled count carried to the directed edge this layer sees, which is not yet possible. #[test] fn a_connector_starts_and_ends_on_the_painted_carriageway() { let (emitted, lines) = stream(&crossroads(&[]));