Don't add an alert segment twice

This commit is contained in:
Dan Paulat 2024-07-14 00:23:23 -05:00
parent 6097b47b7a
commit 09cdb03699

View file

@ -367,13 +367,30 @@ void AlertLayer::Impl::AddAlert(
// Take a mutex before modifying lines by segment // Take a mutex before modifying lines by segment
std::unique_lock lock {linesMutex_}; std::unique_lock lock {linesMutex_};
boost::container::stable_vector<std::shared_ptr<gl::draw::GeoLineDrawItem>>& // Add draw items only if the segment has not already been added
drawItems = linesBySegment_[segmentRecord]; auto drawItems = linesBySegment_.try_emplace(
segmentRecord,
boost::container::stable_vector<
std::shared_ptr<gl::draw::GeoLineDrawItem>> {});
AddLines( // If draw items were added
geoLines, coordinates, kBlack_, 5.0f, startTime, endTime, drawItems); if (drawItems.second)
AddLines( {
geoLines, coordinates, lineColor, 3.0f, startTime, endTime, drawItems); AddLines(geoLines,
coordinates,
kBlack_,
5.0f,
startTime,
endTime,
drawItems.first->second);
AddLines(geoLines,
coordinates,
lineColor,
3.0f,
startTime,
endTime,
drawItems.first->second);
}
} }
void AlertLayer::Impl::UpdateAlert( void AlertLayer::Impl::UpdateAlert(