Modern Apps git

← Modern-Apps.git

maps: bake safety layer (stop signs, signals, cameras) into mamaps

Commit
8bed65eebf47fbcc652f69f27766bc9d9813e7eb
Author
vayun-mathur <[email protected]>
When
2026-10-25 00:07 UTC (1 month ago)
Parents
6e04f83

Diff

library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.kt b/library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.ktindex f6b1af5cc0..422d0dcb77 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.kt@@ -70,6 +70,12 @@ data class LayerOptions(      * colour draws nothing, so the basemap road shows through as the no-data look.      */     val traffic: Boolean = false,+    /**+     * Road furniture: speed and red-light cameras, licence-plate readers, surveillance+     * cameras, stop signs and traffic signals, drawn as icons from z16. Gated at tessellation+     * like the others. An archive built before the `safety` layer simply draws none.+     */+    val safety: Boolean = false, ) {     companion object {         /** The default: basemap only. */
library/map/src/main/java/com/vayunmathur/library/map/MapNative.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/MapNative.kt b/library/map/src/main/java/com/vayunmathur/library/map/MapNative.ktindex 4e57f92608..3067511349 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/MapNative.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/MapNative.kt@@ -190,6 +190,8 @@ internal object MapNative {      * call keeps its shape for the five consumers that never draw traffic.      */     external fun setTrafficEnabled(handle: Long, enabled: Boolean)+    /** Turn the safety overlay (cameras, stop signs, signals) on or off. Gated like [setTrafficEnabled]. */+    external fun setSafetyEnabled(handle: Long, enabled: Boolean)      /**      * Push the live-traffic colour table. [ids] holds each drawn segment's `component_id` and
library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapRenderer.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapRenderer.kt b/library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapRenderer.ktindex d1e348355d..57de98d0c3 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapRenderer.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapRenderer.kt@@ -388,6 +388,7 @@ class SurfaceMapRenderer(         // the layers the host asked for instead of being built and then invalidated.         MapNative.setLayers(handle, layers.poi, layers.transit, layers.poiKinds.joinToString(","))         MapNative.setTrafficEnabled(handle, layers.traffic)+        MapNative.setSafetyEnabled(handle, layers.safety)         applyUserPuck()         applyRoute()         applyRailLines()@@ -664,6 +665,7 @@ class SurfaceMapRenderer(         if (handle != 0L) {             MapNative.setLayers(handle, options.poi, options.transit, options.poiKinds.joinToString(","))             MapNative.setTrafficEnabled(handle, options.traffic)+            MapNative.setSafetyEnabled(handle, options.safety)         }         invalidate()     }
library/map/src/main/rust/assets/sprites/[email protected]
diff --git a/library/map/src/main/rust/assets/sprites/[email protected] b/library/map/src/main/rust/assets/sprites/[email protected]index 5d573aa9d8..93050759ae 100644--- a/library/map/src/main/rust/assets/sprites/[email protected]+++ b/library/map/src/main/rust/assets/sprites/[email protected]@@ -1 +1 @@-{"NL:S-road-1char":{"height":42,"pixelRatio":2,"width":42,"x":0,"y":72},"NL:S-road-2char":{"height":42,"pixelRatio":2,"width":44,"x":76,"y":42},"NL:S-road-3char":{"height":42,"pixelRatio":2,"width":50,"x":404,"y":36},"NL:S-road-4char":{"height":42,"pixelRatio":2,"width":58,"x":346,"y":0},"NL:S-road-5char":{"height":42,"pixelRatio":2,"width":64,"x":158,"y":0},"US:I-1char":{"height":42,"pixelRatio":2,"width":40,"x":168,"y":42},"US:I-2char":{"height":42,"pixelRatio":2,"width":46,"x":454,"y":36},"US:I-3char":{"height":42,"pixelRatio":2,"width":60,"x":286,"y":0},"US:I-4char":{"height":42,"pixelRatio":2,"width":64,"x":222,"y":0},"US:I-5char":{"height":42,"pixelRatio":2,"width":68,"x":90,"y":0},"aerodrome":{"height":38,"pixelRatio":2,"width":38,"x":120,"y":78},"animal":{"height":38,"pixelRatio":2,"width":38,"x":42,"y":84},"arrow":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":114},"artwork":{"height":38,"pixelRatio":2,"width":38,"x":80,"y":84},"attraction":{"height":38,"pixelRatio":2,"width":38,"x":208,"y":42},"bar":{"height":38,"pixelRatio":2,"width":38,"x":246,"y":42},"beach":{"height":38,"pixelRatio":2,"width":38,"x":284,"y":42},"beauty":{"height":38,"pixelRatio":2,"width":38,"x":322,"y":42},"bench":{"height":38,"pixelRatio":2,"width":38,"x":360,"y":42},"books":{"height":38,"pixelRatio":2,"width":38,"x":398,"y":78},"building":{"height":34,"pixelRatio":2,"width":34,"x":386,"y":154},"bus_stop":{"height":38,"pixelRatio":2,"width":38,"x":436,"y":78},"cafe":{"height":38,"pixelRatio":2,"width":38,"x":474,"y":78},"capital":{"height":20,"pixelRatio":2,"width":20,"x":420,"y":154},"clothes":{"height":38,"pixelRatio":2,"width":38,"x":208,"y":80},"convenience":{"height":38,"pixelRatio":2,"width":38,"x":158,"y":84},"drinking_water":{"height":38,"pixelRatio":2,"width":38,"x":118,"y":116},"electronics":{"height":38,"pixelRatio":2,"width":38,"x":38,"y":122},"fast_food":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":152},"ferry_terminal":{"height":38,"pixelRatio":2,"width":38,"x":76,"y":122},"forest":{"height":38,"pixelRatio":2,"width":38,"x":246,"y":80},"garden":{"height":38,"pixelRatio":2,"width":38,"x":284,"y":80},"generic_shield-1char":{"height":36,"pixelRatio":2,"width":38,"x":470,"y":0},"generic_shield-2char":{"height":36,"pixelRatio":2,"width":48,"x":120,"y":42},"generic_shield-3char":{"height":36,"pixelRatio":2,"width":66,"x":404,"y":0},"generic_shield-4char":{"height":36,"pixelRatio":2,"width":76,"x":0,"y":36},"generic_shield-5char":{"height":36,"pixelRatio":2,"width":90,"x":0,"y":0},"library":{"height":38,"pixelRatio":2,"width":38,"x":322,"y":80},"marina":{"height":38,"pixelRatio":2,"width":38,"x":360,"y":80},"museum":{"height":38,"pixelRatio":2,"width":38,"x":398,"y":116},"park":{"height":38,"pixelRatio":2,"width":38,"x":436,"y":116},"peak":{"height":38,"pixelRatio":2,"width":38,"x":474,"y":116},"post_office":{"height":38,"pixelRatio":2,"width":38,"x":196,"y":118},"restaurant":{"height":38,"pixelRatio":2,"width":38,"x":156,"y":122},"school":{"height":38,"pixelRatio":2,"width":38,"x":114,"y":154},"stadium":{"height":38,"pixelRatio":2,"width":38,"x":38,"y":160},"supermarket":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":190},"theatre":{"height":38,"pixelRatio":2,"width":38,"x":76,"y":160},"toilets":{"height":38,"pixelRatio":2,"width":38,"x":234,"y":118},"townspot":{"height":20,"pixelRatio":2,"width":20,"x":440,"y":154},"train_station":{"height":38,"pixelRatio":2,"width":38,"x":272,"y":118},"university":{"height":38,"pixelRatio":2,"width":38,"x":310,"y":118},"zoo":{"height":38,"pixelRatio":2,"width":38,"x":348,"y":118},"fuel":{"x":0,"y":228,"width":38,"height":38,"pixelRatio":2},"hotel":{"x":38,"y":228,"width":38,"height":38,"pixelRatio":2},"bank":{"x":76,"y":228,"width":38,"height":38,"pixelRatio":2},"vehicle-bus":{"x":114,"y":228,"width":38,"height":38,"pixelRatio":2},"vehicle-tram":{"x":152,"y":228,"width":38,"height":38,"pixelRatio":2},"vehicle-train":{"x":190,"y":228,"width":38,"height":38,"pixelRatio":2},"vehicle-ferry":{"x":228,"y":228,"width":38,"height":38,"pixelRatio":2},"atm":{"x":76,"y":228,"width":38,"height":38,"pixelRatio":2},"family":{"x":266,"y":228,"width":38,"height":38,"pixelRatio":2}}\ No newline at end of file+{"NL:S-road-1char":{"height":42,"pixelRatio":2,"width":42,"x":0,"y":72},"NL:S-road-2char":{"height":42,"pixelRatio":2,"width":44,"x":76,"y":42},"NL:S-road-3char":{"height":42,"pixelRatio":2,"width":50,"x":404,"y":36},"NL:S-road-4char":{"height":42,"pixelRatio":2,"width":58,"x":346,"y":0},"NL:S-road-5char":{"height":42,"pixelRatio":2,"width":64,"x":158,"y":0},"US:I-1char":{"height":42,"pixelRatio":2,"width":40,"x":168,"y":42},"US:I-2char":{"height":42,"pixelRatio":2,"width":46,"x":454,"y":36},"US:I-3char":{"height":42,"pixelRatio":2,"width":60,"x":286,"y":0},"US:I-4char":{"height":42,"pixelRatio":2,"width":64,"x":222,"y":0},"US:I-5char":{"height":42,"pixelRatio":2,"width":68,"x":90,"y":0},"aerodrome":{"height":38,"pixelRatio":2,"width":38,"x":120,"y":78},"animal":{"height":38,"pixelRatio":2,"width":38,"x":42,"y":84},"arrow":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":114},"artwork":{"height":38,"pixelRatio":2,"width":38,"x":80,"y":84},"attraction":{"height":38,"pixelRatio":2,"width":38,"x":208,"y":42},"bar":{"height":38,"pixelRatio":2,"width":38,"x":246,"y":42},"beach":{"height":38,"pixelRatio":2,"width":38,"x":284,"y":42},"beauty":{"height":38,"pixelRatio":2,"width":38,"x":322,"y":42},"bench":{"height":38,"pixelRatio":2,"width":38,"x":360,"y":42},"books":{"height":38,"pixelRatio":2,"width":38,"x":398,"y":78},"building":{"height":34,"pixelRatio":2,"width":34,"x":386,"y":154},"bus_stop":{"height":38,"pixelRatio":2,"width":38,"x":436,"y":78},"cafe":{"height":38,"pixelRatio":2,"width":38,"x":474,"y":78},"capital":{"height":20,"pixelRatio":2,"width":20,"x":420,"y":154},"clothes":{"height":38,"pixelRatio":2,"width":38,"x":208,"y":80},"convenience":{"height":38,"pixelRatio":2,"width":38,"x":158,"y":84},"drinking_water":{"height":38,"pixelRatio":2,"width":38,"x":118,"y":116},"electronics":{"height":38,"pixelRatio":2,"width":38,"x":38,"y":122},"fast_food":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":152},"ferry_terminal":{"height":38,"pixelRatio":2,"width":38,"x":76,"y":122},"forest":{"height":38,"pixelRatio":2,"width":38,"x":246,"y":80},"garden":{"height":38,"pixelRatio":2,"width":38,"x":284,"y":80},"generic_shield-1char":{"height":36,"pixelRatio":2,"width":38,"x":470,"y":0},"generic_shield-2char":{"height":36,"pixelRatio":2,"width":48,"x":120,"y":42},"generic_shield-3char":{"height":36,"pixelRatio":2,"width":66,"x":404,"y":0},"generic_shield-4char":{"height":36,"pixelRatio":2,"width":76,"x":0,"y":36},"generic_shield-5char":{"height":36,"pixelRatio":2,"width":90,"x":0,"y":0},"library":{"height":38,"pixelRatio":2,"width":38,"x":322,"y":80},"marina":{"height":38,"pixelRatio":2,"width":38,"x":360,"y":80},"museum":{"height":38,"pixelRatio":2,"width":38,"x":398,"y":116},"park":{"height":38,"pixelRatio":2,"width":38,"x":436,"y":116},"peak":{"height":38,"pixelRatio":2,"width":38,"x":474,"y":116},"post_office":{"height":38,"pixelRatio":2,"width":38,"x":196,"y":118},"restaurant":{"height":38,"pixelRatio":2,"width":38,"x":156,"y":122},"school":{"height":38,"pixelRatio":2,"width":38,"x":114,"y":154},"stadium":{"height":38,"pixelRatio":2,"width":38,"x":38,"y":160},"supermarket":{"height":38,"pixelRatio":2,"width":38,"x":0,"y":190},"theatre":{"height":38,"pixelRatio":2,"width":38,"x":76,"y":160},"toilets":{"height":38,"pixelRatio":2,"width":38,"x":234,"y":118},"townspot":{"height":20,"pixelRatio":2,"width":20,"x":440,"y":154},"train_station":{"height":38,"pixelRatio":2,"width":38,"x":272,"y":118},"university":{"height":38,"pixelRatio":2,"width":38,"x":310,"y":118},"zoo":{"height":38,"pixelRatio":2,"width":38,"x":348,"y":118},"fuel":{"x":0,"y":228,"width":38,"height":38,"pixelRatio":2},"hotel":{"x":38,"y":228,"width":38,"height":38,"pixelRatio":2},"bank":{"x":76,"y":228,"width":38,"height":38,"pixelRatio":2},"vehicle-bus":{"x":114,"y":228,"width":38,"height":38,"pixelRatio":2},"vehicle-tram":{"x":152,"y":228,"width":38,"height":38,"pixelRatio":2},"vehicle-train":{"x":190,"y":228,"width":38,"height":38,"pixelRatio":2},"vehicle-ferry":{"x":228,"y":228,"width":38,"height":38,"pixelRatio":2},"atm":{"x":76,"y":228,"width":38,"height":38,"pixelRatio":2},"family":{"x":266,"y":228,"width":38,"height":38,"pixelRatio":2},"stop_sign":{"x":304,"y":228,"width":38,"height":38,"pixelRatio":2},"traffic_signals":{"x":342,"y":228,"width":38,"height":38,"pixelRatio":2},"speed_camera":{"x":380,"y":228,"width":38,"height":38,"pixelRatio":2},"alpr":{"x":418,"y":228,"width":38,"height":38,"pixelRatio":2},"surveillance":{"x":456,"y":228,"width":38,"height":38,"pixelRatio":2}}\ No newline at end of file
library/map/src/main/rust/assets/sprites/[email protected]
diff --git a/library/map/src/main/rust/assets/sprites/[email protected] b/library/map/src/main/rust/assets/sprites/[email protected]index 002622f70c..e2836a3270 100644Binary files a/library/map/src/main/rust/assets/sprites/[email protected] and b/library/map/src/main/rust/assets/sprites/[email protected] differ
library/map/src/main/rust/src/bridge/layers.rs
diff --git a/library/map/src/main/rust/src/bridge/layers.rs b/library/map/src/main/rust/src/bridge/layers.rsindex c224938a67..5b8141e806 100644--- a/library/map/src/main/rust/src/bridge/layers.rs+++ b/library/map/src/main/rust/src/bridge/layers.rs@@ -1,4 +1,4 @@-//! Optional layers: POI, transit, traffic.+//! Optional layers: POI, transit, traffic, safety. //! //! Pure move out of `bridge.rs`; no logic changes. use super::handle::handle_mut;@@ -47,12 +47,12 @@ pub extern "system" fn Java_com_vayunmathur_library_map_MapNative_setLayers<'l>(                 .collect(),         );         if let Some(map) = handle_mut(handle) {-            // Traffic is carried through its own setter, so preserve whatever it was set to.-            let traffic = map.toggles.get().0.traffic;+            // Traffic and safety ride their own setters, so preserve whatever they were set to.+            let current = map.toggles.get().0;             let wanted = LayerToggles {                 poi,                 transit,-                traffic,+                ..current             };             if map.toggles.set(wanted, filter) {                 log_info(&format!(@@ -103,6 +103,30 @@ pub extern "system" fn Java_com_vayunmathur_library_map_MapNative_setTrafficEnab     } } +/// Turn the safety overlay (stop signs, signals, cameras) on or off.+///+/// Gated at tessellation exactly like [`setTrafficEnabled`]: the current POI/transit/traffic/kinds+/// snapshot is kept and only `safety` flips, sharing the one generation counter. An archive built+/// before the `safety` layer simply has nothing behind the gate.+#[no_mangle]+pub extern "system" fn Java_com_vayunmathur_library_map_MapNative_setSafetyEnabled<'l>(+    _env: EnvUnowned<'l>,+    _class: JClass<'l>,+    handle: jlong,+    enabled: bool,+) {+    if let Some(map) = handle_mut(handle) {+        let (current, kinds, _) = map.toggles.get();+        let wanted = LayerToggles {+            safety: enabled,+            ..current+        };+        if map.toggles.set(wanted, kinds) {+            log_info(&format!("safety layer {}", if enabled { "on" } else { "off" }));+        }+    }+}+ /// Push the live-traffic colour table: `ids[i]` is a segment's `component_id` and /// `colors[i]` the fully-resolved ARGB the device wants drawn for it. ///
library/map/src/main/rust/src/style/filter.rs
diff --git a/library/map/src/main/rust/src/style/filter.rs b/library/map/src/main/rust/src/style/filter.rsindex b68e56586f..4133b022a4 100644--- a/library/map/src/main/rust/src/style/filter.rs+++ b/library/map/src/main/rust/src/style/filter.rs@@ -100,6 +100,8 @@ pub struct GatedSummary {     pub has_transit: bool,     /// The tile carries live-traffic segments (see `tile::geometry::traffic`).     pub has_traffic: bool,+    /// A safety-toggle layer admits at least one source feature.+    pub has_safety: bool, }  impl GatedSummary {@@ -153,6 +155,9 @@ impl ToggleStamp {         if built.traffic != toggles.traffic && self.gated.has_traffic {             return true;         }+        if built.safety != toggles.safety && self.gated.has_safety {+            return true;+        }         if built.poi != toggles.poi {             if built.poi {                 // Was on: turning off removes what is shown.@@ -265,12 +270,14 @@ mod stamp_tests {                 poi,                 transit,                 traffic,+                safety: false,             },             kinds: filter,             gated: GatedSummary {                 poi_kinds,                 has_transit,                 has_traffic,+                has_safety: false,             },         }     }@@ -292,6 +299,7 @@ mod stamp_tests {             poi: true,             transit: false,             traffic: false,+            safety: false,         };         // No POI features at all: any chip change is fresh.         let bare = stamp(true, false, false, KindFilter::all(), vec![], false, false);@@ -339,6 +347,7 @@ mod stamp_tests {             poi: false,             transit: false,             traffic: false,+            safety: false,         };         let stamp = stamp(false, false, false, KindFilter::all(), vec![cafe], false, false);         assert!(!stamp.stale_under(&off, &kinds(&["cafe"])));@@ -353,11 +362,13 @@ mod stamp_tests {             poi: true,             transit: false,             traffic: false,+            safety: false,         };         let off = LayerToggles {             poi: false,             transit: false,             traffic: false,+            safety: false,         };         // Built with POI on, showing a cafe: turning off removes it.         let showing = stamp(true, false, false, KindFilter::all(), vec![cafe], false, false);@@ -388,6 +399,7 @@ mod stamp_tests {             poi: false,             transit: false,             traffic: false,+            safety: false,         };         let transit_on = LayerToggles {             transit: true,@@ -408,6 +420,20 @@ mod stamp_tests {         assert!(!traffic_tile.stale_under(&transit_on, &KindFilter::all()));     } +    /// A safety flip rebuilds only tiles whose source carries safety features.+    #[test]+    fn a_safety_flip_skips_tiles_without_the_layer() {+        let off = LayerToggles::default();+        let on = LayerToggles { safety: true, ..off };+        let bare = stamp(false, false, false, KindFilter::all(), vec![], false, false);+        assert!(!bare.stale_under(&on, &KindFilter::all()));+        let mut with_safety = bare.clone();+        with_safety.gated.has_safety = true;+        assert!(with_safety.stale_under(&on, &KindFilter::all()));+        let built_on = ToggleStamp { toggles: on, ..with_safety };+        assert!(built_on.stale_under(&off, &KindFilter::all()));+    }+     /// Identical snapshots are never stale, and `admitted` honours the empty-means-all rule.     #[test]     fn an_unchanged_snapshot_is_fresh_and_admitted_matches_admits() {@@ -416,6 +442,7 @@ mod stamp_tests {             poi: true,             transit: true,             traffic: true,+            safety: false,         };         let filter = kinds(&["cafe"]);         let stamp = stamp(true, true, true, filter.clone(), vec![cafe, bar], true, true);
library/map/src/main/rust/src/style/kinds.rs
diff --git a/library/map/src/main/rust/src/style/kinds.rs b/library/map/src/main/rust/src/style/kinds.rsindex c428c2e264..7ed5c58389 100644--- a/library/map/src/main/rust/src/style/kinds.rs+++ b/library/map/src/main/rust/src/style/kinds.rs@@ -34,6 +34,9 @@ pub enum Toggle {     /// nothing; the per-segment colours arrive separately as a pushed id→ARGB table     /// (see [`crate::vulkan::renderer::Renderer::set_traffic_speeds`]).     Traffic,+    /// Road furniture (`LAYER_SAFETY`): speed cameras, ALPR, surveillance, stop signs and+    /// traffic signals, drawn as icons when the host's safety overlay is on.+    Safety, }  /// Which optional layers are on. All off by default.@@ -42,6 +45,7 @@ pub struct LayerToggles {     pub poi: bool,     pub transit: bool,     pub traffic: bool,+    pub safety: bool, }  impl LayerToggles {@@ -55,6 +59,7 @@ impl LayerToggles {             Some(Toggle::Poi) => self.poi,             Some(Toggle::Transit) => self.transit,             Some(Toggle::Traffic) => self.traffic,+            Some(Toggle::Safety) => self.safety,         }     } }
library/map/src/main/rust/src/style/paint_extra.rs
diff --git a/library/map/src/main/rust/src/style/paint_extra.rs b/library/map/src/main/rust/src/style/paint_extra.rsindex 353533b7ed..d2771825cb 100644--- a/library/map/src/main/rust/src/style/paint_extra.rs+++ b/library/map/src/main/rust/src/style/paint_extra.rs@@ -194,6 +194,7 @@ pub(crate) fn layer(json: &Json) -> Result<Layer, String> {         None => None,         Some(Some("poi")) => Some(Toggle::Poi),         Some(Some("transit")) => Some(Toggle::Transit),+        Some(Some("safety")) => Some(Toggle::Safety),         Some(other) => return Err(format!("`{id}` has an unknown toggle {other:?}")),     };     let text_offset = match json.get("text_offset").map(|v| v.as_array()) {
library/map/src/main/rust/src/style/paint_extra3.rs
diff --git a/library/map/src/main/rust/src/style/paint_extra3.rs b/library/map/src/main/rust/src/style/paint_extra3.rsindex 931cb3569d..471de6f829 100644--- a/library/map/src/main/rust/src/style/paint_extra3.rs+++ b/library/map/src/main/rust/src/style/paint_extra3.rs@@ -30,7 +30,8 @@ fn the_vendored_flat_style_parses() {     // (country/region/locality/subplace) plus the 3 curved line labels WS-E added     // (roads-label-major, roads-label-minor, waterway-label).     //-    // Optional: 1 transit line, and 6 POI symbols — one per colour group of the+    // Optional: 1 transit line, 6 POI symbols and the app-only `safety-points` symbol. The six+    // POI layers are one per colour group of the     // reference `pois` layer's `text-color` `case` on `kind`. Six and not seven: the     // `case` has a `#e2dfda` default arm, but the same layer's `filter` admits exactly     // the 36 kinds the six groups list between them, so the default is unreachable.@@ -64,7 +65,7 @@ fn the_vendored_flat_style_parses() {             count(LayerKind::Line, true),             count(LayerKind::Symbol, true)         ),-        (0, 1, 6),+        (0, 1, 7),         "the optional layer set",     );     assert_eq!(style.background, (0xFF80DEEA, 0xFF0D1B2A));
library/map/src/main/rust/src/style/paint_extra5.rs
diff --git a/library/map/src/main/rust/src/style/paint_extra5.rs b/library/map/src/main/rust/src/style/paint_extra5.rsindex dd8dfd9a20..7c5cf60367 100644--- a/library/map/src/main/rust/src/style/paint_extra5.rs+++ b/library/map/src/main/rust/src/style/paint_extra5.rs@@ -48,6 +48,7 @@ fn the_flat_style_agrees_with_basemap_json() {                     | "landuse_swimming_pool"                     | "landuse_residential"                     | "landuse_commercial"+                    | "safety-points"             )         {             continue;
library/map/src/main/rust/src/style/paint_extra7.rs
diff --git a/library/map/src/main/rust/src/style/paint_extra7.rs b/library/map/src/main/rust/src/style/paint_extra7.rsindex 275e663e35..0093f0cd88 100644--- a/library/map/src/main/rust/src/style/paint_extra7.rs+++ b/library/map/src/main/rust/src/style/paint_extra7.rs@@ -126,6 +126,7 @@ fn every_authored_layer_a_flat_layer_names_exists() {         "landuse_swimming_pool",         "landuse_residential",         "landuse_commercial",+        "safety",     ];     for layer in layers() {         if APP_ONLY.contains(&layer.authored.as_str()) {
library/map/src/main/rust/src/style/tests.rs
diff --git a/library/map/src/main/rust/src/style/tests.rs b/library/map/src/main/rust/src/style/tests.rsindex 95aa5777f8..63e4936a51 100644--- a/library/map/src/main/rust/src/style/tests.rs+++ b/library/map/src/main/rust/src/style/tests.rs@@ -47,6 +47,7 @@ fn setting_the_same_filter_twice_does_not_bump_the_generation() {         poi: true,         transit: false,         traffic: false,+        safety: false,     };     assert!(shared.set(on, KindFilter::new(vec![cafe, bar])));     let (toggles, kinds, second) = shared.get();
library/map/src/main/rust/src/tile/geometry/build.rs
diff --git a/library/map/src/main/rust/src/tile/geometry/build.rs b/library/map/src/main/rust/src/tile/geometry/build.rsindex e5d7afcc12..0dd36d87d1 100644--- a/library/map/src/main/rust/src/tile/geometry/build.rs+++ b/library/map/src/main/rust/src/tile/geometry/build.rs@@ -139,6 +139,7 @@ pub fn build_toggled(                 // from `traffic_meshes`, probed below) — but if one ever does, its                 // matched features are traffic-gated content all the same.                 Some(Toggle::Traffic) => gated.has_traffic = true,+                Some(Toggle::Safety) => gated.has_safety = true,                 None => {}             }         }@@ -335,10 +336,11 @@ pub fn build_toggled(                     // shapes a curved label laid along its centreline. Both shape here,                     // zoom-independently — the renderer emits quads per frame at the frame's                     // text size, straight from the anchor or along the polyline.-                    let Some(name) = tile.name(feature.name_idx) else {-                        continue;-                    };-                    if name.is_empty() {+                    // Safety furniture carries no name and draws as a bare icon.+                    let icon_only =+                        layer.toggle == Some(Toggle::Safety) && feature.geom_type == GEOM_POINT;+                    let name = tile.name(feature.name_idx).unwrap_or("");+                    if name.is_empty() && !icon_only {                         continue;                     }                     match feature.geom_type {
library/map/src/main/rust/src/tile/geometry/tests.rs
diff --git a/library/map/src/main/rust/src/tile/geometry/tests.rs b/library/map/src/main/rust/src/tile/geometry/tests.rsindex 80e74d9354..6b72bd6519 100644--- a/library/map/src/main/rust/src/tile/geometry/tests.rs+++ b/library/map/src/main/rust/src/tile/geometry/tests.rs@@ -436,6 +436,7 @@ fn transit_lines_split_into_one_mesh_per_colour() {         poi: false,         transit: true,         traffic: false,+        safety: false,     };     let mesh = build_toggled(&body, only, 14, 0, 0, false, on, &KindFilter::all(), 7);     assert_eq!(
library/map/src/main/rust/src/tile/geometry/tests_extra2.rs
diff --git a/library/map/src/main/rust/src/tile/geometry/tests_extra2.rs b/library/map/src/main/rust/src/tile/geometry/tests_extra2.rsindex 6a39fadb24..a3fc51d214 100644--- a/library/map/src/main/rust/src/tile/geometry/tests_extra2.rs+++ b/library/map/src/main/rust/src/tile/geometry/tests_extra2.rs@@ -383,6 +383,7 @@ fn transit_lines_of_one_colour_split_again_on_their_corridor_ordinal() {         poi: false,         transit: true,         traffic: false,+        safety: false,     };     let mesh = build_toggled(&body, only, 14, 0, 0, false, on, &KindFilter::all(), 0);     assert_eq!(@@ -428,3 +429,44 @@ fn a_layer_whose_features_carry_no_colour_still_emits_one_mesh() {         "one mesh per layer where no feature carries a colour"     ); }++/// An unnamed safety point draws as a bare icon with the safety toggle on, and costs nothing+/// (no label, but still recorded in the gated summary) with it off.+#[test]+fn a_safety_point_is_an_icon_only_label_gated_by_its_toggle() {+    use tilecodec::mamaps::body::GEOM_POINT;+    let mut body = Body::new(4096);+    let mut source = BodyLayer::new(dict::LAYER_SAFETY);+    source.parts.push(Part { coord_start: 0, point_count: 1, winding: WINDING_OUTER });+    source.coords.push((2048, 2048));+    source.features.push(Feature {+        kind: crate::style::kind_id_for_test("stop_sign"),+        kind_detail: 0,+        geom_type: GEOM_POINT,+        flags: 0,+        name_idx: NAME_NONE,+        parts_offset: 0,+        part_count: 1,+        transit_color: 0,+        transit_ordinal: 0,+        transit_lanes: 0,+        transit_taper: 0,+        lane_count: 0,+    });+    body.layers.push(source);+    let all = style::layers();+    let at = all.iter().position(|l| l.id == "safety-points").expect("the safety layer");+    let only = &all[at..=at];+    let off = LayerToggles::default();+    let on = LayerToggles { safety: true, ..off };++    let shown = build_toggled(&body, only, 16, 0, 0, false, on, &KindFilter::all(), 0);+    assert_eq!(shown.labels.len(), 1, "one icon for one stop sign");+    assert!(shown.labels[0].lines.is_empty(), "no text: the point has no name");+    assert!(shown.labels[0].sprite.is_some(), "the stop_sign sprite resolved");+    assert!(shown.toggle_stamp.gated.has_safety);++    let hidden = build_toggled(&body, only, 16, 0, 0, false, off, &KindFilter::all(), 0);+    assert!(hidden.labels.is_empty(), "safety off draws nothing");+    assert!(hidden.toggle_stamp.gated.has_safety, "but the tile knows it holds safety");+}
library/map/src/main/rust/src/tile/geometry/tests_extra3.rs
diff --git a/library/map/src/main/rust/src/tile/geometry/tests_extra3.rs b/library/map/src/main/rust/src/tile/geometry/tests_extra3.rsindex d207ca9d24..6195472307 100644--- a/library/map/src/main/rust/src/tile/geometry/tests_extra3.rs+++ b/library/map/src/main/rust/src/tile/geometry/tests_extra3.rs@@ -74,6 +74,7 @@ fn traffic_on() -> LayerToggles {         poi: false,         transit: false,         traffic: true,+        safety: false,     } } 
library/map/src/main/rust/src/tile/geometry/tests_extra8.rs
diff --git a/library/map/src/main/rust/src/tile/geometry/tests_extra8.rs b/library/map/src/main/rust/src/tile/geometry/tests_extra8.rsindex dfe318ac4e..61ac79ced8 100644--- a/library/map/src/main/rust/src/tile/geometry/tests_extra8.rs+++ b/library/map/src/main/rust/src/tile/geometry/tests_extra8.rs@@ -77,6 +77,7 @@ fn build_toggled_stamps_the_snapshot_and_gated_summary() {         poi: true,         transit: false,         traffic: false,+        safety: false,     };     let mesh = build_toggled(&body, layers, 14, 0, 0, false, toggles, &KindFilter::all(), 9);     assert_eq!(mesh.generation, 9, "the generation fast path is unchanged");
library/map/src/main/rust/src/tile/sprite.rs
diff --git a/library/map/src/main/rust/src/tile/sprite.rs b/library/map/src/main/rust/src/tile/sprite.rsindex caf228fc3d..e3b2dae626 100644--- a/library/map/src/main/rust/src/tile/sprite.rs+++ b/library/map/src/main/rust/src/tile/sprite.rs@@ -74,7 +74,7 @@ use super::sprite_extra::decode_rgba8; /// The 2x sprite sheet, embedded. An APK asset is not a file the renderer can open, so /// the bytes ship in the `.so` exactly as the fonts do. const SHEET_PNG: &[u8] = include_bytes!("../../assets/sprites/[email protected]");-/// Its index: 62 entries of `{x, y, width, height, pixelRatio}`.+/// Its index: 67 entries of `{x, y, width, height, pixelRatio}`. const SHEET_JSON: &str = include_str!("../../assets/sprites/[email protected]");  /// One icon in the sheet: where to sample it, and how big to draw it.@@ -313,8 +313,8 @@ mod tests {         assert_eq!(atlas.pixels.len(), 512 * 532 * 4, "RGBA8, tightly packed");         assert_eq!(             atlas.len(),-            62,-            "upstream's 53 entries plus fuel, hotel, bank, atm, the four vehicle mode sprites and family"+            67,+            "upstream's 53 entries plus fuel, hotel, bank, atm, the four vehicle mode sprites, family and the five safety icons"         );         assert_eq!(atlas.dark_v_offset(), 0.5, "two equal halves");     }@@ -446,6 +446,22 @@ mod tests {         assert!(atlas().get("").is_none());     } +    /// Every safety kind the `safety-points` layer draws resolves to its own icon, inside the+    /// light half, so the safety overlay never draws a neighbouring rect or nothing.+    #[test]+    fn every_safety_kind_resolves_to_its_own_sprite() {+        let atlas = atlas();+        let dv = atlas.dark_v_offset();+        let mut seen = Vec::new();+        for kind in ["speed_camera", "alpr", "surveillance", "stop_sign", "traffic_signals"] {+            let sprite = atlas.get(kind).unwrap_or_else(|| panic!("`{kind}` has no sprite"));+            assert!(sprite.uv.v1 <= dv, "`{kind}` strays into the dark half");+            assert!((sprite.width_dp - 19.0).abs() < 1e-6, "`{kind}` is {} Dp", sprite.width_dp);+            assert!(!seen.contains(&sprite.uv.u0.to_bits()), "`{kind}` shares a rect");+            seen.push(sprite.uv.u0.to_bits());+        }+    }+     /// A sheet that will not decode must leave an atlas that answers every lookup with     /// `None`, because that is the path the renderer relies on to keep drawing labels.     #[test]
library/map/src/main/rust/src/tile/symbol/shape.rs
diff --git a/library/map/src/main/rust/src/tile/symbol/shape.rs b/library/map/src/main/rust/src/tile/symbol/shape.rsindex 81b4f88816..690672b584 100644--- a/library/map/src/main/rust/src/tile/symbol/shape.rs+++ b/library/map/src/main/rust/src/tile/symbol/shape.rs@@ -31,8 +31,14 @@ pub fn shape_label(     };     // `text_max_width` is zero on every place layer, which is the single-line path and     // therefore byte-identical to what `shape` alone used to produce.-    let lines = text::shape_wrapped(atlas, weight, name, layer.uppercase, layer.text_max_width);-    if lines.is_empty() {+    let lines = if name.is_empty() {+        Vec::new()+    } else {+        text::shape_wrapped(atlas, weight, name, layer.uppercase, layer.text_max_width)+    };+    let sprite = if layer.icon { sprite_for(feature.kind) } else { None };+    // An unnamed point is drawable only as an icon (safety furniture); otherwise no text, no label.+    if lines.is_empty() && !(name.is_empty() && sprite.is_some()) {         return None;     }     let total_advance = lines@@ -52,11 +58,7 @@ pub fn shape_label(         // Only the POI layers ask for an icon, and a kind the sheet has no picture for         // (`townhall`) simply draws label-only — which is what MapLibre does with a         // missing `icon-image`.-        sprite: if layer.icon {-            sprite_for(feature.kind)-        } else {-            None-        },+        sprite,         // Places carry the tiler's 0–3 population rank as a NUMERIC detail         // (see schema/places.rs); anything else is unranked.         pop: if feature.flags & tilecodec::mamaps::body::FLAG_DETAIL_NUMERIC != 0 {@@ -189,9 +191,8 @@ pub(crate) fn rank_for_layer(id: &str) -> u8 {         // merely because its colour was authored later in the file. Without this they fall         // through to `u8::MAX` and lose every collision to every place label — which at         // z17, where places are sparse, would look almost right and be wrong.-        "poi-outdoor" | "poi-transport" | "poi-civic" | "poi-shop" | "poi-food" | "poi-culture" => {-            4-        }+        "poi-outdoor" | "poi-transport" | "poi-civic" | "poi-shop" | "poi-food" | "poi-culture"+        | "safety-points" => 4,         // Line labels below the point labels: a road or river name yields to a place or POI at a         // collision, matching MapLibre's default `symbol-z-order`. Major roads above minor above         // rivers, so a highway name wins over a side street and both over the waterway they cross.
library/map/src/main/rust/style/basemap.flat.json
diff --git a/library/map/src/main/rust/style/basemap.flat.json b/library/map/src/main/rust/style/basemap.flat.jsonindex 89f771fb53..3157d2212f 100644--- a/library/map/src/main/rust/style/basemap.flat.json+++ b/library/map/src/main/rust/style/basemap.flat.json@@ -852,6 +852,22 @@       "halo_dark": "#0d1b2a",       "halo_width": 1     },+    {+      "id": "safety-points",+      "authored": "safety",+      "source": "safety",+      "type": "symbol",+      "kinds": ["speed_camera", "alpr", "surveillance", "stop_sign", "traffic_signals"],+      "toggle": "safety",+      "icon": true,+      "minzoom": 16,+      "light": "#5c5c5c",+      "dark": "#d0d0d0",+      "text_size": 10,+      "halo_light": "#ffffff",+      "halo_dark": "#0d1b2a",+      "halo_width": 1+    },     {       "id": "roads-label-major",       "authored": "roads_labels_major",
library/tilecodec/src/main/rust/src/mamaps/dict.rs
diff --git a/library/tilecodec/src/main/rust/src/mamaps/dict.rs b/library/tilecodec/src/main/rust/src/mamaps/dict.rsindex ffccb6545d..41dc20d774 100644--- a/library/tilecodec/src/main/rust/src/mamaps/dict.rs+++ b/library/tilecodec/src/main/rust/src/mamaps/dict.rs@@ -40,6 +40,6 @@ mod tests;  pub use tables::{     DETAILS, KINDS, LAYERS, LAYER_BOUNDARIES, LAYER_BUILDINGS, LAYER_JUNCTION, LAYER_LANDTYPE,-    LAYER_PLACES, LAYER_POI, LAYER_ROADS, LAYER_TRAFFIC, LAYER_TRANSIT, NONE,+    LAYER_PLACES, LAYER_POI, LAYER_ROADS, LAYER_SAFETY, LAYER_TRAFFIC, LAYER_TRANSIT, NONE, }; pub use types::Dictionary;
library/tilecodec/src/main/rust/src/mamaps/dict/parse.rs
diff --git a/library/tilecodec/src/main/rust/src/mamaps/dict/parse.rs b/library/tilecodec/src/main/rust/src/mamaps/dict/parse.rsindex 5c258ed07c..24231e02ef 100644--- a/library/tilecodec/src/main/rust/src/mamaps/dict/parse.rs+++ b/library/tilecodec/src/main/rust/src/mamaps/dict/parse.rs@@ -52,11 +52,10 @@ impl Dictionary {     /// that id 17 means `national_park` in every archive ever written, so an archive that     /// disagrees anywhere would render some layer in the wrong colour with no other symptom.     ///-    /// Strict by deliberate scope decision (no backward-compat requirement: nobody is using the-    /// app): the dict is frozen, every archive is built from this tree, and an archive built-    /// from anything else is refused rather than reinterpreted. An older archive — including-    /// prod planet.mamaps with its v1 dict — does NOT open under this reader; rebuild it from-    /// the frozen tree instead.+    /// An archive whose tables are a strict **prefix** of the schema still opens: the tables are+    /// append-only, so every id it uses means the same thing here, and a layer it predates simply+    /// has no features. That lets a reader that knows `safety` keep drawing the archive built+    /// before it. A table that is longer than the schema, or differs anywhere, is refused.     pub fn check_matches_schema(&self) -> Result<()> {         let schema = Dictionary::schema();         for (what, ours, theirs) in [@@ -64,7 +63,7 @@ impl Dictionary {             ("kind", &schema.kinds, &self.kinds),             ("kind_detail", &schema.details, &self.details),         ] {-            if ours == theirs {+            if theirs.len() <= ours.len() && ours[..theirs.len()] == theirs[..] {                 continue;             }             let first = ours
library/tilecodec/src/main/rust/src/mamaps/dict/tables.rs
diff --git a/library/tilecodec/src/main/rust/src/mamaps/dict/tables.rs b/library/tilecodec/src/main/rust/src/mamaps/dict/tables.rsindex 59374b3ece..56c99729cd 100644--- a/library/tilecodec/src/main/rust/src/mamaps/dict/tables.rs+++ b/library/tilecodec/src/main/rust/src/mamaps/dict/tables.rs@@ -35,6 +35,7 @@ pub const LAYERS: &[&str] = &[     "transit",     "traffic",     "junction",+    "safety", ];  pub const LAYER_LANDTYPE: u8 = 0;@@ -61,6 +62,11 @@ pub const LAYER_TRAFFIC: u8 = 7; /// built or shipped — there is no deployed reader to refuse. Any layer appended after a v7 /// archive exists must bump the format, the way v4 did for `traffic`. pub const LAYER_JUNCTION: u8 = 8;+/// One `GEOM_POINT` per OSM safety node (speed/red-light cameras, ALPR, surveillance, stop+/// signs, traffic signals). Excluded from the basemap style: it draws only when the safety+/// overlay is enabled. Archives built before it still open (prefix rule in+/// `check_matches_schema`) and just carry no safety features.+pub const LAYER_SAFETY: u8 = 9;  /// Every `kind` value the schema can emit, id 1 upward. Index 0 is [`NONE`]. ///@@ -228,6 +234,12 @@ pub const KINDS: &[&str] = &[     "orchard",     "vineyard",     "quarry",+    // safety. Names match `osm_ingest::safety` kinds and the renderer's sprite names.+    "speed_camera",+    "alpr",+    "surveillance",+    "stop_sign",+    "traffic_signals", ];  /// Every `kind_detail` value, id 1 upward. Index 0 is [`NONE`].
library/tilecodec/src/main/rust/src/mamaps/dict/tests.rs
diff --git a/library/tilecodec/src/main/rust/src/mamaps/dict/tests.rs b/library/tilecodec/src/main/rust/src/mamaps/dict/tests.rsindex 016989113f..82f7f9cd81 100644--- a/library/tilecodec/src/main/rust/src/mamaps/dict/tests.rs+++ b/library/tilecodec/src/main/rust/src/mamaps/dict/tests.rs@@ -38,7 +38,8 @@ fn kind_ids_are_positions_in_a_constant_table() {     assert_eq!(d.layer_name(LAYER_TRANSIT), Some("transit"), "v2 reserves transit");     assert_eq!(d.layer_name(LAYER_TRAFFIC), Some("traffic"), "v4's live traffic layer");     assert_eq!(d.layer_name(LAYER_JUNCTION), Some("junction"), "v7's lane connectors");-    assert_eq!(d.layer_name(9), None, "past the table");+    assert_eq!(d.layer_name(LAYER_SAFETY), Some("safety"), "the safety overlay");+    assert_eq!(d.layer_name(10), None, "past the table"); }  /// A duplicate would give one value two ids, so half the features carrying it would filter@@ -77,15 +78,17 @@ fn an_archive_whose_tables_differ_is_refused() {     let mut renamed_layer = Dictionary::schema();     renamed_layer.layers[0] = "ground".to_string();     assert!(renamed_layer.check_matches_schema().is_err());-    // A shorter table is refused too, even when it is a prefix: the dict is frozen and an-    // archive built from anything but this tree is a different contract, not an older one.-    // (No backward-compat requirement: rebuild the archive instead.)-    let mut short = Dictionary::schema();-    short.layers.truncate(4);-    assert!(short.check_matches_schema().is_err(), "a 4-layer table opened");-    let mut short_details = Dictionary::schema();-    short_details.details.truncate(40);-    assert!(short_details.check_matches_schema().is_err(), "a 40-detail table opened");+    // A shorter table that is a prefix opens: an archive built before an append still means+    // the same thing for every id it carries.+    let mut pre_safety = Dictionary::schema();+    pre_safety.layers.truncate(LAYER_SAFETY as usize);+    pre_safety.kinds.truncate(pre_safety.kinds.len() - 5);+    assert!(pre_safety.check_matches_schema().is_ok(), "a pre-safety archive was refused");+    // A shorter table that differs inside the prefix is still refused.+    let mut short_renamed = Dictionary::schema();+    short_renamed.layers.truncate(4);+    short_renamed.layers[1] = "streets".to_string();+    assert!(short_renamed.check_matches_schema().is_err());     // And a table *longer* than the schema is refused: those ids mean nothing here.     let mut long = Dictionary::schema();     long.kinds.push("future_kind".to_string());
maps/src/main/java/com/vayunmathur/maps/ui/SafetyLayer.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/SafetyLayer.kt b/maps/src/main/java/com/vayunmathur/maps/ui/SafetyLayer.ktindex b1871537f5..51cf379b72 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/SafetyLayer.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/SafetyLayer.kt@@ -1,18 +1,12 @@ package com.vayunmathur.maps.ui -import androidx.compose.runtime.Composable- /**- * Safety / road-furniture data source (P13). The features are baked into the- * overlay PMTiles archive (source-layer [SOURCE_LAYER]).- *- * Each `safety` feature carries a `kind` in [KIND_SPEED_CAMERA],- * [KIND_ALPR], [KIND_SURVEILLANCE], [KIND_STOP_SIGN], [KIND_TRAFFIC_SIGNALS].+ * The safety overlay's `.mamaps` contract: the `safety` source layer and the kinds it carries.+ * Drawn by the renderer (`safety-points` style layer) when `LayerOptions.safety` is on.  */ object SafetyLayersSource {-    /** Baked into the overlay PMTiles. */     const val SOURCE_LAYER: String = "safety"-    const val LAYER_ID: String = "safety-icons"+    const val LAYER_ID: String = "safety-points"      const val KIND_SPEED_CAMERA = "speed_camera"     const val KIND_ALPR = "alpr"@@ -20,20 +14,5 @@ object SafetyLayersSource {     const val KIND_STOP_SIGN = "stop_sign"     const val KIND_TRAFFIC_SIGNALS = "traffic_signals" -    /** Whether the overlay tileset exists. The pin rendering additionally needs renderer-     *  vector-layer support (see [SafetyLayer]) before anything draws. */     val available: Boolean get() = true }--/**- * Mount the safety-layers overlay when [enabled] (the P6 LayersSheet toggle).- *- * Currently a NO-OP (renderer gap, reported to lead — library:map has no vector-layer API,- * so the `safety` source-layer cannot be drawn). Kept so the toggle wiring and the- * [SafetyLayersSource] contract survive the swap untouched.- */-@Composable-fun SafetyLayer(enabled: Boolean) {-    if (!enabled || !SafetyLayersSource.available) return-    // Intentionally empty until the renderer can draw vector source-layers.-}
maps/src/main/java/com/vayunmathur/maps/ui/map/MapLayers.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapLayers.kt b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapLayers.ktindex 38a7883bb0..71a6dc5216 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapLayers.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapLayers.kt@@ -4,7 +4,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.platform.LocalContext import com.vayunmathur.maps.ui.RoadsLayer-import com.vayunmathur.maps.ui.SafetyLayer import com.vayunmathur.maps.ui.SatelliteLayer import com.vayunmathur.maps.ui.TransitStopsLayer import com.vayunmathur.maps.util.OfflineRouterLifecycle@@ -25,17 +24,16 @@ import kotlinx.coroutines.withContext  * [com.vayunmathur.library.map.UserPuck] and [com.vayunmathur.library.map.RouteOverlay]).  *  * What is still Compose here draws no pins, so none of it lags a pan: satellite imagery, and the- * roads/safety/transit-stop overlays that remain **no-ops** until the renderer grows a vector+ * roads/transit-stop overlays that remain **no-ops** until the renderer grows a vector  * source-layer API (reported to lead — symbol-renderer owns that). The basemap draws its own road  * network and ambient POIs regardless; POI taps arrive as `MapClick.poi`.  *- * Traffic is not here: the renderer draws the baked per-component layer, coloured from a table- * [MapSurface] resolves from the theme and pushes in, gated by the traffic toggle.+ * Traffic and safety are not here: the renderer draws both baked layers, gated by their+ * toggles through `LayerOptions` in [MapSurface].  */ @Composable fun MapLayers(     satelliteEnabled: Boolean = false,-    safetyEnabled: Boolean = false,     transitEnabled: Boolean = false, ) {     val context = LocalContext.current@@ -55,10 +53,6 @@ fun MapLayers(     // Our own road rendering — no-op until the renderer can draw vector source-layers.     RoadsLayer() -    // Safety / road-furniture layer. Gated on the toggle; no-op until the renderer can-    // draw vector source-layers.-    SafetyLayer(safetyEnabled)-     if (transitEnabled) {         // Baked GTFS stop pins. No-op until the renderer can draw vector source-layers;         // tap a stop → live departure board (handled in MapSurface.onMapClick).
maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.kt b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.ktindex 2439848663..d3fd650b3f 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurface.kt@@ -90,7 +90,7 @@ fun MapSurface(     // VulkanMapSurface keys a LaunchedEffect on this by equality and a fresh instance every     // recomposition would churn it.     val selectedCategory = chrome.selectedCategory-    val mapOptions = remember(transitEnabled, selectedCategory, trafficEnabled) {+    val mapOptions = remember(transitEnabled, selectedCategory, trafficEnabled, safetyEnabled) {         MapOptions(             layerOptions = LayerOptions(                 poi = true,@@ -99,6 +99,7 @@ fun MapSurface(                 // Gates the baked traffic layer's geometry (renderer layer 10). The colours                 // ride in separately via [trafficColors] below.                 traffic = trafficEnabled,+                safety = safetyEnabled,             ),             // maps is the one app that pushes a `.mamaps` archive to external files, so it             // reads tiles from the file; every other app streams from the server (the default).@@ -341,7 +342,6 @@ fun MapSurface(     ) {         MapLayers(             satelliteEnabled = satelliteEnabled,-            safetyEnabled = safetyEnabled,             transitEnabled = transitEnabled,         )     }
scripts/maps/mamaps_build/src/extract_part2.rs
diff --git a/scripts/maps/mamaps_build/src/extract_part2.rs b/scripts/maps/mamaps_build/src/extract_part2.rsindex 03ebb4dadc..6d32283723 100644--- a/scripts/maps/mamaps_build/src/extract_part2.rs+++ b/scripts/maps/mamaps_build/src/extract_part2.rs@@ -199,11 +199,13 @@ fn build_resolved_table(         if !select.matches(|k| node.tags.get_str(k)) {             return None;         }-        let class = schema::classify(&node.tags, false, layers)?;-        if !is_label(class.layer) {-            return None;-        }-        if class.layer == tilecodec::mamaps::dict::LAYER_POI+        // A node no label claimed may still be road furniture. Safety is asked only here, in the+        // node pass, so a way or relation can never land in the point-only `safety` layer.+        let class = schema::classify(&node.tags, false, layers)+            .filter(|c| is_label(c.layer))+            .or_else(|| schema::safety::classify(&node.tags))?;+        let safety = class.layer == tilecodec::mamaps::dict::LAYER_SAFETY;+        if (safety || class.layer == tilecodec::mamaps::dict::LAYER_POI)             && !osm_ingest::bbox::keep_e7(region, node.lat_e7, node.lon_e7)         {             return None;@@ -214,7 +216,7 @@ fn build_resolved_table(             node.lon_e7 as f64 * 1e-7,             node.lat_e7 as f64 * 1e-7,             name,-            tagged_id(node.id, ELEMENT_NODE),+            if safety { tilecodec::mamaps::body::ID_NONE } else { tagged_id(node.id, ELEMENT_NODE) },         ))     };     let drain = |hits: Vec<(Class, f64, f64, Option<String>, u64)>| -> Result<()> {
scripts/maps/mamaps_build/src/schema/mod.rs
diff --git a/scripts/maps/mamaps_build/src/schema/mod.rs b/scripts/maps/mamaps_build/src/schema/mod.rsindex 306d57c4f0..510b921af3 100644--- a/scripts/maps/mamaps_build/src/schema/mod.rs+++ b/scripts/maps/mamaps_build/src/schema/mod.rs@@ -32,6 +32,7 @@ pub mod places; pub mod poi; pub mod roads; pub mod roads_extra;+pub mod safety; pub mod traffic; pub mod traffic_extra; pub mod transit;@@ -162,7 +163,7 @@ pub fn detail(name: &str) -> u16 { /// z14 traffic was the layer's dominant cost. Every other layer tiles to the archive /// max (14). Enforced in the spill lane filter beside `min_zoom`, so no spill format /// change: a per-layer table, not a per-feature field.-pub const MAX_ZOOM_PER_LAYER: [u8; 9] = [+pub const MAX_ZOOM_PER_LAYER: [u8; 10] = [     14, // landtype     14, // roads     12, // boundaries (overzoomed at z13+)@@ -172,6 +173,7 @@ pub const MAX_ZOOM_PER_LAYER: [u8; 9] = [     14, // transit     13, // traffic (overzoomed at z14; ids unaffected)     14, // junction+    14, // safety ];  /// The cap for `layer`, or 14 (no cap) for an id outside the table.@@ -299,6 +301,7 @@ pub fn filters() -> Vec<&'static str> {     out.extend_from_slice(boundaries::FILTERS);     out.extend_from_slice(places::FILTERS);     out.extend_from_slice(poi::FILTERS);+    out.extend_from_slice(safety::FILTERS);     // No `transit` entry: the layer's geometry comes from a GTFS export rather than the `.osm.pbf`,     // and the one tag it still reads — `station`, for a station POI's `kind_detail` — is screened by     // `poi::FILTERS`.@@ -320,6 +323,7 @@ mod tests {             .chain(boundaries::KINDS)             .chain(places::KINDS)             .chain(poi::KINDS)+            .chain(safety::KINDS)         {             assert!(                 dict::KINDS.contains(name),@@ -384,7 +388,7 @@ mod tests {         for key in [             "natural", "waterway", "landuse", "water", "building", "highway", "railway",             "boundary", "place", "leisure", "amenity", "shop", "tourism", "aeroway", "man_made",-            "public_transport", "name", "route", "station",+            "public_transport", "name", "route", "station", "enforcement",         ] {             assert!(all.contains(&key), "the screen omits `{key}`");         }@@ -411,6 +415,7 @@ mod tests {             dict::LAYER_POI,             dict::LAYER_TRANSIT,             dict::LAYER_JUNCTION,+            dict::LAYER_SAFETY,         ] {             assert_eq!(max_zoom_for_layer(layer), 14, "layer {layer} is street detail");         }
scripts/maps/mamaps_build/src/schema/safety.rs
diff --git a/scripts/maps/mamaps_build/src/schema/safety.rs b/scripts/maps/mamaps_build/src/schema/safety.rsnew file mode 100644index 0000000000..ddf40507dd--- /dev/null+++ b/scripts/maps/mamaps_build/src/schema/safety.rs@@ -0,0 +1,62 @@+//! The `safety` layer: speed cameras, ALPR, surveillance cameras, stop signs and traffic signals.+//!+//! Classification is [`osm_ingest::safety::classify`], the port of `normalize_safety.py`; this+//! module only adapts tags to it and interns the result. Nodes only — extract calls it from the+//! node pass, never for a way or a relation.++use osm_ingest::safety::{self, SafetyTags};+use tilecodec::mamaps::dict;++use super::{kind, Class, TagSource};++/// Carried at the archive max only: dense at every intersection and drawn from z16 by overzoom.+pub const MIN_ZOOM: u8 = 14;++pub const KINDS: &[&str] = &["speed_camera", "alpr", "surveillance", "stop_sign", "traffic_signals"];++pub const FILTERS: &[&str] = &["highway", "man_made", "enforcement"];++pub fn classify(tags: &(impl TagSource + ?Sized)) -> Option<Class> {+    let t = SafetyTags {+        highway: tags.get("highway"),+        man_made: tags.get("man_made"),+        enforcement: tags.get("enforcement"),+        surveillance_type: tags.get("surveillance:type"),+        camera_type: tags.get("camera:type"),+        operator: tags.get("operator"),+        manufacturer: tags.get("manufacturer"),+        ..SafetyTags::default()+    };+    let found = safety::classify(&t)?;+    Some(Class::line(dict::LAYER_SAFETY, kind(found.as_str()), MIN_ZOOM))+}++#[cfg(test)]+mod tests {+    use super::*;++    fn kind_of(tags: &[(&str, &str)]) -> Option<&'static str> {+        classify(tags).map(|c| {+            assert_eq!(c.layer, dict::LAYER_SAFETY);+            dict::KINDS[c.kind as usize - 1]+        })+    }++    #[test]+    fn each_kind_classifies() {+        assert_eq!(kind_of(&[("highway", "stop")]), Some("stop_sign"));+        assert_eq!(kind_of(&[("highway", "traffic_signals")]), Some("traffic_signals"));+        assert_eq!(kind_of(&[("highway", "speed_camera")]), Some("speed_camera"));+        assert_eq!(+            kind_of(&[("man_made", "surveillance"), ("enforcement", "maxspeed")]),+            Some("speed_camera"),+        );+        assert_eq!(+            kind_of(&[("man_made", "surveillance"), ("surveillance:type", "ALPR")]),+            Some("alpr"),+        );+        assert_eq!(kind_of(&[("man_made", "surveillance")]), Some("surveillance"));+        assert_eq!(kind_of(&[("highway", "residential")]), None);+        assert_eq!(kind_of(&[("amenity", "cafe")]), None);+    }+}
scripts/maps/mamaps_build/src/tiler_part9.rs
diff --git a/scripts/maps/mamaps_build/src/tiler_part9.rs b/scripts/maps/mamaps_build/src/tiler_part9.rsindex 83d40c75f1..0f648c2efb 100644--- a/scripts/maps/mamaps_build/src/tiler_part9.rs+++ b/scripts/maps/mamaps_build/src/tiler_part9.rs@@ -18,7 +18,7 @@ mod tests_part9 {         use tilecodec::mamaps::dict::LAYERS;         // Eight content layers: landtype..junction minus transit, whose geometry         // comes from a GTFS export the fixture path does not carry.-        let layers: [(u8, Class, Geometry); 8] = [+        let layers: [(u8, Class, Geometry); 9] = [             (                 dict::LAYER_LANDTYPE,                 Class::area(dict::LAYER_LANDTYPE, crate::schema::kind("lake"), 0),@@ -59,8 +59,13 @@ mod tests_part9 {                 crate::schema::junction::junction_class(),                 Geometry::Lines(vec![vec![(-120.0, 35.0), (-119.9996, 35.0004)]]),             ),+            (+                dict::LAYER_SAFETY,+                crate::schema::safety::classify(&[("highway", "stop")][..]).expect("stop"),+                Geometry::Points(vec![(-120.0, 35.0)]),+            ),         ];-        assert_eq!(LAYERS.len(), 9, "nine layers in the dictionary, eight tiled here");+        assert_eq!(LAYERS.len(), 10, "ten layers in the dictionary, nine tiled here");         let mut seen = std::collections::BTreeSet::new();         for (layer_id, class, geometry) in layers {             let feature = Feature {