Modern Apps git

← Modern-Apps.git

maps: lane rendering kill switch, scale bar and curved label fixes

Commit
28a82f33435487e5042b7a25fe46eb5eccb8e65b
Author
vayun-mathur <[email protected]>
When
2026-09-11 18:07 UTC (2 months ago)
Parents
a12d1d8

Diff

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 3b0957de08..87a000af4b 100644--- a/library/map/src/main/rust/src/style/mod.rs+++ b/library/map/src/main/rust/src/style/mod.rs@@ -683,14 +683,51 @@ pub fn background(variant: Variant) -> u32 {     } } +/// Whether the lane-level road rendering is built and drawn at all.+///+/// The one switch for the whole feature set: the `roads-carriageway` asphalt surface and its+/// painted markings, the `junction-connector` surface that continues it through an intersection,+/// the carriageway taper, and the road-surface turn arrows. Off for release; the code stays.+///+/// It works by dropping the two [`Layer::carriageway`] layers from [`layers`], which is the one+/// point every part of the feature already funnels through. No carriageway layer means+/// `tile::geometry`'s carriageway branch is never taken (so no ribbon mesh, no taper), and+/// [`road_carriageway_layer`] answers `None`, which is what+/// [`crate::vulkan::renderer::Renderer::record_arrows`] gates the turn arrows on. Dropping the+/// layers rather than clearing the flag matters: a `carriageway` layer with the flag off would+/// fall through to the ordinary stroke path and draw a 40px grey band over every road at z20.+///+/// The plain road line layers (`roads-major` and friends) are untouched and already draw+/// *underneath* the carriageway pass, so removing that pass uncovers them rather than leaving a+/// hole — the map returns to its pre-carriageway appearance.+///+/// Not a [`Toggle`]: those are a host-app opt-in the user sees. This is a release kill switch,+/// so it is a `const` and flipping it is a code change.+///+/// The tests that pin carriageway behaviour turn it on by reading+/// [`layers_with_lane_rendering`] instead, so they keep asserting against the real style rather+/// than being weakened to match the switch.+pub const LANE_RENDERING: bool = false;+ /// Every layer the renderer draws, in draw order. /// /// A borrow rather than a fresh list: the flat style is a constant table that happens to need a /// parser, so it is parsed once for the process and handed out.+///+/// Carries no carriageway layer while [`LANE_RENDERING`] is off. pub fn layers() -> &'static [Layer] {     &paint::style().layers } +/// Every layer the style declares, carriageways included, whatever [`LANE_RENDERING`] says.+///+/// For the tests that pin carriageway behaviour: they assert against the feature as authored, so+/// they have to name it explicitly rather than read a layer set the switch may have emptied.+#[cfg(test)]+pub fn layers_with_lane_rendering() -> &'static [Layer] {+    &paint::style_with_lane_rendering().layers+}+ /// The road carriageway layer, whose zoom window gates the per-lane road detail and whose width /// ramp says how wide one lane of it is. ///@@ -848,10 +885,13 @@ mod tests {     /// fixture would have passed.     #[test]     fn turn_arrows_are_gated_by_the_road_lane_layer() {-        let gate = road_carriageway_layer(layers()).expect("the road carriageway layer");+        // With lane rendering forced on: the gate is what the switch removes, so asserting it+        // against the shipped set would only re-state that the switch is off.+        let all = layers_with_lane_rendering();+        let gate = road_carriageway_layer(all).expect("the road carriageway layer");         assert_eq!(gate.id, "roads-carriageway", "not `transit-rail`, which has a spread"); -        let rail = find("transit-rail");+        let rail = all.iter().find(|l| l.id == "transit-rail").expect("transit-rail");         assert!(rail.lane_fan(), "the rail corridor fan is what made the naive predicate wrong");         assert!(!rail.carriageway, "and a corridor fan is not a carriageway");         assert!(rail.min_zoom < gate.min_zoom, "and it is the earlier of the two");@@ -872,7 +912,8 @@ mod tests {     /// order irrelevant, and a `find` cannot tell one match from the first of several.     #[test]     fn the_arrow_gate_does_not_depend_on_the_declaration_order() {-        let matches: Vec<&str> = layers()+        let all = layers_with_lane_rendering();+        let matches: Vec<&str> = all             .iter()             .filter(|l| l.carriageway && l.source_layer_id == dict::LAYER_ROADS)             .map(|l| l.id.as_str())@@ -880,7 +921,8 @@ mod tests {         assert_eq!(matches, vec!["roads-carriageway"], "the gate predicate must name one layer");          // The layer that would answer instead, and the two halves of why it does not.-        let connector = find("junction-connector");+        let connector =+            all.iter().find(|l| l.id == "junction-connector").expect("junction-connector");         assert!(connector.carriageway, "a connector draws as a road surface as well");         assert_ne!(             connector.source_layer_id,@@ -889,8 +931,43 @@ mod tests {         );     } -    /// 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.+    /// [`LANE_RENDERING`] decides whether the shipped layer set carries the carriageways at all,+    /// and the roads it uncovers are still there.+    ///+    /// The second half is the point. The carriageway pass draws *over* the flat layer loop, so+    /// switching it off has to leave the pre-carriageway road lines drawing rather than a hole —+    /// and `roads-carriageway` had to be dropped rather than have its flag cleared, because a+    /// `carriageway: false` layer of that width would fall through to the stroke path and paint a+    /// band over every road it names.+    #[test]+    fn the_lane_rendering_switch_removes_the_carriageways_and_nothing_else() {+        let shipped: Vec<&str> =+            layers().iter().filter(|l| l.carriageway).map(|l| l.id.as_str()).collect();+        if LANE_RENDERING {+            assert_eq!(shipped, vec!["roads-carriageway", "junction-connector"]);+            assert!(road_carriageway_layer(layers()).is_some(), "and the turn arrows are gated on");+        } else {+            assert!(shipped.is_empty(), "no surface layer, so no asphalt, markings or taper");+            assert!(road_carriageway_layer(layers()).is_none(), "which is the turn-arrow gate");+        }++        // Either way the plain road lines are untouched, and they draw to the top of the range.+        for id in ["roads-major", "roads-highway", "roads-minor", "roads-link"] {+            let road = find(id);+            assert!(!road.carriageway, "{id} is a stroke and stays one");+            assert!(road.draws_at(16) && road.draws_at(22), "{id} covers the carriageway's window");+        }++        // And the switch removes exactly the two, leaving every other layer in its place.+        let dropped: Vec<&str> = layers_with_lane_rendering()+            .iter()+            .filter(|l| !layers().iter().any(|kept| kept.id == l.id))+            .map(|l| l.id.as_str())+            .collect();+        let expected: Vec<&str> =+            if LANE_RENDERING { Vec::new() } else { vec!["roads-carriageway", "junction-connector"] };+        assert_eq!(dropped, expected);+    }     #[test]     fn a_data_driven_fill_is_one_layer_per_colour() {         let park: Vec<&Layer> =
library/map/src/main/rust/src/style/paint.rs
diff --git a/library/map/src/main/rust/src/style/paint.rs b/library/map/src/main/rust/src/style/paint.rsindex ce658045d9..b485e0376b 100644--- a/library/map/src/main/rust/src/style/paint.rs+++ b/library/map/src/main/rust/src/style/paint.rs@@ -522,6 +522,21 @@ fn parse_hex(source: &str) -> Option<u32> { /// `the_vendored_flat_style_parses` fails the build if it will not load, so the alternative — a /// blank map with no diagnostic — is strictly worse than a crash that names the line. pub fn style() -> &'static Style {+    static STYLE: OnceLock<Style> = OnceLock::new();+    STYLE.get_or_init(|| {+        let mut style = parse(FLAT).unwrap_or_else(|e| panic!("style/basemap.flat.json: {e}"));+        if !super::LANE_RENDERING {+            style.layers.retain(|layer| !layer.carriageway);+        }+        style+    })+}++/// The style as authored, carriageways included, whatever [`super::LANE_RENDERING`] says.+///+/// Behind [`super::layers_with_lane_rendering`]; see that for why the tests need it.+#[cfg(test)]+pub fn style_with_lane_rendering() -> &'static Style {     static STYLE: OnceLock<Style> = OnceLock::new();     STYLE.get_or_init(|| parse(FLAT).unwrap_or_else(|e| panic!("style/basemap.flat.json: {e}"))) }@@ -545,6 +560,17 @@ mod tests {         layers().iter().find(|layer| layer.id == id).unwrap_or_else(|| panic!("{id}"))     } +    /// A layer from the set with lane rendering forced on.+    ///+    /// [`crate::style::LANE_RENDERING`] is off for release, so the carriageway layers are absent+    /// from [`layers`] and the tests that pin them have to name the authored set explicitly.+    fn find_lane(id: &str) -> &'static Layer {+        crate::style::layers_with_lane_rendering()+            .iter()+            .find(|layer| layer.id == id)+            .unwrap_or_else(|| panic!("{id}"))+    }+     // --- the loader --------------------------------------------------------      #[test]@@ -1610,14 +1636,15 @@ mod tests {     /// so a two-lane street and an eight-lane motorway come off the same ramp at their true widths.     #[test]     fn the_carriageway_is_gated_and_sized_by_the_lane() {-        let layer = find("roads-carriageway");+        let all = crate::style::layers_with_lane_rendering();+        let layer = find_lane("roads-carriageway");         assert!(layer.carriageway, "roads-carriageway must draw as a surface");         // Two layers draw a surface now. `road_carriageway_layer` no longer picks between them by         // declaration order — it names the roads source — so this list is pinning *draw order*,         // not the gate: the connector has to come second, or the road surface paints over the         // connector at the mouth of the junction and clips its edge lines short of the kerb.         assert_eq!(-            layers().iter().filter(|l| l.carriageway).map(|l| l.id.as_str()).collect::<Vec<_>>(),+            all.iter().filter(|l| l.carriageway).map(|l| l.id.as_str()).collect::<Vec<_>>(),             vec!["roads-carriageway", "junction-connector"],             "the layers drawn as road surfaces, in draw order",         );@@ -1625,7 +1652,7 @@ mod tests {         // connector is put first, which is what `turn_arrows_are_gated_by_the_road_lane_layer`         // relies on and what the flag alone could not promise.         assert_eq!(-            super::super::road_carriageway_layer(layers()).map(|l| l.id.as_str()),+            super::super::road_carriageway_layer(all).map(|l| l.id.as_str()),             Some("roads-carriageway"),         );         assert_eq!(layer.min_zoom, 16, "the dense lane detail is gated to high zoom");@@ -1665,7 +1692,8 @@ mod tests {     /// width steps in or out at the kerb. Cheaper to pin than to notice on a screenshot.     #[test]     fn a_connector_matches_the_carriageway_it_continues() {-        let (road, connector) = (find("roads-carriageway"), find("junction-connector"));+        let (road, connector) =+            (find_lane("roads-carriageway"), find_lane("junction-connector"));         assert_eq!(connector.light, road.light, "a connector is the same asphalt");         assert_eq!(connector.dark, road.dark);         for zoom in [16.0, 17.5, 18.0, 20.0, 22.0] {
library/map/src/main/rust/src/tess/text.rs
diff --git a/library/map/src/main/rust/src/tess/text.rs b/library/map/src/main/rust/src/tess/text.rsindex b48753b419..a489ef7fea 100644--- a/library/map/src/main/rust/src/tess/text.rs+++ b/library/map/src/main/rust/src/tess/text.rs@@ -463,6 +463,59 @@ fn polyline_length(pts: &[(f32, f32)]) -> f32 {     sum } +/// The sharpest turn a run may be laid across, at a single vertex.+///+/// MapLibre's `symbol-max-angle` default. A corner sharper than this cannot carry legible+/// glyphs, and — more importantly here — it is what a *discontinuity* looks like: a line+/// feature's parts are joined end to end before they reach this module, so a multi-part road+/// arrives as one polyline with a phantom connector segment bridging the gap. That connector+/// inflates the arc length (so an over-long name passes the fit test) and points nowhere near+/// the road (so the glyphs that land on it fly off at their own angle). Both of the reported+/// symptoms — a name that stops mid-word, and letters kinked away from the line — are that.+const MAX_TURN_RAD: f32 = std::f32::consts::FRAC_PI_4;++/// The longest stretch of `pts` containing no turn sharper than [`MAX_TURN_RAD`].+///+/// A label is laid along this rather than the whole polyline, which is the cheap version of+/// "put the run where it fits": no placement search, just the single best-behaved stretch.+fn longest_smooth_run(pts: &[(f32, f32)]) -> &[(f32, f32)] {+    if pts.len() < 3 {+        return pts;+    }+    let cos_max = MAX_TURN_RAD.cos();+    let direction = |a: (f32, f32), b: (f32, f32)| {+        let (dx, dy) = (b.0 - a.0, b.1 - a.1);+        let len = (dx * dx + dy * dy).sqrt();+        (len > 0.0).then_some((dx / len, dy / len))+    };+    let (mut best_start, mut best_end) = (0usize, pts.len());+    let mut best_len = -1.0f32;+    let mut start = 0usize;+    let mut previous: Option<(f32, f32)> = None;+    for i in 0..pts.len() - 1 {+        // A repeated vertex has no direction of its own; it bridges its neighbours rather than+        // ending the run, exactly as `sample_polyline` skips it.+        let Some(d) = direction(pts[i], pts[i + 1]) else { continue };+        if let Some(p) = previous {+            if p.0 * d.0 + p.1 * d.1 < cos_max {+                let len = polyline_length(&pts[start..=i]);+                if len > best_len {+                    best_len = len;+                    (best_start, best_end) = (start, i + 1);+                }+                // The corner vertex belongs to both runs: it is the end of one and the start+                // of the next, so no arc length is lost between them.+                start = i;+            }+        }+        previous = Some(d);+    }+    if polyline_length(&pts[start..]) > best_len {+        (best_start, best_end) = (start, pts.len());+    }+    &pts[best_start..best_end]+}+ /// The point and unit tangent at arc length `d` along `pts`, clamped to the ends. Degenerate /// (zero-length) segments are skipped so a repeated vertex cannot produce a NaN tangent. fn sample_polyline(pts: &[(f32, f32)], d: f32) -> ((f32, f32), (f32, f32)) {@@ -501,7 +554,12 @@ fn sample_polyline(pts: &[(f32, f32)], d: f32) -> ((f32, f32), (f32, f32)) { /// measured in (`text_px / UP_EM / tile_span_px`), so the along-line spacing tracks the frame's /// text size exactly as [`emit`]'s does. Returns one [`CurvedGlyph`] per glyph, or an empty vec /// when the run is longer than the centreline — it does not fit and the label should not be-/// placed at all, which is what stops a long name spilling off a short road.+/// placed at all, which is what stops a long name spilling off a short road. A half-drawn street+/// name is worse than none: the reader cannot tell it is incomplete.+///+/// The run is measured and laid along the [longest smooth stretch](longest_smooth_run) of the+/// centreline, not the whole of it, so a corner or a join between two parts of the feature+/// neither lends its length to the fit test nor carries any glyph. pub fn layout_along_line(     line: &ShapedLine,     centreline: &[(f32, f32)],@@ -510,7 +568,11 @@ pub fn layout_along_line(     if centreline.len() < 2 || line.glyphs.is_empty() || px_per_font_unit <= 0.0 {         return Vec::new();     }-    let total_len = polyline_length(centreline);+    let smooth = longest_smooth_run(centreline);+    if smooth.len() < 2 {+        return Vec::new();+    }+    let total_len = polyline_length(smooth);     let run_len = line.advance * px_per_font_unit;     if run_len <= 0.0 || run_len > total_len {         return Vec::new();@@ -518,19 +580,34 @@ pub fn layout_along_line(     // Read the line in whichever direction keeps it upright: a polyline whose net heading points     // leftwards would otherwise draw every glyph upside down. Reverse the *walk*, not the glyph     // order, so the run still spells left-to-right on screen.-    let net_dx = centreline[centreline.len() - 1].0 - centreline[0].0;+    let net_dx = smooth[smooth.len() - 1].0 - smooth[0].0;     let reversed: Vec<(f32, f32)>;     let path: &[(f32, f32)] = if net_dx < 0.0 {-        reversed = centreline.iter().rev().copied().collect();+        reversed = smooth.iter().rev().copied().collect();         &reversed     } else {-        centreline+        smooth     };     let start = (total_len - run_len) * 0.5;+    // One em either side: the window each glyph's heading is averaged over. Wide enough that a+    // vertex is inside it for a few consecutive glyphs (so a bend is shared between them rather+    // than taken in one step) and that the direction noise of extent-quantised coordinates+    // averages out, narrow enough that the run still tracks a real curve.+    let half_window = UP_EM as f32 * px_per_font_unit;     let mut out = Vec::with_capacity(line.glyphs.len());     for g in &line.glyphs {         let d = start + g.pen_x * px_per_font_unit;-        let (pen, tangent) = sample_polyline(path, d);+        let (pen, segment_tangent) = sample_polyline(path, d);+        // The chord across that window, not the tangent of the segment the pen happens to sit+        // on. The segment tangent is a step function of `d`: every glyph on one segment shares+        // an angle, the angle jumps at each vertex, and on a finely-digitised road it jitters+        // with the coordinate quantisation — which is the faceted, individually-rotated look.+        // A chord between two points of a continuous polyline turns continuously.+        let (behind, _) = sample_polyline(path, d - half_window);+        let (ahead, _) = sample_polyline(path, d + half_window);+        let (dx, dy) = (ahead.0 - behind.0, ahead.1 - behind.1);+        let chord = (dx * dx + dy * dy).sqrt();+        let tangent = if chord > 1e-7 { (dx / chord, dy / chord) } else { segment_tangent };         out.push(CurvedGlyph { glyph: *g, pen, tangent });     }     out@@ -1266,4 +1343,104 @@ mod tests {             assert!((0.0..=1.0).contains(&chunk[2]) && (0.0..=1.0).contains(&chunk[3]));         }     }++    /// A synthetic run of `n` identical square glyphs, each one font-unit-em wide. Lets the+    /// along-line layout be tested without staged fonts, since it never touches the atlas.+    fn block_run(n: usize) -> ShapedLine {+        let em = UP_EM as f32;+        let glyphs: Vec<ShapedGlyph> = (0..n)+            .map(|i| ShapedGlyph {+                pen_x: i as f32 * em,+                ch: 'x',+                advance: em,+                bearing_x: 0.0,+                top: em,+                w: em,+                h: em,+            })+            .collect();+        ShapedLine { glyphs, advance: n as f32 * em }+    }++    #[test]+    fn a_join_between_two_parts_lends_no_length_to_the_fit_test() {+        // The reported truncation: a feature's parts are concatenated into one polyline, so a+        // multi-part road carries a phantom connector between them. Its length used to count+        // toward the fit test, letting a name that fits on neither part be accepted and then+        // run off the end of the first one. The name must now be rejected outright.+        let run = block_run(10); // ten ems long+        let ppfu = 1.0 / UP_EM as f32; // one em == one tile-local unit, so run_len == 10.0+        // Two collinear-but-disjoint parts of 6, bridged by a connector that doubles back.+        let two_parts = [(0.0f32, 0.0), (6.0, 0.0), (0.0, 4.0), (6.0, 4.0)];+        assert!(+            polyline_length(&two_parts) > 10.0,+            "the concatenated length alone would pass the fit test"+        );+        assert!(+            layout_along_line(&run, &two_parts, ppfu).is_empty(),+            "a run that fits no single part of the feature must not be drawn at all"+        );+    }++    #[test]+    fn a_run_is_laid_on_the_longer_part_not_across_the_join() {+        // When one part *is* long enough, the label goes there — the cheap version of "put it+        // where it fits" — and no glyph lands on the connector between the parts.+        let run = block_run(4);+        let ppfu = 1.0 / UP_EM as f32;+        // A short stub, then a sharp turn, then the real road: y == 4 for its whole length.+        let path = [(0.0f32, 0.0), (2.0, 0.0), (0.0, 4.0), (9.0, 4.0)];+        let placed = layout_along_line(&run, &path, ppfu);+        assert_eq!(placed.len(), 4, "the run fits the longer part");+        for cg in &placed {+            assert!((cg.pen.1 - 4.0).abs() < 1e-4, "glyph left the long part at y {}", cg.pen.1);+            assert!((cg.tangent.0 - 1.0).abs() < 1e-4, "and faces along it");+        }+    }++    #[test]+    fn a_single_sharp_corner_does_not_carry_glyphs() {+        // A right-angle bend is the degenerate case of the same rule: the run takes one arm.+        let run = block_run(3);+        let ppfu = 1.0 / UP_EM as f32;+        let elbow = [(0.0f32, 0.0), (4.0, 0.0), (4.0, 9.0)];+        let placed = layout_along_line(&run, &elbow, ppfu);+        assert_eq!(placed.len(), 3);+        let spread = placed+            .iter()+            .map(|c| heading(c.tangent))+            .fold(f32::NEG_INFINITY, f32::max)+            - placed.iter().map(|c| heading(c.tangent)).fold(f32::INFINITY, f32::min);+        assert!(spread < 1e-3, "no glyph straddles the corner, heading spread {spread}");+    }++    #[test]+    fn a_gentle_bend_turns_glyph_by_glyph_instead_of_in_steps() {+        // The kinked-rotation symptom. Two long segments meeting at a shallow angle used to+        // give every glyph on a segment one identical heading and then jump, so the run read as+        // separately-rotated letters. Sampling the chord each glyph spans turns it continuously:+        // consecutive headings differ, and none differs by the whole corner at once.+        let run = block_run(8);+        let ppfu = 1.0 / UP_EM as f32;+        // A 30-degree bend — inside the max turn, so it stays one run.+        let corner = 30.0f32.to_radians();+        let bend = [(0.0f32, 0.0), (6.0, 0.0), (6.0 + 6.0 * corner.cos(), 6.0 * corner.sin())];+        let placed = layout_along_line(&run, &bend, ppfu);+        assert_eq!(placed.len(), 8);+        let headings: Vec<f32> = placed.iter().map(|c| heading(c.tangent)).collect();+        let steps: Vec<f32> =+            headings.windows(2).map(|w| (w[1] - w[0]).abs()).collect();+        assert!(+            headings.last().unwrap() - headings[0] > 1e-3,+            "the run still follows the bend overall"+        );+        assert!(+            steps.iter().all(|s| *s < corner * 0.75),+            "no single glyph absorbs the whole corner: steps {steps:?}"+        );+        assert!(+            steps.iter().filter(|s| **s > 1e-4).count() >= 2,+            "the turn is shared across glyphs rather than taken in one step: {steps:?}"+        );+    } }
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 ad9c600790..c20e07ddbf 100644--- a/library/map/src/main/rust/src/tile/geometry.rs+++ b/library/map/src/main/rust/src/tile/geometry.rs@@ -369,13 +369,22 @@ pub fn build_toggled(     let mut building_vertices: Vec<f32> = Vec::new();     let mut building_indices: Vec<u32> = Vec::new();     let ground_width_m = tile_ground_width_m(z, y);+    let deepest = z.saturating_add(ANCESTOR_DEPTH);     // Every point in this tile where the carriageway changes width. Scanned once, tile-wide,     // because the step it removes is *between* two features — `coalesce`'s merge key includes     // the lane count, so a road whose count changes arrives as two — and no per-feature pass     // can see a pair.-    let transitions = taper::Nodes::scan(tile);+    //+    // Only when a carriageway will actually be built from it: with `style::LANE_RENDERING` off+    // the style carries no carriageway layer at all, and outside its zoom window none draws, so+    // otherwise this is a walk over every road feature in the tile for a result nothing reads.+    // An empty scan tapers nothing, so getting this condition wrong costs a step, not a blank map.+    // Written as the layer loop's own zoom test rather than a helper, so the two cannot drift.+    let carriageway_here =+        layers.iter().any(|l| l.carriageway && l.min_zoom <= deepest && l.max_zoom >= z);+    let transitions =+        if carriageway_here { taper::Nodes::scan(tile) } else { taper::Nodes::default() };     let taper_run = taper::taper_run(ground_width_m);-    let deepest = z.saturating_add(ANCESTOR_DEPTH);     let extent = tile.extent as u32;      for (index, layer) in layers.iter().enumerate() {@@ -1347,8 +1356,12 @@ mod tests {     }      /// The `roads-carriageway` layer as a one-layer slice, so a test states its own layer set.+    ///+    /// Read with lane rendering forced on: [`style::LANE_RENDERING`] is off for release, so the+    /// shipped layer set carries no carriageway at all and the tests below would have nothing to+    /// assert against.     fn carriageway_only() -> &'static [Layer] {-        let all = style::layers();+        let all = style::layers_with_lane_rendering();         let at = all.iter().position(|l| l.carriageway).expect("the carriageway layer");         all.get(at..=at).expect("a one-layer slice")     }@@ -1697,7 +1710,7 @@ mod tests {      /// The `junction-connector` layer as a one-layer slice, matching [`carriageway_only`].     fn connector_only() -> &'static [Layer] {-        let all = style::layers();+        let all = style::layers_with_lane_rendering();         let at = all.iter().position(|l| l.id == "junction-connector").expect("the connector layer");         all.get(at..=at).expect("a one-layer slice")     }@@ -1743,7 +1756,7 @@ mod tests {     /// they meet the kerb.     #[test]     fn connectors_and_roads_are_separate_draws_with_the_connector_over_the_road() {-        let layers = style::layers();+        let layers = style::layers_with_lane_rendering();         let roads = layers.iter().position(|l| l.id == "roads-carriageway").expect("roads");         let connectors =             layers.iter().position(|l| l.id == "junction-connector").expect("connectors");@@ -1771,7 +1784,7 @@ mod tests {     /// would actually reach a screen.     #[test]     fn a_tile_with_no_junction_layer_is_untouched_by_the_connector_layer() {-        let layers = style::layers();+        let layers = style::layers_with_lane_rendering();         let connectors =             layers.iter().position(|l| l.id == "junction-connector").expect("connectors"); 
maps/src/main/java/com/vayunmathur/maps/ui/MapScaleBar.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapScaleBar.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapScaleBar.ktindex 18d416328a..fba86c7546 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapScaleBar.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapScaleBar.kt@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier-import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Surface@@ -33,16 +32,12 @@ import kotlin.math.roundToInt  */ @Composable fun MapScaleBar(zoom: Double, latitude: Double, modifier: Modifier = Modifier) {-    val density = LocalDensity.current-    val maxBarPx = with(density) { 96.dp.toPx() }--    // Ground resolution (meters per screen pixel) at this latitude and zoom.-    val metersPerPixel = 156543.03392 * cos(latitude * PI / 180.0) / 2.0.pow(zoom)-    if (!metersPerPixel.isFinite() || metersPerPixel <= 0.0) return+    val metersPerDp = metersPerDp(zoom, latitude)+    if (!metersPerDp.isFinite() || metersPerDp <= 0.0) return      val imperial = isImperialUnits()-    val (barMeters, label) = scaleBar(metersPerPixel * maxBarPx, imperial)-    val barWidth = with(density) { (barMeters / metersPerPixel).toFloat().toDp() }+    val (barMeters, label) = scaleBar(metersPerDp * MAX_BAR_DP, imperial)+    val barWidth = (barMeters / metersPerDp).toFloat().dp      Surface(         modifier = modifier,@@ -66,6 +61,26 @@ fun MapScaleBar(zoom: Double, latitude: Double, modifier: Modifier = Modifier) {     } } +/** Longest the bar is allowed to get, in dp. */+internal const val MAX_BAR_DP = 96.0++private const val EQUATOR_METERS = 40075016.686++/** Logical pixels per tile. Must match `Mercator.TILE_SIZE` / the Rust renderer's `TILE_SIZE`. */+private const val TILE_SIZE_DP = 512.0++/**+ * Web-Mercator ground resolution in metres per logical pixel (dp).+ *+ * Everything downstream of the camera — `Mercator`, the Rust renderer's `TILE_SIZE`, the `Dp`+ * this bar is laid out in — is a 512-dp tile grid, so this must divide by 512 and must stay in+ * dp. The widely quoted 156543.03392 is the same figure for a 256-px tile, which is a factor of+ * two out here, and pairing any of it with a device pixel length brings in a second factor of+ * the screen density.+ */+internal fun metersPerDp(zoom: Double, latitude: Double): Double =+    EQUATOR_METERS * cos(latitude * PI / 180.0) / (TILE_SIZE_DP * 2.0.pow(zoom))+ /** Largest value of the form 1/2/5 × 10ⁿ that is ≤ [maxMeters]. */ private fun niceRoundDistance(maxMeters: Double): Double {     if (maxMeters <= 0.0) return 1.0@@ -83,7 +98,7 @@ private fun niceRoundDistance(maxMeters: Double): Double {  * it in the regional unit ([imperial] = ft/mi, else m/km). Returns the distance  * in METERS (for bar width) paired with the display label.  */-private fun scaleBar(maxMeters: Double, imperial: Boolean): Pair<Double, String> {+internal fun scaleBar(maxMeters: Double, imperial: Boolean): Pair<Double, String> {     if (imperial) {         val maxMiles = maxMeters / 1609.34         return if (maxMiles < 1.0) {
maps/src/main/java/com/vayunmathur/maps/ui/PoiEnrichment.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/PoiEnrichment.kt b/maps/src/main/java/com/vayunmathur/maps/ui/PoiEnrichment.ktindex 27a603c17f..33a3052176 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/PoiEnrichment.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/PoiEnrichment.kt@@ -63,13 +63,6 @@ fun GooglePoiEnrichment(info: GooglePoiInfo, section: PoiSection, showHours: Boo             PoiSection.PHOTOS -> PhotosSection(info.photoUrls)             PoiSection.REVIEWS -> ReviewsSection(info)         }--        // Trademark attribution ("Google Maps" is non-translatable, see strings.xml).-        Text(-            stringResource(R.string.poi_google_attribution),-            style = MaterialTheme.typography.labelSmall,-            color = MaterialTheme.colorScheme.onSurfaceVariant,-        )     } } 
maps/src/main/res/values/strings.xml
diff --git a/maps/src/main/res/values/strings.xml b/maps/src/main/res/values/strings.xmlindex 0d5e22eb2a..b136691a24 100644--- a/maps/src/main/res/values/strings.xml+++ b/maps/src/main/res/values/strings.xml@@ -54,9 +54,6 @@     <!-- Place detail: Rating summary. %1$s=stars e.g. "4.5", %2$s=review count e.g. "128" -->     <string name="reviews_summary"><xliff:g id="rating" example="4.5">%1$s</xliff:g> stars | <xliff:g id="review_count" example="128">%2$s</xliff:g> reviews</string> -    <!-- Place detail: Attribution for scraped POI enrichment. "Google Maps" is a product-         trademark and must not be translated. -->-    <string name="poi_google_attribution" translatable="false">Data from Google Maps</string>     <!-- Place detail: Fuel price section header, shown for gas stations only. Noun phrase. -->     <string name="poi_fuel_price_header">Fuel price</string>     <!-- Place detail: Label of the first tab under the action buttons, holding the