Add smoothing settings

This commit is contained in:
Dan Paulat 2024-12-14 22:36:25 -06:00
parent 172203ec16
commit 3e681abfdb
5 changed files with 38 additions and 7 deletions

View file

@ -27,12 +27,15 @@ static const std::string kMapStyleName_ {"map_style"};
static const std::string kRadarSiteName_ {"radar_site"}; static const std::string kRadarSiteName_ {"radar_site"};
static const std::string kRadarProductGroupName_ {"radar_product_group"}; static const std::string kRadarProductGroupName_ {"radar_product_group"};
static const std::string kRadarProductName_ {"radar_product"}; static const std::string kRadarProductName_ {"radar_product"};
static const std::string kSmoothingEnabledName_ {"smoothing_enabled"};
static const std::string kDefaultMapStyle_ {"?"}; static const std::string kDefaultMapStyle_ {"?"};
static const std::string kDefaultRadarProductGroupString_ = "L3"; static const std::string kDefaultRadarProductGroupString_ = "L3";
static const std::array<std::string, kCount_> kDefaultRadarProduct_ { static const std::array<std::string, kCount_> kDefaultRadarProduct_ {
"N0B", "N0G", "N0C", "N0X"}; "N0B", "N0G", "N0C", "N0X"};
static constexpr bool kDefaultSmoothingEnabled_ {false};
class MapSettings::Impl class MapSettings::Impl
{ {
public: public:
@ -43,6 +46,7 @@ public:
SettingsVariable<std::string> radarProductGroup_ { SettingsVariable<std::string> radarProductGroup_ {
kRadarProductGroupName_}; kRadarProductGroupName_};
SettingsVariable<std::string> radarProduct_ {kRadarProductName_}; SettingsVariable<std::string> radarProduct_ {kRadarProductName_};
SettingsVariable<bool> smoothingEnabled_ {kSmoothingEnabledName_};
}; };
explicit Impl() explicit Impl()
@ -54,6 +58,7 @@ public:
map_[i].radarProductGroup_.SetDefault( map_[i].radarProductGroup_.SetDefault(
kDefaultRadarProductGroupString_); kDefaultRadarProductGroupString_);
map_[i].radarProduct_.SetDefault(kDefaultRadarProduct_[i]); map_[i].radarProduct_.SetDefault(kDefaultRadarProduct_[i]);
map_[i].smoothingEnabled_.SetDefault(kDefaultSmoothingEnabled_);
map_[i].radarSite_.SetValidator( map_[i].radarSite_.SetValidator(
[](const std::string& value) [](const std::string& value)
@ -95,7 +100,8 @@ public:
{&map_[i].mapStyle_, {&map_[i].mapStyle_,
&map_[i].radarSite_, &map_[i].radarSite_,
&map_[i].radarProductGroup_, &map_[i].radarProductGroup_,
&map_[i].radarProduct_}); &map_[i].radarProduct_,
&map_[i].smoothingEnabled_});
} }
} }
@ -107,6 +113,7 @@ public:
map_[i].radarSite_.SetValueToDefault(); map_[i].radarSite_.SetValueToDefault();
map_[i].radarProductGroup_.SetValueToDefault(); map_[i].radarProductGroup_.SetValueToDefault();
map_[i].radarProduct_.SetValueToDefault(); map_[i].radarProduct_.SetValueToDefault();
map_[i].smoothingEnabled_.SetValueToDefault();
} }
friend void tag_invoke(boost::json::value_from_tag, friend void tag_invoke(boost::json::value_from_tag,
@ -116,7 +123,8 @@ public:
jv = {{kMapStyleName_, data.mapStyle_.GetValue()}, jv = {{kMapStyleName_, data.mapStyle_.GetValue()},
{kRadarSiteName_, data.radarSite_.GetValue()}, {kRadarSiteName_, data.radarSite_.GetValue()},
{kRadarProductGroupName_, data.radarProductGroup_.GetValue()}, {kRadarProductGroupName_, data.radarProductGroup_.GetValue()},
{kRadarProductName_, data.radarProduct_.GetValue()}}; {kRadarProductName_, data.radarProduct_.GetValue()},
{kSmoothingEnabledName_, data.smoothingEnabled_.GetValue()}};
} }
friend bool operator==(const MapData& lhs, const MapData& rhs) friend bool operator==(const MapData& lhs, const MapData& rhs)
@ -124,7 +132,8 @@ public:
return (lhs.mapStyle_ == rhs.mapStyle_ && // return (lhs.mapStyle_ == rhs.mapStyle_ && //
lhs.radarSite_ == rhs.radarSite_ && lhs.radarSite_ == rhs.radarSite_ &&
lhs.radarProductGroup_ == rhs.radarProductGroup_ && lhs.radarProductGroup_ == rhs.radarProductGroup_ &&
lhs.radarProduct_ == rhs.radarProduct_); lhs.radarProduct_ == rhs.radarProduct_ &&
lhs.smoothingEnabled_ == rhs.smoothingEnabled_);
} }
std::array<MapData, kCount_> map_ {}; std::array<MapData, kCount_> map_ {};
@ -170,6 +179,11 @@ SettingsVariable<std::string>& MapSettings::radar_product(std::size_t i) const
return p->map_[i].radarProduct_; return p->map_[i].radarProduct_;
} }
SettingsVariable<bool>& MapSettings::smoothing_enabled(std::size_t i) const
{
return p->map_[i].smoothingEnabled_;
}
bool MapSettings::Shutdown() bool MapSettings::Shutdown()
{ {
bool dataChanged = false; bool dataChanged = false;
@ -180,6 +194,7 @@ bool MapSettings::Shutdown()
Impl::MapData& mapRecordSettings = p->map_[i]; Impl::MapData& mapRecordSettings = p->map_[i];
dataChanged |= mapRecordSettings.mapStyle_.Commit(); dataChanged |= mapRecordSettings.mapStyle_.Commit();
dataChanged |= mapRecordSettings.smoothingEnabled_.Commit();
} }
return dataChanged; return dataChanged;
@ -207,6 +222,8 @@ bool MapSettings::ReadJson(const boost::json::object& json)
validated &= mapRecordSettings.radarSite_.ReadValue(mapRecord); validated &= mapRecordSettings.radarSite_.ReadValue(mapRecord);
validated &= validated &=
mapRecordSettings.radarProductGroup_.ReadValue(mapRecord); mapRecordSettings.radarProductGroup_.ReadValue(mapRecord);
validated &=
mapRecordSettings.smoothingEnabled_.ReadValue(mapRecord);
bool productValidated = bool productValidated =
mapRecordSettings.radarProduct_.ReadValue(mapRecord); mapRecordSettings.radarProduct_.ReadValue(mapRecord);

