Additional clang-tidy action cleanup

This commit is contained in:
Dan Paulat 2024-12-15 22:32:25 -06:00
parent 57b773d009
commit a3eb53a649
15 changed files with 128 additions and 117 deletions

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::uint8_t kDataWordSize8_ = 8u;
static constexpr std::uint8_t kDataWordSize16_ = 16u;
static constexpr std::size_t kVerticesPerGate_ = 6u;
static constexpr std::size_t kVerticesPerOriginGate_ = 3u;
@ -108,6 +111,12 @@ public:
threadPool_.join();
};
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(Impl&&) noexcept = default;
Impl& operator=(Impl&&) noexcept = default;
void ComputeCoordinates(
const std::shared_ptr<wsr88d::rda::ElevationScan>& radarData,
bool smoothingEnabled);
@ -119,7 +128,7 @@ public:
void ComputeEdgeValue();
template<typename T>
inline T RemapDataMoment(T dataMoment) const;
[[nodiscard]] inline T RemapDataMoment(T dataMoment) const;
static bool IsRadarDataIncomplete(
const std::shared_ptr<const wsr88d::rda::ElevationScan>& radarData);
@ -130,7 +139,8 @@ public:
boost::asio::thread_pool threadPool_ {1u};
common::Level2Product product_;
wsr88d::rda::DataBlockType dataBlockType_;
wsr88d::rda::DataBlockType dataBlockType_ {
wsr88d::rda::DataBlockType::Unknown};
float selectedElevation_;
@ -525,9 +535,9 @@ void Level2ProductView::ComputeSweep()
std::shared_ptr<manager::RadarProductManager> radarProductManager =
radar_product_manager();
const bool smoothingEnabled = smoothing_enabled();
p->showSmoothedRangeFolding_ = show_smoothed_range_folding();
bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_;
const bool smoothingEnabled = smoothing_enabled();
p->showSmoothedRangeFolding_ = show_smoothed_range_folding();
const bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_;
std::shared_ptr<wsr88d::rda::ElevationScan> radarData;
std::chrono::system_clock::time_point requestedTime {selected_time()};
@ -661,7 +671,7 @@ void Level2ProductView::ComputeSweep()
const auto& radialPair = *it;
std::uint16_t radial = radialPair.first;
const auto& radialData = radialPair.second;
std::shared_ptr<wsr88d::rda::GenericRadarData::MomentDataBlock>
const std::shared_ptr<wsr88d::rda::GenericRadarData::MomentDataBlock>
momentData = radialData->moment_data_block(p->dataBlockType_);
if (momentData0->data_word_size() != momentData->data_word_size())
@ -748,7 +758,7 @@ void Level2ProductView::ComputeSweep()
continue;
}
if (nextMomentData->data_word_size() == 8)
if (nextMomentData->data_word_size() == kDataWordSize8_)
{
nextDataMomentsArray8 = reinterpret_cast<const std::uint8_t*>(
nextMomentData->data_moments());
@ -783,7 +793,7 @@ void Level2ProductView::ComputeSweep()
{
if (!smoothingEnabled)
{
std::uint8_t dataValue = dataMomentsArray8[i];
const std::uint8_t& dataValue = dataMomentsArray8[i];
if (dataValue < snrThreshold && dataValue != RANGE_FOLDED)
{
continue;
@ -791,7 +801,7 @@ void Level2ProductView::ComputeSweep()
for (std::size_t m = 0; m < vertexCount; m++)
{
dataMoments8[mIndex++] = dataMomentsArray8[i];
dataMoments8[mIndex++] = dataValue;
if (cfpMomentsArray != nullptr)
{
@ -851,7 +861,7 @@ void Level2ProductView::ComputeSweep()
{
if (!smoothingEnabled)
{
std::uint16_t dataValue = dataMomentsArray16[i];
const std::uint16_t& dataValue = dataMomentsArray16[i];
if (dataValue < snrThreshold && dataValue != RANGE_FOLDED)
{
continue;
@ -859,7 +869,7 @@ void Level2ProductView::ComputeSweep()
for (std::size_t m = 0; m < vertexCount; m++)
{
dataMoments16[mIndex++] = dataMomentsArray16[i];
dataMoments16[mIndex++] = dataValue;
}
}
else if (gate > 0)
@ -924,18 +934,19 @@ void Level2ProductView::ComputeSweep()
const std::uint16_t baseCoord = gate - 1;
std::size_t offset1 = ((startRadial + radial) % vertexRadials *
common::MAX_DATA_MOMENT_GATES +
baseCoord) *
2;
std::size_t offset2 =
const std::size_t offset1 =
((startRadial + radial) % vertexRadials *
common::MAX_DATA_MOMENT_GATES +
baseCoord) *
2;
const std::size_t offset2 =
offset1 + static_cast<std::size_t>(gateSize) * 2;
std::size_t offset3 =
const std::size_t offset3 =
(((startRadial + radial + 1) % vertexRadials) *
common::MAX_DATA_MOMENT_GATES +
baseCoord) *
2;
std::size_t offset4 =
const std::size_t offset4 =
offset3 + static_cast<std::size_t>(gateSize) * 2;
vertices[vIndex++] = coordinates[offset1];
@ -955,8 +966,6 @@ void Level2ProductView::ComputeSweep()
vertices[vIndex++] = coordinates[offset4];
vertices[vIndex++] = coordinates[offset4 + 1];
vertexCount = kVerticesPerGate_;
}
else
{
@ -980,8 +989,6 @@ void Level2ProductView::ComputeSweep()
vertices[vIndex++] = coordinates[offset2];
vertices[vIndex++] = coordinates[offset2 + 1];
vertexCount = kVerticesPerOriginGate_;
}
}
}

View file

@ -489,8 +489,8 @@ std::uint8_t Level3ProductView::ComputeEdgeValue() const
{
std::uint8_t edgeValue = 0;
std::shared_ptr<wsr88d::rpg::ProductDescriptionBlock> descriptionBlock =
p->graphicMessage_->description_block();
const std::shared_ptr<wsr88d::rpg::ProductDescriptionBlock>
descriptionBlock = p->graphicMessage_->description_block();
const float offset = descriptionBlock->offset();
const float scale = descriptionBlock->scale();
@ -498,11 +498,12 @@ std::uint8_t Level3ProductView::ComputeEdgeValue() const
switch (p->category_)
{
case common::Level3ProductCategory::Velocity:
edgeValue = (scale > 0.0f) ? (-offset / scale) : -offset;
edgeValue = static_cast<std::uint8_t>((scale > 0.0f) ? (-offset / scale) :
-offset);
break;
case common::Level3ProductCategory::DifferentialReflectivity:
edgeValue = -offset;
edgeValue = static_cast<std::uint8_t>(-offset);
break;
case common::Level3ProductCategory::SpectrumWidth:
@ -512,7 +513,8 @@ std::uint8_t Level3ProductView::ComputeEdgeValue() const
case common::Level3ProductCategory::CorrelationCoefficient:
edgeValue = static_cast<std::uint8_t>(
std::max<std::uint16_t>(255, descriptionBlock->number_of_levels()));
std::max<std::uint16_t>(std::numeric_limits<std::uint8_t>::max(),
descriptionBlock->number_of_levels()));
break;
case common::Level3ProductCategory::Reflectivity:

View file

@ -58,7 +58,7 @@ protected:
void DisconnectRadarProductManager() override;
void UpdateColorTableLut() override;
std::uint8_t ComputeEdgeValue() const;
[[nodiscard]] std::uint8_t ComputeEdgeValue() const;
private:
class Impl;

View file

@ -47,7 +47,8 @@ public:
const std::shared_ptr<wsr88d::rpg::GenericRadialDataPacket>& radialData,
bool smoothingEnabled);
inline std::uint8_t RemapDataMoment(std::uint8_t dataMoment) const;
[[nodiscard]] inline std::uint8_t
RemapDataMoment(std::uint8_t dataMoment) const;
Level3RadialView* self_;
@ -133,9 +134,9 @@ void Level3RadialView::ComputeSweep()
std::shared_ptr<manager::RadarProductManager> radarProductManager =
radar_product_manager();
const bool smoothingEnabled = smoothing_enabled();
p->showSmoothedRangeFolding_ = show_smoothed_range_folding();
bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_;
const bool smoothingEnabled = smoothing_enabled();
p->showSmoothedRangeFolding_ = show_smoothed_range_folding();
const bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_;
// Retrieve message from Radar Product Manager
std::shared_ptr<wsr88d::rpg::Level3Message> message;
@ -381,7 +382,7 @@ void Level3RadialView::ComputeSweep()
if (!smoothingEnabled)
{
// Store data moment value
uint8_t dataValue =
const uint8_t dataValue =
(i < dataMomentsArray8.size()) ? dataMomentsArray8[i] : 0;
if (dataValue < snrThreshold && dataValue != RANGE_FOLDED)
{
@ -470,8 +471,6 @@ void Level3RadialView::ComputeSweep()
vertices[vIndex++] = coordinates[offset4];
vertices[vIndex++] = coordinates[offset4 + 1];
vertexCount = 6;
}
else
{
@ -494,8 +493,6 @@ void Level3RadialView::ComputeSweep()
vertices[vIndex++] = coordinates[offset2];
vertices[vIndex++] = coordinates[offset2 + 1];
vertexCount = 3;
}
}
}
@ -561,44 +558,46 @@ void Level3RadialView::Impl::ComputeCoordinates(
// size distance from the radar site
1.0f;
std::for_each(std::execution::par_unseq,
radials.begin(),
radials.end(),
[&](std::uint32_t radial)
{
float angle = radialData->start_angle(radial);
std::for_each(
std::execution::par_unseq,
radials.begin(),
radials.end(),
[&](std::uint32_t radial)
{
float angle = radialData->start_angle(radial);
if (smoothingEnabled)
{
angle += radialData->delta_angle(radial) * 0.5f;
}
if (smoothingEnabled)
{
static constexpr float kDeltaAngleFactor = 0.5f;
angle += radialData->delta_angle(radial) * kDeltaAngleFactor;
}
std::for_each(std::execution::par_unseq,
gates.begin(),
gates.end(),
[&](std::uint32_t gate)
{
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;
std::for_each(
std::execution::par_unseq,
gates.begin(),
gates.end(),
[&](std::uint32_t gate)
{
const std::uint32_t radialGate =
radial * common::MAX_DATA_MOMENT_GATES + gate;
const float range =
(static_cast<float>(gate) + gateRangeOffset) * gateSize;
const std::size_t offset = static_cast<size_t>(radialGate) * 2;
double latitude;
double longitude;
double latitude = 0.0;
double longitude = 0.0;
geodesic.Direct(radarLatitude,
radarLongitude,
angle,
range,
latitude,
longitude);
geodesic.Direct(radarLatitude,
radarLongitude,
angle,
range,
latitude,
longitude);
coordinates_[offset] = latitude;
coordinates_[offset + 1] = longitude;
});
});
coordinates_[offset] = static_cast<float>(latitude);
coordinates_[offset + 1] = static_cast<float>(longitude);
});
});
timer.stop();
logger_->debug("Coordinates calculated in {}", timer.format(6, "%ws"));
}

View file

@ -33,7 +33,8 @@ public:
}
~Level3RasterViewImpl() { threadPool_.join(); };
inline std::uint8_t RemapDataMoment(std::uint8_t dataMoment) const;
[[nodiscard]] inline std::uint8_t
RemapDataMoment(std::uint8_t dataMoment) const;
boost::asio::thread_pool threadPool_ {1u};
@ -116,9 +117,9 @@ void Level3RasterView::ComputeSweep()
std::shared_ptr<manager::RadarProductManager> radarProductManager =
radar_product_manager();
const bool smoothingEnabled = smoothing_enabled();
p->showSmoothedRangeFolding_ = show_smoothed_range_folding();
bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_;
const bool smoothingEnabled = smoothing_enabled();
p->showSmoothedRangeFolding_ = show_smoothed_range_folding();
const bool& showSmoothedRangeFolding = p->showSmoothedRangeFolding_;
// Retrieve message from Radar Product Manager
std::shared_ptr<wsr88d::rpg::Level3Message> message;
@ -344,10 +345,10 @@ void Level3RasterView::ComputeSweep()
{
if (!smoothingEnabled)
{
constexpr size_t vertexCount = 6;
static constexpr std::size_t vertexCount = 6;
// Store data moment value
uint8_t dataValue = dataMomentsArray8[bin];
const std::uint8_t& dataValue = dataMomentsArray8[bin];
if (dataValue < snrThreshold && dataValue != RANGE_FOLDED)
{
continue;

View file

@ -47,11 +47,12 @@ public:
virtual std::uint16_t vcp() const = 0;
virtual const std::vector<float>& vertices() const = 0;
std::shared_ptr<manager::RadarProductManager> radar_product_manager() const;
std::chrono::system_clock::time_point selected_time() const;
bool show_smoothed_range_folding() const;
bool smoothing_enabled() const;
std::mutex& sweep_mutex();
[[nodiscard]] std::shared_ptr<manager::RadarProductManager>
radar_product_manager() const;
[[nodiscard]] std::chrono::system_clock::time_point selected_time() const;
[[nodiscard]] bool show_smoothed_range_folding() const;
[[nodiscard]] bool smoothing_enabled() const;
[[nodiscard]] std::mutex& sweep_mutex();
void set_radar_product_manager(
std::shared_ptr<manager::RadarProductManager> radarProductManager);