Modern Apps git

← Modern-Apps.git

maps: dedicated vehicle sprites with route-color rings

Commit
07a50bd4ad5d1ab7df4700b33ea8621b717303d2
Author
vayun-mathur <[email protected]>
When
2026-09-14 05:49 UTC (2 months ago)
Parents
dcc786f

Diff

library/map/src/main/java/com/vayunmathur/library/map/MapMarker.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/MapMarker.kt b/library/map/src/main/java/com/vayunmathur/library/map/MapMarker.ktindex be6da99e14..4f7a4d6837 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/MapMarker.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/MapMarker.kt@@ -13,11 +13,15 @@ package com.vayunmathur.library.map  *   `0` is reserved by the pick path to mean "nothing", so avoid it for a real pin.  * @param position the ground point the pin sits on.  * @param icon which atlas icon to draw — one of [MarkerIcon].+ * @param color route colour packed as `0xRRGGBB` for the ring drawn under a+ *   transit-vehicle sprite so it reads in its line's colour; `0` draws no+ *   ring. Only vehicles carry one today — app pins leave the default.  */ data class MapMarker(     val id: Long,     val position: GeoPoint,     val icon: Int,+    val color: Int = 0, )  /**
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 18a1225af5..6dc8f28790 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@@ -230,8 +230,10 @@ internal object MapNative {      *      * The same three parallel bulk arrays as [setMarkers] — [ids] each vehicle's stable per-trip id,      * [lonLat] a flat `[lon0, lat0, lon1, lat1, …]`, and [icons] each vehicle's mode sprite id (the-     * `VEHICLE_*` entries in [MarkerIcon]) — because a vehicle is a marker whose icon names a mode-     * sprite, so it reuses the marker draw path verbatim.+     * `VEHICLE_*` entries in [MarkerIcon]) — plus [colors], each vehicle's GTFS `route_color`+     * packed as `0xRRGGBB` (`0` draws no ring). A nonzero colour draws a route-coloured ring under+     * the sprite so the vehicle reads in its line's colour. Because a vehicle is a marker whose+     * icon names a mode sprite, it reuses the marker draw path verbatim.      *      * Separate from [setMarkers] so the app's ~1 Hz vehicle recompute replaces only the vehicles and      * leaves the pins untouched, and so the moving vehicle sprites stay out of the pin id-buffer pick@@ -241,7 +243,13 @@ internal object MapNative {      * linger. Mismatched array lengths are truncated to the shortest; an empty set is the same as      * [clearVehicles].      */-    external fun setVehicles(handle: Long, ids: LongArray, lonLat: FloatArray, icons: IntArray)+    external fun setVehicles(+        handle: Long,+        ids: LongArray,+        lonLat: FloatArray,+        icons: IntArray,+        colors: IntArray,+    )      /** Take every simulated vehicle away: the transit toggle went off, or the surface was hidden. */     external fun clearVehicles(handle: Long)
library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapOverlays.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapOverlays.kt b/library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapOverlays.ktindex d1ac460d34..03b848002a 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapOverlays.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/SurfaceMapOverlays.kt@@ -23,6 +23,35 @@ internal fun packMapMarkers(pins: List<MapMarker>): Triple<LongArray, FloatArray     return Triple(ids, lonLat, icons) } +/**+ * Packs vehicle lists into the four parallel bulk arrays the native vehicle+ * path reads: the three marker arrays plus per-vehicle route colours packed+ * as `0xRRGGBB` (`0` draws no ring). Separate from [packMapMarkers] so the pin+ * path keeps its three-array JNI signature.+ */+internal data class PackedVehicles(+    val ids: LongArray,+    val lonLat: FloatArray,+    val icons: IntArray,+    val colors: IntArray,+)++internal fun packVehicles(vehicles: List<MapMarker>): PackedVehicles {+    val ids = LongArray(vehicles.size)+    val lonLat = FloatArray(vehicles.size * 2)+    val icons = IntArray(vehicles.size)+    val colors = IntArray(vehicles.size)+    for (i in vehicles.indices) {+        val v = vehicles[i]+        ids[i] = v.id+        lonLat[i * 2] = v.position.longitude.toFloat()+        lonLat[i * 2 + 1] = v.position.latitude.toFloat()+        icons[i] = v.icon+        colors[i] = v.color and 0x00FFFFFF+    }+    return PackedVehicles(ids, lonLat, icons, colors)+}+ /**  * The route, traffic and picking half of [SurfaceMapRenderer], as `internal`  * extensions so SurfaceMapRenderer.kt stays under the FileLength limit. Public
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 f0b9b821fc..f2d7e5ac3c 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@@ -668,8 +668,8 @@ class SurfaceMapRenderer(             MapNative.clearVehicles(handle)             return         }-        val (ids, lonLat, icons) = packMapMarkers(vs)-        MapNative.setVehicles(handle, ids, lonLat, icons)+        val packed = packVehicles(vs)+        MapNative.setVehicles(handle, packed.ids, packed.lonLat, packed.icons, packed.colors)     }  
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 749206d689..d9d65af65a 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},"atm":{"x":76,"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}}\ 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 ff02a0e459..25e7533b5c 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/markers.rs
diff --git a/library/map/src/main/rust/src/bridge/markers.rs b/library/map/src/main/rust/src/bridge/markers.rsindex 4d13eaa158..e71b1a9e87 100644--- a/library/map/src/main/rust/src/bridge/markers.rs+++ b/library/map/src/main/rust/src/bridge/markers.rs@@ -62,6 +62,9 @@ pub extern "system" fn Java_com_vayunmathur_library_map_MapNative_setMarkers<'l>             lon: coord_buf[i * 2] as f64,             lat: coord_buf[i * 2 + 1] as f64,             icon: icon_buf[i] as u32,+            // App pins carry no route colour; vehicles arrive through+            // `setVehicles`, which has its own colours array.+            colour: 0,         })         .collect();     map.renderer.set_markers(markers);@@ -85,7 +88,10 @@ pub extern "system" fn Java_com_vayunmathur_library_map_MapNative_clearMarkers<' /// [`setMarkers`](Java_com_vayunmathur_library_map_MapNative_setMarkers) — `ids[i]` the host's /// stable per-trip id, `lonLat` the flat `[lon0, lat0, lon1, lat1, …]`, and `icons[i]` the mode /// sprite id (a vehicle uses the `VEHICLE_*` ids in `crate::marker::icon`) — because a vehicle is-/// just a [`Marker`] whose icon names a mode sprite, so it reuses the marker draw path verbatim.+/// just a [`Marker`] whose icon names a mode sprite, so it reuses the marker draw path verbatim —+/// plus a fourth, `colors[i]`, the GTFS `route_color` packed as `0xRRGGBB` (`0` when the pack+/// carries none). A nonzero colour draws a route-coloured ring under the sprite so the vehicle+/// reads in its line's colour; without it the icon is only its mode glyph. /// /// Separate from [`setMarkers`](Java_com_vayunmathur_library_map_MapNative_setMarkers) so the app's /// ~1 Hz vehicle recompute replaces only the vehicles, leaving the pins (which change on a tap or@@ -102,12 +108,15 @@ pub extern "system" fn Java_com_vayunmathur_library_map_MapNative_setVehicles<'l     ids: JLongArray<'l>,     lon_lat: JFloatArray<'l>,     icons: JIntArray<'l>,+    colors: JIntArray<'l>, ) {     let Some(map) = handle_mut(handle) else { return };     let id_len = env.get_array_length(&ids).unwrap_or(0).max(0) as usize;     let icon_len = env.get_array_length(&icons).unwrap_or(0).max(0) as usize;     let coord_len = env.get_array_length(&lon_lat).unwrap_or(0).max(0) as usize;+    let color_len = env.get_array_length(&colors).unwrap_or(0).max(0) as usize;     // Each vehicle consumes two floats (lon, lat), so the coordinate array bounds the count too.+    // Colours ride along when present; a short/empty array means "no rings" rather than a failure.     let n = id_len.min(icon_len).min(coord_len / 2);     if n == 0 {         map.renderer.set_vehicles(Vec::new());@@ -116,9 +125,12 @@ pub extern "system" fn Java_com_vayunmathur_library_map_MapNative_setVehicles<'l     let mut id_buf = vec![0i64; n];     let mut icon_buf = vec![0i32; n];     let mut coord_buf = vec![0f32; n * 2];+    let mut color_buf = vec![0i32; n.min(color_len)];     if env.get_long_array_region(&ids, 0, &mut id_buf).is_err()         || env.get_int_array_region(&icons, 0, &mut icon_buf).is_err()         || env.get_float_array_region(&lon_lat, 0, &mut coord_buf).is_err()+        || (!color_buf.is_empty()+            && env.get_int_array_region(&colors, 0, &mut color_buf).is_err())     {         log("the vehicle arrays could not be read; leaving the vehicles unchanged");         return;@@ -129,6 +141,7 @@ pub extern "system" fn Java_com_vayunmathur_library_map_MapNative_setVehicles<'l             lon: coord_buf[i * 2] as f64,             lat: coord_buf[i * 2 + 1] as f64,             icon: icon_buf[i] as u32,+            colour: color_buf.get(i).copied().unwrap_or(0) as u32 & 0x00FF_FFFF,         })         .collect();     map.renderer.set_vehicles(vehicles);
library/map/src/main/rust/src/marker.rs
diff --git a/library/map/src/main/rust/src/marker.rs b/library/map/src/main/rust/src/marker.rsindex 0941c863d3..cc2906e493 100644--- a/library/map/src/main/rust/src/marker.rs+++ b/library/map/src/main/rust/src/marker.rs@@ -24,7 +24,8 @@ //! **name** here, and a name the sheet does not carry simply draws nothing, exactly as a POI with //! no icon does ([`crate::tile::sprite::SpriteAtlas::get`]). -/// One marker: a stable id for picking, a ground position, and which atlas icon to draw.+/// One marker: a stable id for picking, a ground position, which atlas icon+/// to draw, and an optional route-colour ring. /// /// [`id`](Self::id) is the app's own stable feature id (a pin's parking/search/saved id, or a /// vehicle's trip id), returned verbatim by the id-buffer pick so the host can rejoin the tap to@@ -39,6 +40,11 @@ pub struct Marker {     pub lat: f64,     /// Which atlas icon to draw — see [`icon`] and [`icon_sprite_name`].     pub icon: u32,+    /// Route colour (`0xRRGGBB`) for the ring drawn under a vehicle sprite so+    /// the icon reads in its line's colour; `0` draws no ring. Carried only on+    /// the vehicles path today (app pins pass `0`) — see+    /// [`crate::vulkan::renderer`] vehicle rings.+    pub colour: u32, }  /// The screen size a marker icon is drawn at, in Dp.@@ -84,7 +90,14 @@ pub mod icon { /// which have no dedicated *pin* pictograms, so the pin ids map to the closest existing sprite so a /// marker is visible today rather than blank. A follow-up build-side asset pass can add dedicated /// `pin-*` sprites and repoint these names with no code change beyond this table — the JNI ids stay-/// the same. The vehicle ids already resolve to real transit sprites, so WS-F needs no new art.+/// the same.+///+/// # Vehicle art+///+/// The vehicle ids resolve to dedicated `vehicle-*` sprites: solid transport-blue badges with+/// white Maki glyphs, built by `analysis/spritepack/pack.py` alongside the `fuel`/`hotel`/`bank`+/// POI additions. Solid rather than the pale POI badge on purpose — vehicles dwell exactly on+/// stops, and pale badges read as duplicated station POIs (seen on-device 2026-09-14). pub fn icon_sprite_name(icon: u32) -> Option<&'static str> {     let name = match icon {         // Pins — provisional mappings onto existing POI sprites (see the doc above).@@ -93,11 +106,11 @@ pub fn icon_sprite_name(icon: u32) -> Option<&'static str> {         icon::SEARCH => "attraction",         icon::SAVED => "artwork",         icon::FAMILY => "attraction",-        // Vehicles (WS-F) — real transit sprites already in the sheet.-        icon::VEHICLE_BUS => "bus_stop",-        icon::VEHICLE_TRAM => "train_station",-        icon::VEHICLE_TRAIN => "train_station",-        icon::VEHICLE_FERRY => "ferry_terminal",+        // Vehicles (WS-F) — dedicated solid-badge sprites, not POI icons.+        icon::VEHICLE_BUS => "vehicle-bus",+        icon::VEHICLE_TRAM => "vehicle-tram",+        icon::VEHICLE_TRAIN => "vehicle-train",+        icon::VEHICLE_FERRY => "vehicle-ferry",         _ => return None,     };     Some(name)@@ -137,14 +150,15 @@ mod tests {         assert!(icon_sprite_name(u32::MAX).is_none());     } -    /// The vehicle ids WS-F builds on are the reserved 5–8 and resolve to transit sprites, so the-    /// bulk vehicle case needs no new art. Pins them so a renumbering that collided with a pin id-    /// is caught here.+    /// The vehicle ids WS-F builds on are the reserved 5-8 and resolve to the+    /// dedicated solid-badge `vehicle-*` sprites (not the ambient POI icons,+    /// which read as duplicated stations when vehicles dwell on stops). Pins+    /// them so a renumbering that collided with a pin id is caught here.     #[test]     fn the_reserved_vehicle_ids_map_to_transit_sprites() {-        assert_eq!(icon_sprite_name(icon::VEHICLE_BUS), Some("bus_stop"));-        assert_eq!(icon_sprite_name(icon::VEHICLE_TRAM), Some("train_station"));-        assert_eq!(icon_sprite_name(icon::VEHICLE_TRAIN), Some("train_station"));-        assert_eq!(icon_sprite_name(icon::VEHICLE_FERRY), Some("ferry_terminal"));+        assert_eq!(icon_sprite_name(icon::VEHICLE_BUS), Some("vehicle-bus"));+        assert_eq!(icon_sprite_name(icon::VEHICLE_TRAM), Some("vehicle-tram"));+        assert_eq!(icon_sprite_name(icon::VEHICLE_TRAIN), Some("vehicle-train"));+        assert_eq!(icon_sprite_name(icon::VEHICLE_FERRY), Some("vehicle-ferry"));     } }
library/map/src/main/rust/src/vulkan/renderer/mod.rs
diff --git a/library/map/src/main/rust/src/vulkan/renderer/mod.rs b/library/map/src/main/rust/src/vulkan/renderer/mod.rsindex bbe09c26a6..6d89481e30 100644--- a/library/map/src/main/rust/src/vulkan/renderer/mod.rs+++ b/library/map/src/main/rust/src/vulkan/renderer/mod.rs@@ -337,6 +337,13 @@ const PUCK_CONE_HALF_STROKE_DP: f32 = 4.0; /// so a quad any tighter would clip the falloff. const PUCK_QUAD_DP: f32 = 28.0; +/// A simulated vehicle's route-colour ring: the disc radius in Dp, and the quad+/// half-extent that holds it. The disc is wider than the 28 Dp vehicle sprite+/// (half 14) so its edge reads as an outline in the line's colour around the+/// mode glyph; the sprite draws over the disc's middle on top of it.+const VEHICLE_RING_DP: f32 = 16.5;+const VEHICLE_RING_QUAD_DP: f32 = 19.0;+ /// The turn-arrow glyph: its screen size in Dp (the unit arrow spans roughly `-1..1`, so this is a /// touch under its half-extent), and its colour. A muted near-white so the arrows read on the dark /// carriageway without competing with the route line's saturated blue.
library/map/src/main/rust/src/vulkan/renderer/record_extra2.rs
diff --git a/library/map/src/main/rust/src/vulkan/renderer/record_extra2.rs b/library/map/src/main/rust/src/vulkan/renderer/record_extra2.rsindex 3de97ab646..792d4242ba 100644--- a/library/map/src/main/rust/src/vulkan/renderer/record_extra2.rs+++ b/library/map/src/main/rust/src/vulkan/renderer/record_extra2.rs@@ -1,7 +1,8 @@ use super::{     ARROW_COLOR, ARROW_DP, BUILDINGS_DRAW_MIN_ZOOM, IDENTITY, Overlay, PUCK_COLOR, PUCK_CONE_DP,     PUCK_CONE_HALF_STROKE_DP, PUCK_DOT_DP, PUCK_QUAD_DP, PUCK_RIM_DP, QUAD_INDICES, Renderer,-    SCRIM_COLOR, TRAFFIC_WIDTH_DP, UserPuck, anchors_for, argb_to_rgba, scale_alpha,+    SCRIM_COLOR, TRAFFIC_WIDTH_DP, UserPuck, VEHICLE_RING_DP, VEHICLE_RING_QUAD_DP, anchors_for,+    argb_to_rgba, scale_alpha, }; use crate::camera::Camera; use crate::marker::{Marker, MARKER_SIZE_DP};@@ -295,6 +296,11 @@ impl Renderer {         // user placed and can tap outranks a simulated vehicle sprite at the same spot, and the         // user's own location outranks both. Both go through the shared billboarded sprite path.         if !vehicles.is_empty() {+            // Route-colour rings under the sprites that carry a colour, so a+            // vehicle reads in its line's colour: a dot-only pass on the puck+            // pipeline (no cone, no white rim), sized just past the 28 Dp+            // sprite, drawn before the sprites so they cover its middle.+            self.draw_vehicle_rings(command_buffer, camera, &vehicles, submitted);             self.draw_markers(command_buffer, camera, palette, &vehicles, submitted);         }         if !markers.is_empty() {
library/map/src/main/rust/src/vulkan/renderer/record_extra3.rs
diff --git a/library/map/src/main/rust/src/vulkan/renderer/record_extra3.rs b/library/map/src/main/rust/src/vulkan/renderer/record_extra3.rsindex 1077a8f4ec..fe1a1cf51c 100644--- a/library/map/src/main/rust/src/vulkan/renderer/record_extra3.rs+++ b/library/map/src/main/rust/src/vulkan/renderer/record_extra3.rs@@ -1,7 +1,8 @@ use super::{     ARROW_COLOR, ARROW_DP, BUILDINGS_DRAW_MIN_ZOOM, IDENTITY, Overlay, PUCK_COLOR, PUCK_CONE_DP,     PUCK_CONE_HALF_STROKE_DP, PUCK_DOT_DP, PUCK_QUAD_DP, PUCK_RIM_DP, QUAD_INDICES, Renderer,-    SCRIM_COLOR, TRAFFIC_WIDTH_DP, UserPuck, anchors_for, argb_to_rgba, scale_alpha,+    SCRIM_COLOR, TRAFFIC_WIDTH_DP, UserPuck, VEHICLE_RING_DP, VEHICLE_RING_QUAD_DP, anchors_for,+    argb_to_rgba, scale_alpha, }; use crate::camera::Camera; use crate::marker::{Marker, MARKER_SIZE_DP};@@ -112,6 +113,67 @@ impl Renderer {         );     } +    /// Draw the route-colour rings under coloured vehicles, so each reads in+    /// its line's colour.+    ///+    /// A dot-only pass on the puck pipeline (no cone, no white rim): one disc+    /// per vehicle with a nonzero [`Marker::colour`], sized just past the+    /// 28 Dp sprite, drawn before the sprites so they cover its middle and+    /// only the edge shows as an outline. The pipeline is bound once and each+    /// vehicle is one push-constant draw — the visible set is bounded by the+    /// host's bbox/zoom gate, so this stays a handful of draws per frame.+    /// Vehicles with colour `0` (the pack carries no `route_color`) and ones+    /// the tilt puts behind the eye draw nothing.+    pub(super) unsafe fn draw_vehicle_rings(+        &mut self,+        command_buffer: vk::CommandBuffer,+        camera: &Camera,+        vehicles: &[Marker],+        submitted: &mut usize,+    ) {+        let density = camera.density;+        let device = &self.context.device;+        device.cmd_bind_pipeline(+            command_buffer,+            vk::PipelineBindPoint::GRAPHICS,+            self.pipelines.puck,+        );+        device.cmd_bind_vertex_buffers(command_buffer, 0, &[self.quad.vertices.buffer], &[0]);+        device.cmd_bind_index_buffer(+            command_buffer,+            self.quad.indices.buffer,+            0,+            vk::IndexType::UINT32,+        );+        for v in vehicles {+            if v.colour == 0 {+                continue;+            }+            let m = camera.screen_quad_to_clip(v.lon, v.lat, VEHICLE_RING_QUAD_DP as f64);+            if m[15] <= 0.0 {+                continue; // behind the eye / above the horizon under tilt.+            }+            let push = Push {+                tile_to_clip: m,+                color: argb_to_rgba(0xFF00_0000 | v.colour),+                // Dot only: rim 0 hides the white ring, cone sizes 0 and+                // misc.y 0 hide the bearing cone.+                line: [0.0, VEHICLE_RING_DP * density, 0.0, 0.0],+                misc: [0.0, 0.0, VEHICLE_RING_QUAD_DP * density, camera.time_seconds],+                morph: MORPH_NONE,+            };+            device.cmd_push_constants(+                command_buffer,+                self.pipelines.layout,+                vk::ShaderStageFlags::VERTEX | vk::ShaderStageFlags::FRAGMENT,+                0,+                push.as_bytes(),+            );+            device.cmd_draw_indexed(command_buffer, QUAD_INDICES.len() as u32, 1, 0, 0, 0);+            *submitted += 1;+        }+    }+     /// Draw one tile's one symbol layer: emit its shaped labels at the frame's     /// text size, upload a transient buffer pair, and draw it with the symbol     /// pipeline bound to the glyph atlas set.
maps/src/main/java/com/vayunmathur/maps/ui/LayersSheet.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/LayersSheet.kt b/maps/src/main/java/com/vayunmathur/maps/ui/LayersSheet.ktindex 4cf024d9a2..081729c883 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/LayersSheet.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/LayersSheet.kt@@ -71,11 +71,10 @@ fun LayersSheet(                 )             } -            // Transit — offline rail lines from the on-device pack, and a+            // Transit — offline rail lines from the on-device pack, live vehicle+            // pictograms (dedicated solid-badge sprites, not POI icons) and a             // departure board for the stop nearest a tap. Stop pins-            // themselves are a tracked renderer gap ([TransitStopsLayer]);-            // vehicle sprites stay off until the atlas carries dedicated-            // vehicle art (VEHICLE_SPRITES_ENABLED).+            // themselves are a tracked renderer gap ([TransitStopsLayer]).             SettingsSwitchRow(                 title = stringResource(R.string.layer_transit),                 supportingText = stringResource(R.string.layer_transit_desc),
maps/src/main/java/com/vayunmathur/maps/ui/map/TransitVehicles.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/map/TransitVehicles.kt b/maps/src/main/java/com/vayunmathur/maps/ui/map/TransitVehicles.ktindex 0933c34a3a..df38ccd1f3 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/map/TransitVehicles.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/map/TransitVehicles.kt@@ -40,17 +40,14 @@ private const val VEHICLE_TICK_MS = 1_000L private const val VEHICLE_MIN_ZOOM = 11.0  /**- * Whether the simulated vehicle sprites draw at all. Currently false: the- * sprite atlas has no dedicated vehicle pictograms, so the vehicle ids borrow- * the ambient POI icons (`VEHICLE_BUS` draws the bus-stop pin,- * `VEHICLE_TRAM/TRAIN` the train-station pin) at 28 Dp against 19 Dp POIs- * with no labels. Vehicles dwell exactly on stops, so several trips at one- * station read as duplicated, misaligned, textless station POIs - which is- * what the transit toggle showed. Rail lines, departure boards and routing- * are unaffected (separate paths); flip this back on when dedicated vehicle- * sprites land in the atlas (see `marker::icon_sprite_name`).+ * Whether the simulated vehicle sprites draw at all. True: the sprite atlas+ * carries dedicated solid-badge vehicle pictograms (`vehicle-bus/tram/train/+ * ferry`, white Maki glyphs on transport blue — built by+ * `analysis/spritepack/pack.py`), visually distinct from the pale ambient POI+ * badges so a vehicle dwelling on a stop no longer reads as a duplicated+ * station POI. Was false while the vehicle ids borrowed POI icons.  */-private const val VEHICLE_SPRITES_ENABLED = false+private const val VEHICLE_SPRITES_ENABLED = true  /**  * How far the bbox centre may drift (degrees) before a recompute is forced.@@ -147,6 +144,10 @@ fun rememberTransitVehicles(                             id = v.id,                             position = GeoPoint(longitude = v.lon, latitude = v.lat),                             icon = gtfsModeToMarkerIcon(v.mode),+                            // The pack's GTFS route_color drives the ring under the+                            // sprite so the vehicle reads in its line's colour; 0+                            // (no colour in the pack) draws no ring.+                            color = v.colour,                         )                     }                 }
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 b347eb83aa..62778a10e6 100644--- a/maps/src/main/res/values/strings.xml+++ b/maps/src/main/res/values/strings.xml@@ -327,8 +327,8 @@     <string name="layer_safety_unavailable">Coming soon</string>     <!-- LayersSheet: public-transit layer toggle. Noun. -->     <string name="layer_transit">Transit</string>-    <!-- LayersSheet: transit layer description. Rail lines the basemap renderer draws plus the departure board for the stop nearest a tap; stop pins are a tracked renderer gap (TransitStopsLayer is a no-op) and vehicle sprites are off until the atlas carries dedicated vehicle art. -->-    <string name="layer_transit_desc">Show rail lines and departures</string>+    <!-- LayersSheet: transit layer description. Rail lines the basemap renderer draws, live vehicle pictograms and the departure board for the stop nearest a tap; stop pins are a tracked renderer gap (TransitStopsLayer is a no-op). -->+    <string name="layer_transit_desc">Show rail lines, live vehicles and departures</string>      <!-- Departure board: section subtitle under the stop name. Noun. -->     <string name="transit_departures_title">Departures</string>