Merge pull request #386 from AdenKoperczak/color_palette_fallback_warning

Color palette fallback
This commit is contained in:
Dan Paulat 2025-03-01 23:25:37 -06:00 committed by GitHub
commit d5dadb5175
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1865,34 +1865,49 @@ void MapWidgetImpl::RadarProductManagerDisconnect()
void MapWidgetImpl::InitializeNewRadarProductView( void MapWidgetImpl::InitializeNewRadarProductView(
const std::string& colorPalette) const std::string& colorPalette)
{ {
boost::asio::post(threadPool_, boost::asio::post(
[=, this]() threadPool_,
{ [colorPalette, this]()
try {
{ try
auto radarProductView = {
context_->radar_product_view(); auto radarProductView = context_->radar_product_view();
std::string colorTableFile = auto& paletteSetting =
settings::PaletteSettings::Instance() settings::PaletteSettings::Instance().palette(colorPalette);
.palette(colorPalette)
.GetValue();
if (!colorTableFile.empty())
{
std::unique_ptr<std::istream> colorTableStream =
util::OpenFile(colorTableFile);
std::shared_ptr<common::ColorTable> colorTable =
common::ColorTable::Load(*colorTableStream);
radarProductView->LoadColorTable(colorTable);
}
radarProductView->Initialize(); std::string colorTableFile = paletteSetting.GetValue();
} if (colorTableFile.empty())
catch (const std::exception& ex) {
{ colorTableFile = paletteSetting.GetDefault();
logger_->error(ex.what()); }
}
}); std::unique_ptr<std::istream> colorTableStream =
util::OpenFile(colorTableFile);
if (colorTableStream->fail())
{
logger_->warn("Could not open color table {}", colorTableFile);
colorTableStream = util::OpenFile(paletteSetting.GetDefault());
}
std::shared_ptr<common::ColorTable> colorTable =
common::ColorTable::Load(*colorTableStream);
if (!colorTable->IsValid())
{
logger_->warn("Could not load color table {}", colorTableFile);
colorTableStream = util::OpenFile(paletteSetting.GetDefault());
colorTable = common::ColorTable::Load(*colorTableStream);
}
radarProductView->LoadColorTable(colorTable);
radarProductView->Initialize();
}
catch (const std::exception& ex)
{
logger_->error(ex.what());
}
});
if (map_ != nullptr) if (map_ != nullptr)
{ {