[traffic] Properly process message replacement

Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
mvglasow
2025-10-12 16:39:39 +03:00
parent d098ecae15
commit 2ed9bc1880
2 changed files with 38 additions and 17 deletions

View File

@@ -639,6 +639,13 @@ void TrafficManager::DecodeFirstMessage()
// store message in cache // store message in cache
m_messageCache.insert_or_assign(message.m_id, message); 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: * TODO detect if we can do a quick update:

View File

@@ -210,8 +210,14 @@ void TraffDecoder::DecodeMessage(traffxml::TraffMessage & message)
return; return;
traffxml::MultiMwmColoring decoded; 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()) if ((it != m_messageCache.end())
&& !it->second.m_decoded.empty() && !it->second.m_decoded.empty()
&& (it->second.m_location == message.m_location)) && (it->second.m_location == message.m_location))
@@ -229,10 +235,18 @@ void TraffDecoder::DecodeMessage(traffxml::TraffMessage & message)
message.m_decoded = it->second.m_decoded; message.m_decoded = it->second.m_decoded;
return; 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; decoded = it->second.m_decoded;
isDecoded = true;
} }
else }
}
if (!isDecoded)
DecodeLocation(message, decoded); DecodeLocation(message, decoded);
if (impact) if (impact)