Add tornado observed to alert dock

This commit is contained in:
Dan Paulat 2024-06-28 23:24:31 -05:00
parent f0347da923
commit c80b26be22
2 changed files with 39 additions and 15 deletions

View file

@ -34,6 +34,7 @@ public:
explicit AlertModelImpl(); explicit AlertModelImpl();
~AlertModelImpl() = default; ~AlertModelImpl() = default;
bool GetObserved(const types::TextEventKey& key);
awips::ThreatCategory GetThreatCategory(const types::TextEventKey& key); awips::ThreatCategory GetThreatCategory(const types::TextEventKey& key);
bool GetTornadoPossible(const types::TextEventKey& key); bool GetTornadoPossible(const types::TextEventKey& key);
@ -52,6 +53,10 @@ public:
const GeographicLib::Geodesic& geodesic_; const GeographicLib::Geodesic& geodesic_;
std::unordered_map<types::TextEventKey,
bool,
types::TextEventHash<types::TextEventKey>>
observedMap_;
std::unordered_map<types::TextEventKey, std::unordered_map<types::TextEventKey,
awips::ThreatCategory, awips::ThreatCategory,
types::TextEventHash<types::TextEventKey>> types::TextEventHash<types::TextEventKey>>
@ -136,7 +141,12 @@ QVariant AlertModel::data(const QModelIndex& index, int role) const
return QString::fromStdString( return QString::fromStdString(
awips::GetSignificanceText(textEventKey.significance_)); awips::GetSignificanceText(textEventKey.significance_));
case static_cast<int>(Column::TornadoPossible): case static_cast<int>(Column::Tornado):
if (textEventKey.phenomenon_ == awips::Phenomenon::Tornado &&
p->GetObserved(textEventKey))
{
return tr("Observed");
}
if (p->GetTornadoPossible(textEventKey)) if (p->GetTornadoPossible(textEventKey))
{ {
return tr("Possible"); return tr("Possible");
@ -236,7 +246,7 @@ AlertModel::headerData(int section, Qt::Orientation orientation, int role) const
case static_cast<int>(Column::ThreatCategory): case static_cast<int>(Column::ThreatCategory):
return tr("Category"); return tr("Category");
case static_cast<int>(Column::TornadoPossible): case static_cast<int>(Column::Tornado):
return tr("Tornado"); return tr("Tornado");
case static_cast<int>(Column::State): case static_cast<int>(Column::State):
@ -279,8 +289,8 @@ AlertModel::headerData(int section, Qt::Orientation orientation, int role) const
contentsSize = fontMetrics.size(0, QString(6, 'W')); contentsSize = fontMetrics.size(0, QString(6, 'W'));
break; break;
case static_cast<int>(Column::TornadoPossible): case static_cast<int>(Column::Tornado):
contentsSize = fontMetrics.size(0, QString(4, 'W')); contentsSize = fontMetrics.size(0, QString(5, 'W'));
break; break;
case static_cast<int>(Column::State): case static_cast<int>(Column::State):
@ -328,6 +338,7 @@ void AlertModel::HandleAlert(const types::TextEventKey& alertKey,
std::shared_ptr<const awips::Segment> alertSegment = std::shared_ptr<const awips::Segment> alertSegment =
alertMessages[messageIndex]->segments().back(); alertMessages[messageIndex]->segments().back();
p->observedMap_.insert_or_assign(alertKey, alertSegment->observed_);
p->threatCategoryMap_.insert_or_assign(alertKey, p->threatCategoryMap_.insert_or_assign(alertKey,
alertSegment->threatCategory_); alertSegment->threatCategory_);
p->tornadoPossibleMap_.insert_or_assign(alertKey, p->tornadoPossibleMap_.insert_or_assign(alertKey,
@ -413,6 +424,19 @@ AlertModelImpl::AlertModelImpl() :
{ {
} }
bool AlertModelImpl::GetObserved(const types::TextEventKey& key)
{
bool observed = false;
auto it = observedMap_.find(key);
if (it != observedMap_.cend())
{
observed = it->second;
}
return observed;
}
awips::ThreatCategory awips::ThreatCategory
AlertModelImpl::GetThreatCategory(const types::TextEventKey& key) AlertModelImpl::GetThreatCategory(const types::TextEventKey& key)
{ {

View file

@ -26,7 +26,7 @@ public:
Phenomenon = 2, Phenomenon = 2,
Significance = 3, Significance = 3,
ThreatCategory = 4, ThreatCategory = 4,
TornadoPossible = 5, Tornado = 5,
State = 6, State = 6,
Counties = 7, Counties = 7,
StartTime = 8, StartTime = 8,