mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 13:53:37 +00:00
[traffic] Properly process message replacement
Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
@@ -639,6 +639,13 @@ void TrafficManager::DecodeFirstMessage()
|
||||
|
||||
// store message in cache
|
||||
m_messageCache.insert_or_assign(message.m_id, message);
|
||||
|
||||
for (auto & replaced : message.m_replaces)
|
||||
{
|
||||
auto it = m_messageCache.find(replaced);
|
||||
if (it != m_messageCache.cend())
|
||||
m_messageCache.erase(it);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* TODO detect if we can do a quick update:
|
||||
|
||||
@@ -210,8 +210,14 @@ void TraffDecoder::DecodeMessage(traffxml::TraffMessage & message)
|
||||
return;
|
||||
|
||||
traffxml::MultiMwmColoring decoded;
|
||||
bool isDecoded = false;
|
||||
|
||||
auto it = m_messageCache.find(message.m_id);
|
||||
std::vector<std::string> ids = message.m_replaces;
|
||||
ids.insert(ids.begin(), message.m_id);
|
||||
|
||||
for (auto & id : ids)
|
||||
{
|
||||
auto it = m_messageCache.find(id);
|
||||
if ((it != m_messageCache.end())
|
||||
&& !it->second.m_decoded.empty()
|
||||
&& (it->second.m_location == message.m_location))
|
||||
@@ -229,10 +235,18 @@ void TraffDecoder::DecodeMessage(traffxml::TraffMessage & message)
|
||||
message.m_decoded = it->second.m_decoded;
|
||||
return;
|
||||
}
|
||||
else
|
||||
else if (!isDecoded)
|
||||
{
|
||||
/*
|
||||
* populate only on first occurrence but continue searching, we might find a matching
|
||||
* location with matching impact
|
||||
*/
|
||||
decoded = it->second.m_decoded;
|
||||
isDecoded = true;
|
||||
}
|
||||
else
|
||||
}
|
||||
}
|
||||
if (!isDecoded)
|
||||
DecodeLocation(message, decoded);
|
||||
|
||||
if (impact)
|
||||
|
||||
Reference in New Issue
Block a user