mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:20:06 +00:00
County display for alerts, alert cleanup
This commit is contained in:
parent
305e5c3698
commit
c87a77795d
5 changed files with 27 additions and 5 deletions
|
|
@ -25,11 +25,17 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||||
|
|
||||||
static const std::string countyDatabaseFilename_ = ":/res/db/counties.db";
|
static const std::string countyDatabaseFilename_ = ":/res/db/counties.db";
|
||||||
|
|
||||||
|
static bool initialized_ {false};
|
||||||
static std::unordered_map<std::string, std::string> countyMap_;
|
static std::unordered_map<std::string, std::string> countyMap_;
|
||||||
static std::shared_mutex countyMutex_;
|
static std::shared_mutex countyMutex_;
|
||||||
|
|
||||||
void CountyDatabase::Initialize()
|
void CountyDatabase::Initialize()
|
||||||
{
|
{
|
||||||
|
if (initialized_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
logger_->debug("Loading database");
|
logger_->debug("Loading database");
|
||||||
|
|
||||||
// Generate UUID for temporary file
|
// Generate UUID for temporary file
|
||||||
|
|
@ -124,6 +130,8 @@ void CountyDatabase::Initialize()
|
||||||
|
|
||||||
// Remove temporary file
|
// Remove temporary file
|
||||||
std::filesystem::remove(countyDatabaseCache);
|
std::filesystem::remove(countyDatabaseCache);
|
||||||
|
|
||||||
|
initialized_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetCountyName(const std::string& id)
|
std::string GetCountyName(const std::string& id)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <scwx/qt/manager/resource_manager.hpp>
|
#include <scwx/qt/manager/resource_manager.hpp>
|
||||||
|
#include <scwx/qt/config/county_database.hpp>
|
||||||
#include <scwx/qt/util/font.hpp>
|
#include <scwx/qt/util/font.hpp>
|
||||||
#include <scwx/qt/util/texture_atlas.hpp>
|
#include <scwx/qt/util/texture_atlas.hpp>
|
||||||
|
|
||||||
|
|
@ -19,6 +20,8 @@ void PreLoad()
|
||||||
|
|
||||||
static void LoadFonts()
|
static void LoadFonts()
|
||||||
{
|
{
|
||||||
|
config::CountyDatabase::Initialize();
|
||||||
|
|
||||||
util::Font::Create(":/res/fonts/din1451alt.ttf");
|
util::Font::Create(":/res/fonts/din1451alt.ttf");
|
||||||
util::Font::Create(":/res/fonts/din1451alt_g.ttf");
|
util::Font::Create(":/res/fonts/din1451alt_g.ttf");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public:
|
||||||
TextEventManager* self_;
|
TextEventManager* self_;
|
||||||
|
|
||||||
std::unordered_map<types::TextEventKey,
|
std::unordered_map<types::TextEventKey,
|
||||||
std::list<std::shared_ptr<awips::TextProductMessage>>,
|
std::vector<std::shared_ptr<awips::TextProductMessage>>,
|
||||||
types::TextEventHash<types::TextEventKey>>
|
types::TextEventHash<types::TextEventKey>>
|
||||||
textEventMap_;
|
textEventMap_;
|
||||||
std::shared_mutex textEventMutex_;
|
std::shared_mutex textEventMutex_;
|
||||||
|
|
@ -131,7 +131,7 @@ void TextEventManager::Impl::HandleMessage(
|
||||||
if (it == textEventMap_.cend())
|
if (it == textEventMap_.cend())
|
||||||
{
|
{
|
||||||
// If there was no matching event, add the message to a new event
|
// If there was no matching event, add the message to a new event
|
||||||
textEventMap_.emplace(key, std::list {message});
|
textEventMap_.emplace(key, std::vector {message});
|
||||||
messageIndex = 0;
|
messageIndex = 0;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ static QString GetSuffix(awips::Phenomenon phenomenon, bool alertActive);
|
||||||
static const QVariantMap kEmptyFeatureCollection_ {
|
static const QVariantMap kEmptyFeatureCollection_ {
|
||||||
{"type", "geojson"},
|
{"type", "geojson"},
|
||||||
{"data", QVariant::fromValue(std::list<QMapLibreGL::Feature> {})}};
|
{"data", QVariant::fromValue(std::list<QMapLibreGL::Feature> {})}};
|
||||||
static const std::list<awips::Phenomenon> kAlertPhenomena_ {
|
static const std::vector<awips::Phenomenon> kAlertPhenomena_ {
|
||||||
awips::Phenomenon::Marine,
|
awips::Phenomenon::Marine,
|
||||||
awips::Phenomenon::FlashFlood,
|
awips::Phenomenon::FlashFlood,
|
||||||
awips::Phenomenon::SevereThunderstorm,
|
awips::Phenomenon::SevereThunderstorm,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <scwx/qt/model/alert_model.hpp>
|
#include <scwx/qt/model/alert_model.hpp>
|
||||||
|
#include <scwx/qt/config/county_database.hpp>
|
||||||
#include <scwx/qt/manager/text_event_manager.hpp>
|
#include <scwx/qt/manager/text_event_manager.hpp>
|
||||||
#include <scwx/qt/types/qt_types.hpp>
|
#include <scwx/qt/types/qt_types.hpp>
|
||||||
#include <scwx/common/geographic.hpp>
|
#include <scwx/common/geographic.hpp>
|
||||||
|
|
@ -174,7 +175,7 @@ AlertModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
case kColumnState:
|
case kColumnState:
|
||||||
return tr("State");
|
return tr("State");
|
||||||
case kColumnCounties:
|
case kColumnCounties:
|
||||||
return tr("Counties");
|
return tr("Counties / Areas");
|
||||||
case kColumnStartTime:
|
case kColumnStartTime:
|
||||||
return tr("Start Time");
|
return tr("Start Time");
|
||||||
case kColumnEndTime:
|
case kColumnEndTime:
|
||||||
|
|
@ -287,7 +288,17 @@ std::string AlertModelImpl::GetCounties(const types::TextEventKey& key)
|
||||||
auto& lastMessage = messageList.back();
|
auto& lastMessage = messageList.back();
|
||||||
size_t segmentCount = lastMessage->segment_count();
|
size_t segmentCount = lastMessage->segment_count();
|
||||||
auto lastSegment = lastMessage->segment(segmentCount - 1);
|
auto lastSegment = lastMessage->segment(segmentCount - 1);
|
||||||
return util::ToString(lastSegment->header_->ugc_.fips_ids());
|
auto fipsIds = lastSegment->header_->ugc_.fips_ids();
|
||||||
|
|
||||||
|
std::vector<std::string> counties;
|
||||||
|
counties.reserve(fipsIds.size());
|
||||||
|
for (auto& id : fipsIds)
|
||||||
|
{
|
||||||
|
counties.push_back(config::CountyDatabase::GetCountyName(id));
|
||||||
|
}
|
||||||
|
std::sort(counties.begin(), counties.end());
|
||||||
|
|
||||||
|
return util::ToString(counties);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AlertModelImpl::GetState(const types::TextEventKey& key)
|
std::string AlertModelImpl::GetState(const types::TextEventKey& key)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue