Linting fixes

This commit is contained in:
Dan Paulat 2024-12-15 08:22:19 -06:00
parent a65504a2cb
commit 57b773d009
4 changed files with 98 additions and 73 deletions

View file

@ -10,7 +10,6 @@
#include <scwx/util/threads.hpp>
#include <scwx/wsr88d/nexrad_file_factory.hpp>
#include <deque>
#include <execution>
#include <mutex>
#include <shared_mutex>
@ -64,6 +63,8 @@ static constexpr uint32_t NUM_COORIDNATES_1_DEGREE =
static const std::string kDefaultLevel3Product_ {"N0B"};
static constexpr std::size_t kTimerPlaces_ {6u};
static constexpr std::chrono::seconds kFastRetryInterval_ {15};
static constexpr std::chrono::seconds kSlowRetryInterval_ {120};
@ -464,6 +465,8 @@ void RadarProductManager::Initialize()
const auto radialGates0_5Degree =
boost::irange<uint32_t>(0, NUM_RADIAL_GATES_0_5_DEGREE);
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers): Values are given
// descriptions
p->CalculateCoordinates(
radialGates0_5Degree,
units::angle::degrees<float> {0.5f}, // Radial angle
@ -471,10 +474,11 @@ void RadarProductManager::Initialize()
// Far end of the first gate is the gate size distance from the radar site
1.0f,
coordinates0_5Degree);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
timer.stop();
logger_->debug("Coordinates (0.5 degree) calculated in {}",
timer.format(6, "%ws"));
timer.format(kTimerPlaces_, "%ws"));
// Calculate half degree smooth azimuth coordinates
timer.start();
@ -483,6 +487,8 @@ void RadarProductManager::Initialize()
coordinates0_5DegreeSmooth.resize(NUM_COORIDNATES_0_5_DEGREE);
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers): Values are given
// descriptions
p->CalculateCoordinates(radialGates0_5Degree,
units::angle::degrees<float> {0.5f}, // Radial angle
units::angle::degrees<float> {0.25f}, // Angle offset
@ -490,10 +496,11 @@ void RadarProductManager::Initialize()
// distance from the radar site
0.5f,
coordinates0_5DegreeSmooth);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
timer.stop();
logger_->debug("Coordinates (0.5 degree smooth) calculated in {}",
timer.format(6, "%ws"));
timer.format(kTimerPlaces_, "%ws"));
// Calculate 1 degree azimuth coordinates
timer.start();
@ -504,6 +511,8 @@ void RadarProductManager::Initialize()
const auto radialGates1Degree =
boost::irange<uint32_t>(0, NUM_RADIAL_GATES_1_DEGREE);
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers): Values are given
// descriptions
p->CalculateCoordinates(
radialGates1Degree,
units::angle::degrees<float> {1.0f}, // Radial angle
@ -511,10 +520,11 @@ void RadarProductManager::Initialize()
// Far end of the first gate is the gate size distance from the radar site
1.0f,
coordinates1Degree);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
timer.stop();
logger_->debug("Coordinates (1 degree) calculated in {}",
timer.format(6, "%ws"));
timer.format(kTimerPlaces_, "%ws"));
// Calculate 1 degree smooth azimuth coordinates
timer.start();
@ -522,6 +532,8 @@ void RadarProductManager::Initialize()
coordinates1DegreeSmooth.resize(NUM_COORIDNATES_1_DEGREE);
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers): Values are given
// descriptions
p->CalculateCoordinates(radialGates1Degree,
units::angle::degrees<float> {1.0f}, // Radial angle
units::angle::degrees<float> {0.5f}, // Angle offset
@ -529,10 +541,11 @@ void RadarProductManager::Initialize()
// distance from the radar site
0.5f,
coordinates1DegreeSmooth);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
timer.stop();
logger_->debug("Coordinates (1 degree smooth) calculated in {}",
timer.format(6, "%ws"));
timer.format(kTimerPlaces_, "%ws"));
p->initialized_ = true;
}
@ -558,23 +571,25 @@ void RadarProductManagerImpl::CalculateCoordinates(
radialGates.end(),
[&](uint32_t radialGate)
{
const uint16_t gate =
static_cast<uint16_t>(radialGate % common::MAX_DATA_MOMENT_GATES);
const uint16_t radial =
static_cast<uint16_t>(radialGate / common::MAX_DATA_MOMENT_GATES);
const auto gate = static_cast<std::uint16_t>(
radialGate % common::MAX_DATA_MOMENT_GATES);
const auto radial = static_cast<std::uint16_t>(
radialGate / common::MAX_DATA_MOMENT_GATES);
const float angle = radial * radialAngle.value() + angleOffset.value();
const float range = (gate + gateRangeOffset) * gateSize;
const size_t offset = radialGate * 2;
const float angle = static_cast<float>(radial) * radialAngle.value() +
angleOffset.value();
const float range =
(static_cast<float>(gate) + gateRangeOffset) * gateSize;
const std::size_t offset = static_cast<std::size_t>(radialGate) * 2;
double latitude;
double longitude;
double latitude = 0.0;
double longitude = 0.0;
geodesic.Direct(
radar.first, radar.second, angle, range, latitude, longitude);
outputCoordinates[offset] = latitude;
outputCoordinates[offset + 1] = longitude;
outputCoordinates[offset] = static_cast<float>(latitude);
outputCoordinates[offset + 1] = static_cast<float>(longitude);
});
}

View file

@ -6,8 +6,6 @@
#include <scwx/qt/view/radar_product_view.hpp>
#include <scwx/util/logger.hpp>
#include <execution>
#if defined(_MSC_VER)
# pragma warning(push, 0)
#endif

View file

@ -6,7 +6,6 @@
#include <scwx/util/logger.hpp>
#include <array>
#include <execution>
#include <boost/json.hpp>
@ -53,21 +52,21 @@ public:
{
for (std::size_t i = 0; i < kCount_; i++)
{
map_[i].mapStyle_.SetDefault(kDefaultMapStyle_);
map_[i].radarSite_.SetDefault(kDefaultRadarSite_);
map_[i].radarProductGroup_.SetDefault(
map_.at(i).mapStyle_.SetDefault(kDefaultMapStyle_);
map_.at(i).radarSite_.SetDefault(kDefaultRadarSite_);
map_.at(i).radarProductGroup_.SetDefault(
kDefaultRadarProductGroupString_);
map_[i].radarProduct_.SetDefault(kDefaultRadarProduct_[i]);
map_[i].smoothingEnabled_.SetDefault(kDefaultSmoothingEnabled_);
map_.at(i).radarProduct_.SetDefault(kDefaultRadarProduct_.at(i));
map_.at(i).smoothingEnabled_.SetDefault(kDefaultSmoothingEnabled_);
map_[i].radarSite_.SetValidator(
map_.at(i).radarSite_.SetValidator(
[](const std::string& value)
{
// Radar site must exist
return config::RadarSite::Get(value) != nullptr;
});
map_[i].radarProductGroup_.SetValidator(
map_.at(i).radarProductGroup_.SetValidator(
[](const std::string& value)
{
// Radar product group must be valid
@ -76,12 +75,12 @@ public:
return radarProductGroup != common::RadarProductGroup::Unknown;
});
map_[i].radarProduct_.SetValidator(
map_.at(i).radarProduct_.SetValidator(
[this, i](const std::string& value)
{
common::RadarProductGroup radarProductGroup =
common::GetRadarProductGroup(
map_[i].radarProductGroup_.GetValue());
map_.at(i).radarProductGroup_.GetValue());
if (radarProductGroup == common::RadarProductGroup::Level2)
{
@ -97,11 +96,11 @@ public:
});
variables_.insert(variables_.cend(),
{&map_[i].mapStyle_,
&map_[i].radarSite_,
&map_[i].radarProductGroup_,
&map_[i].radarProduct_,
&map_[i].smoothingEnabled_});
{&map_.at(i).mapStyle_,
&map_.at(i).radarSite_,
&map_.at(i).radarProductGroup_,
&map_.at(i).radarProduct_,
&map_.at(i).smoothingEnabled_});
}
}
@ -109,11 +108,11 @@ public:
void SetDefaults(std::size_t i)
{
map_[i].mapStyle_.SetValueToDefault();
map_[i].radarSite_.SetValueToDefault();
map_[i].radarProductGroup_.SetValueToDefault();
map_[i].radarProduct_.SetValueToDefault();
map_[i].smoothingEnabled_.SetValueToDefault();
map_.at(i).mapStyle_.SetValueToDefault();
map_.at(i).radarSite_.SetValueToDefault();
map_.at(i).radarProductGroup_.SetValueToDefault();
map_.at(i).radarProduct_.SetValueToDefault();
map_.at(i).smoothingEnabled_.SetValueToDefault();
}
friend void tag_invoke(boost::json::value_from_tag,
@ -160,28 +159,28 @@ std::size_t MapSettings::count() const
SettingsVariable<std::string>& MapSettings::map_style(std::size_t i) const
{
return p->map_[i].mapStyle_;
return p->map_.at(i).mapStyle_;
}
SettingsVariable<std::string>& MapSettings::radar_site(std::size_t i) const
{
return p->map_[i].radarSite_;
return p->map_.at(i).radarSite_;
}
SettingsVariable<std::string>&
MapSettings::radar_product_group(std::size_t i) const
{
return p->map_[i].radarProductGroup_;
return p->map_.at(i).radarProductGroup_;
}
SettingsVariable<std::string>& MapSettings::radar_product(std::size_t i) const
{
return p->map_[i].radarProduct_;
return p->map_.at(i).radarProduct_;
}
SettingsVariable<bool>& MapSettings::smoothing_enabled(std::size_t i) const
{
return p->map_[i].smoothingEnabled_;
return p->map_.at(i).smoothingEnabled_;
}
bool MapSettings::Shutdown()
@ -191,7 +190,7 @@ bool MapSettings::Shutdown()
// Commit settings that are managed separate from the settings dialog
for (std::size_t i = 0; i < kCount_; ++i)
{
Impl::MapData& mapRecordSettings = p->map_[i];
Impl::MapData& mapRecordSettings = p->map_.at(i);
dataChanged |= mapRecordSettings.mapStyle_.Commit();
dataChanged |= mapRecordSettings.smoothingEnabled_.Commit();
@ -215,7 +214,7 @@ bool MapSettings::ReadJson(const boost::json::object& json)
if (i < mapArray.size() && mapArray.at(i).is_object())
{
const boost::json::object& mapRecord = mapArray.at(i).as_object();
Impl::MapData& mapRecordSettings = p->map_[i];
Impl::MapData& mapRecordSettings = p->map_.at(i);
// Load JSON Elements
validated &= mapRecordSettings.mapStyle_.ReadValue(mapRecord);

View file

@ -25,6 +25,9 @@ static constexpr std::uint32_t kMaxRadialGates_ =
common::MAX_0_5_DEGREE_RADIALS * common::MAX_DATA_MOMENT_GATES;
static constexpr std::uint32_t kMaxCoordinates_ = kMaxRadialGates_ * 2u;
static constexpr std::size_t kVerticesPerGate_ = 6u;
static constexpr std::size_t kVerticesPerOriginGate_ = 3u;
static constexpr uint16_t RANGE_FOLDED = 1u;
static constexpr uint32_t VERTICES_PER_BIN = 6u;
static constexpr uint32_t VALUES_PER_VERTEX = 2u;
@ -769,7 +772,11 @@ void Level2ProductView::ComputeSweep()
continue;
}
std::size_t vertexCount = (gate > 0) ? 6 : 3;
std::size_t vertexCount =
(gate > 0) ? kVerticesPerGate_ : kVerticesPerOriginGate_;
// Allow pointer arithmetic here, as bounds have already been checked
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic)
// Store data moment value
if (dataMomentsArray8 != nullptr)
@ -902,6 +909,8 @@ void Level2ProductView::ComputeSweep()
}
}
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
// Store vertices
if (gate > 0)
{
@ -919,13 +928,15 @@ void Level2ProductView::ComputeSweep()
common::MAX_DATA_MOMENT_GATES +
baseCoord) *
2;
std::size_t offset2 = offset1 + gateSize * 2;
std::size_t offset2 =
offset1 + static_cast<std::size_t>(gateSize) * 2;
std::size_t offset3 =
(((startRadial + radial + 1) % vertexRadials) *
common::MAX_DATA_MOMENT_GATES +
baseCoord) *
2;
std::size_t offset4 = offset3 + gateSize * 2;
std::size_t offset4 =
offset3 + static_cast<std::size_t>(gateSize) * 2;
vertices[vIndex++] = coordinates[offset1];
vertices[vIndex++] = coordinates[offset1 + 1];
@ -945,7 +956,7 @@ void Level2ProductView::ComputeSweep()
vertices[vIndex++] = coordinates[offset4];
vertices[vIndex++] = coordinates[offset4 + 1];
vertexCount = 6;
vertexCount = kVerticesPerGate_;
}
else
{
@ -970,7 +981,7 @@ void Level2ProductView::ComputeSweep()
vertices[vIndex++] = coordinates[offset2];
vertices[vIndex++] = coordinates[offset2 + 1];
vertexCount = 3;
vertexCount = kVerticesPerOriginGate_;
}
}
}
@ -1010,7 +1021,7 @@ void Level2ProductView::Impl::ComputeEdgeValue()
{
case wsr88d::rda::DataBlockType::MomentVel:
case wsr88d::rda::DataBlockType::MomentZdr:
edgeValue_ = offset;
edgeValue_ = static_cast<std::uint16_t>(offset);
break;
case wsr88d::rda::DataBlockType::MomentSw:
@ -1019,7 +1030,7 @@ void Level2ProductView::Impl::ComputeEdgeValue()
break;
case wsr88d::rda::DataBlockType::MomentRho:
edgeValue_ = 255;
edgeValue_ = std::numeric_limits<std::uint8_t>::max();
break;
case wsr88d::rda::DataBlockType::MomentRef:
@ -1194,7 +1205,8 @@ void Level2ProductView::Impl::ComputeCoordinates(
}
}
std::for_each(std::execution::par_unseq,
std::for_each(
std::execution::par_unseq,
gates.begin(),
gates.end(),
[&](std::uint32_t gate)
@ -1202,11 +1214,12 @@ void Level2ProductView::Impl::ComputeCoordinates(
const std::uint32_t radialGate =
radial * common::MAX_DATA_MOMENT_GATES + gate;
const float range =
(gate + gateRangeOffset) * gateSize;
const std::size_t offset = radialGate * 2;
(static_cast<float>(gate) + gateRangeOffset) * gateSize;
const std::size_t offset =
static_cast<std::size_t>(radialGate) * 2;
double latitude;
double longitude;
double latitude = 0.0;
double longitude = 0.0;
geodesic.Direct(radarLatitude,
radarLongitude,
@ -1215,8 +1228,8 @@ void Level2ProductView::Impl::ComputeCoordinates(
latitude,
longitude);
coordinates_[offset] = latitude;
coordinates_[offset + 1] = longitude;
coordinates_[offset] = static_cast<float>(latitude);
coordinates_[offset + 1] = static_cast<float>(longitude);
});
});
timer.stop();