From d6e2bfe9abc833819f9ed873938a9bf7939fd115 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Tue, 22 Apr 2025 11:04:48 -0400 Subject: [PATCH] Level 2 azimuth angle is the center of the radial, not the start --- .../scwx/qt/view/level2_product_view.cpp | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/scwx-qt/source/scwx/qt/view/level2_product_view.cpp b/scwx-qt/source/scwx/qt/view/level2_product_view.cpp index 6fcc775c..6344dff0 100644 --- a/scwx-qt/source/scwx/qt/view/level2_product_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level2_product_view.cpp @@ -1131,7 +1131,7 @@ void Level2ProductView::Impl::ComputeCoordinates( units::degrees angle {}; auto radialData = radarData->find(radial); - if (radialData != radarData->cend() && !smoothingEnabled) + if (radialData != radarData->cend() && smoothingEnabled) { angle = radialData->second->azimuth_angle(); } @@ -1143,7 +1143,7 @@ void Level2ProductView::Impl::ComputeCoordinates( (radial >= 2) ? radial - 2 : numRadials - (2 - radial)); if (radialData != radarData->cend() && - prevRadial1 != radarData->cend() && smoothingEnabled) + prevRadial1 != radarData->cend() && !smoothingEnabled) { const units::degrees currentAngle = radialData->second->azimuth_angle(); @@ -1154,13 +1154,13 @@ void Level2ProductView::Impl::ComputeCoordinates( const units::degrees deltaAngle = NormalizeAngle(currentAngle - prevAngle); - // Delta scale is half the delta angle to reach the center of the - // bin, because smoothing is enabled + // Delta scale is half the delta angle to reach the end of the + // bin, because smoothing is not enabled constexpr float deltaScale = 0.5f; - angle = currentAngle + deltaAngle * deltaScale; + angle = currentAngle - deltaAngle * deltaScale; } - else if (radialData != radarData->cend() && smoothingEnabled) + else if (radialData != radarData->cend() && !smoothingEnabled) { const units::degrees currentAngle = radialData->second->azimuth_angle(); @@ -1169,11 +1169,11 @@ void Level2ProductView::Impl::ComputeCoordinates( // to determine a delta angle constexpr units::degrees deltaAngle {0.5f}; - // Delta scale is half the delta angle to reach the center of the + // Delta scale is half the delta angle to reach the edge of the // bin, because smoothing is enabled constexpr float deltaScale = 0.5f; - angle = currentAngle + deltaAngle * deltaScale; + angle = currentAngle - deltaAngle * deltaScale; } else if (prevRadial1 != radarData->cend() && prevRadial2 != radarData->cend()) @@ -1189,11 +1189,12 @@ void Level2ProductView::Impl::ComputeCoordinates( const float deltaScale = (smoothingEnabled) ? - // Delta scale is 1.5x the delta angle to reach the center + // Delta scale is 1.0x the delta angle to reach the center // of the next bin, because smoothing is enabled - 1.5f : - // Delta scale is 1.0x the delta angle - 1.0f; + 1.0f : + // Delta scale is 0.5x the delta angle to reach the edge of + // the next bin + 0.5f; angle = prevAngle1 + deltaAngle * deltaScale; } @@ -1208,11 +1209,12 @@ void Level2ProductView::Impl::ComputeCoordinates( const float deltaScale = (smoothingEnabled) ? - // Delta scale is 1.5x the delta angle to reach the center + // Delta scale is 1.0x the delta angle to reach the center // of the next bin, because smoothing is enabled - 1.5f : - // Delta scale is 1.0x the delta angle - 1.0f; + 1.0f : + // Delta scale is 0.5x the delta angle to reach the edge of + // the next bin + 0.5f; angle = prevAngle1 + deltaAngle * deltaScale; } @@ -1368,6 +1370,13 @@ Level2ProductView::GetBinLevel(const common::Coordinate& coordinate) const if (nextRadial != radarData->cend()) { nextAngle = nextRadial->second->azimuth_angle(); + + // Level 2 angles are the center of the bins. + const units::degrees deltaAngle = + common::GetAngleDelta(startAngle, nextAngle); + startAngle -= deltaAngle / 2; + nextAngle -= deltaAngle / 2; + hasNextAngle = true; } else @@ -1384,7 +1393,9 @@ Level2ProductView::GetBinLevel(const common::Coordinate& coordinate) const const units::degrees deltaAngle = common::GetAngleDelta(startAngle, prevAngle); - nextAngle = startAngle + deltaAngle; + // Level 2 angles are the center of the bins. + nextAngle = startAngle + deltaAngle / 2; + startAngle -= deltaAngle / 2; hasNextAngle = true; } }