[Feedback Requested] : [RFC] Add Traffic Color Support to Route Visualization #678
Replies: 2 comments 7 replies
-
|
Some nice ideas in there. A couple of things to consider: ColorsYou define a color fallback system with hard coded colors. Developers will quickly want to change that. I suggest defining semantic colors (heavy, medium, low instead of blue, orange red) with default values, and allowing developers to override the semantic colors Error handlingYou propose tolerating malformed entries. Such an approach frequently leads to difficult debugging: a developer expects something to appear, misspelled "congestion_level", and the system accepts this but doesn't do anything. I suggest to throw an error in such cases, the developer can still decide to catch and ignore it if they would like to. At the very least, if you do want to accept malformed entries, a warning should be outputted to the console for the developer to notice. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for putting this together @radityagumay! Just a few additional things to discuss from me. I'm sure we'll have a few more questions come up as you get into implementation, but it looks like all the foundational elements are here. ColorsAlready left a comment on Patrick's suggestion. TL;DR I also favor having semantic colors as a baseline with hex as an optional override. General comment on how we can achieve the portability goalsProbably no surprise, but we can shift most of the heavy lifting to the Rust core, so we have a single implementation for arriving at the final state. I think the proposed theme object can be an
The custom variant provides a lot of flexibility, but most users probably won't actually need it (so we can actually drop this for now probably and keep it in the back of our heads to add later?). The others are pretty simple structures, which will easily work cross-platform with predictable behavior. The custom trait impls work perfectly on Android and iOS, but we don't currently expose these to TypeScript. What is the "intermediate representation"?This is squarely an implementation question, but starting the discussion anyways 😂 I don't think we currently have a cross-platform representation of a "color." But since I think MapLibre accepts most valid CSS strings, we can probably use that as the representation. I don't have a strong opinion on whether we should validate the color strings or not, but if we do, there are crates aplenty, like https://crates.io/crates/css-colors. I also like your idea of combining adjacent segments with identical colors. MapLibre shouldn't have a super hard time with this either way. So I guess the output after applying the theme would be a LineString and a CSS color. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Name: traffic_color
Type: feature
Start Date: 2025-08-21
Author: Raditya Gumay
Related components: Ferrostar Core (annotations), Routing backend, Android MapLibre UI, iOS MapLibre UI, React Native UI
Link issues: (TBD)
Summary
Traffic color is a basic feature in map/navigation apps. Ferrostar currently does not provide traffic-based route coloring out of the box. This RFC describes how to leverage OSRM-style annotations (https://project-osrm.org/docs/v5.24.0/api/#annotation-object) and the Ferrostar annotations pipeline (https://stadiamaps.github.io/ferrostar/annotations.html) to add traffic-aware coloring.
I recommend a server-driven approach that provides pre-colored per-segment annotations, while supporting client-side derivation from speed metrics when colors are not provided. A simple Blue/Orange/Red scheme is proposed, with clear thresholds and a fallback.
Motivation
Goals
Non-Goals
Functional Requirements (High Level)
Non-Functional Requirements (High Level)
Detailed design
Data model
Use OSRM-style per-segment annotations aligned with geometry (arrays of length N−1 for N coordinates). A recommended
trafficobject per segment:{ "annotation": { "traffic": [ { "congestion_level": "free_flow", "speed_kmh": 65, "typical_speed_kmh": 75, "congestion_color": "#3583dd" }, { "unknown" : true, }, { "congestion_level": "heavy", "speed_kmh": 12, "typical_speed_kmh": 20, "congestion_color": "#E74C3C" } ] } }Notes:
traffic.congestion_coloris recommended (server-specified). If absent, clients derive color from speeds (or optionally fromcongestion_level).RouteStep.annotations(length = step.geometry.size − 1).congestion_levelandtypical_speed_kmhare mandatoryspeed_kmhandtypical_speed_kmhare optional.Color scheme policy
Color selection precedence
traffic.congestion_coloris a valid hex, use it verbatim.ratio = speed_kmh / typical_speed_kmh.ratio > 0.80: Blue0.40 ≤ ratio ≤ 0.80: Orangeratio < 0.40): Redcongestion_levelPseudocode:
Rendering behavior (high level)
Error handling
Platform considerations
valuekey); clients should extract the inner payload before applying the policy.References
Beta Was this translation helpful? Give feedback.
All reactions