diff --git a/map/traffic_manager.cpp b/map/traffic_manager.cpp index eabbdfbbc..d6ba95c05 100644 --- a/map/traffic_manager.cpp +++ b/map/traffic_manager.cpp @@ -404,8 +404,7 @@ void TrafficManager::InitializeDataSources(std::vector & dataS * If we batch-decode segments, we need to fix the [partner] segment IDs in the segment and path * structures to accept a TraFF message ID (string) rather than an integer. */ -void TrafficManager::DecodeMessage(traffxml::TraffMessage & message, std::map & trafficCache) +void TrafficManager::DecodeMessage(traffxml::TraffMessage & message) { if (message.m_location) { @@ -503,7 +502,7 @@ void TrafficManager::DecodeMessage(traffxml::TraffMessage & message, std::mapsecond.find(rsid) ; c_it != target_it->second.end()) + { + // if delta overrules target (target is Unknown, delta is TempBlock or delta is slower than target) + if ((sg == traffic::SpeedGroup::TempBlock) + || (c_it->second == traffic::SpeedGroup::Unknown) || (sg < c_it->second)) + target_it->second[rsid] = sg; + } + else + // if target[mwm] does not contain segment, add speed group + target_it->second[rsid] = sg; + else + // if target does not contain mwm, add coloring + target[mwmId] = coloring; +} + /* string DebugPrint(LinearSegmentSource source) { diff --git a/traffxml/traff_model.hpp b/traffxml/traff_model.hpp index 3e8fd539f..436f99966 100644 --- a/traffxml/traff_model.hpp +++ b/traffxml/traff_model.hpp @@ -5,10 +5,14 @@ #include "geometry/latlon.hpp" #include "geometry/point2d.hpp" +#include "indexer/mwm_set.hpp" + #include "openlr/openlr_model.hpp" #include "traffic/speed_groups.hpp" +#include "traffic/traffic_info.hpp" +#include #include #include @@ -271,6 +275,11 @@ struct TraffEvent // TODO supplementary information }; +/** + * @brief Global mapping from feature segments to speed groups, across all MWMs. + */ +using MultiMwmColoring = std::map>; + struct TraffMessage { /** @@ -299,6 +308,7 @@ struct TraffMessage std::optional m_location; std::vector m_events; std::vector m_replaces; + MultiMwmColoring m_decoded; }; using TraffFeed = std::vector; @@ -317,6 +327,21 @@ using TraffFeed = std::vector; */ uint32_t GuessDnp(openlr::LocationReferencePoint & p1, openlr::LocationReferencePoint & p2); +/** + * @brief Merges the contents of one `MultiMwmColoring` into another. + * + * After this function returns, `target` will hold the union of the entries it had prior to the + * function call and the entries from `delta`. + * + * In case of conflict, the more restrictive speed group wins. That is, `TempBlock` overrides + * everything else, `Unknown` never overrides anything else, and among `G0` to `G5`, the lowest + * group wins. + * + * @param delta Contains the entries to be added. + * @param target Receives the added entries. + */ +void MergeMultiMwmColoring(MultiMwmColoring &delta, MultiMwmColoring & target); + std::string DebugPrint(IsoTime time); std::string DebugPrint(Directionality directionality); std::string DebugPrint(Ramps ramps);