View file

@ -30,6 +30,7 @@ public:
SettingsVariable<std::string>& radar_site(std::size_t i) const; SettingsVariable<std::string>& radar_site(std::size_t i) const;
SettingsVariable<std::string>& radar_product_group(std::size_t i) const; SettingsVariable<std::string>& radar_product_group(std::size_t i) const;
SettingsVariable<std::string>& radar_product(std::size_t i) const; SettingsVariable<std::string>& radar_product(std::size_t i) const;
SettingsVariable<bool>& smoothing_enabled(std::size_t i) const;
bool Shutdown(); bool Shutdown();

View file

@ -15,12 +15,15 @@ class ProductSettings::Impl
public: public:
explicit Impl() explicit Impl()
{ {
showSmoothedRangeFolding_.SetDefault(false);
stiForecastEnabled_.SetDefault(true); stiForecastEnabled_.SetDefault(true);
stiPastEnabled_.SetDefault(true); stiPastEnabled_.SetDefault(true);
} }
~Impl() {} ~Impl() {}
SettingsVariable<bool> showSmoothedRangeFolding_ {
"show_smoothed_range_folding"};
SettingsVariable<bool> stiForecastEnabled_ {"sti_forecast_enabled"}; SettingsVariable<bool> stiForecastEnabled_ {"sti_forecast_enabled"};
SettingsVariable<bool> stiPastEnabled_ {"sti_past_enabled"}; SettingsVariable<bool> stiPastEnabled_ {"sti_past_enabled"};
}; };
@ -28,7 +31,9 @@ public:
ProductSettings::ProductSettings() : ProductSettings::ProductSettings() :
SettingsCategory("product"), p(std::make_unique<Impl>()) SettingsCategory("product"), p(std::make_unique<Impl>())
{ {
RegisterVariables({&p->stiForecastEnabled_, &p->stiPastEnabled_}); RegisterVariables({&p->showSmoothedRangeFolding_,
&p->stiForecastEnabled_,
&p->stiPastEnabled_});
SetDefaults(); SetDefaults();
} }
ProductSettings::~ProductSettings() = default; ProductSettings::~ProductSettings() = default;
@ -37,6 +42,11 @@ ProductSettings::ProductSettings(ProductSettings&&) noexcept = default;
ProductSettings& ProductSettings&
ProductSettings::operator=(ProductSettings&&) noexcept = default; ProductSettings::operator=(ProductSettings&&) noexcept = default;
SettingsVariable<bool>& ProductSettings::show_smoothed_range_folding() const
{
return p->showSmoothedRangeFolding_;
}
SettingsVariable<bool>& ProductSettings::sti_forecast_enabled() const SettingsVariable<bool>& ProductSettings::sti_forecast_enabled() const
{ {
return p->stiForecastEnabled_; return p->stiForecastEnabled_;
@ -66,7 +76,9 @@ ProductSettings& ProductSettings::Instance()
bool operator==(const ProductSettings& lhs, const ProductSettings& rhs) bool operator==(const ProductSettings& lhs, const ProductSettings& rhs)
{ {
return (lhs.p->stiForecastEnabled_ == rhs.p->stiForecastEnabled_ && return (lhs.p->showSmoothedRangeFolding_ ==
rhs.p->showSmoothedRangeFolding_ &&
lhs.p->stiForecastEnabled_ == rhs.p->stiForecastEnabled_ &&
lhs.p->stiPastEnabled_ == rhs.p->stiPastEnabled_); lhs.p->stiPastEnabled_ == rhs.p->stiPastEnabled_);
} }

View file

@ -25,6 +25,7 @@ public:
ProductSettings(ProductSettings&&) noexcept; ProductSettings(ProductSettings&&) noexcept;
ProductSettings& operator=(ProductSettings&&) noexcept; ProductSettings& operator=(ProductSettings&&) noexcept;
SettingsVariable<bool>& show_smoothed_range_folding() const;
SettingsVariable<bool>& sti_forecast_enabled() const; SettingsVariable<bool>& sti_forecast_enabled() const;
SettingsVariable<bool>& sti_past_enabled() const; SettingsVariable<bool>& sti_past_enabled() const;

@ -1 +1 @@
Subproject commit eaf8f185ce2b3a3248da1a4d6c8e2e9265638f15 Subproject commit 0eb475909f9e64ce81e7b8b39420d980b81b3baa