mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:30:06 +00:00
Use common data level functions when generating color table lut
This commit is contained in:
parent
8921c08f4f
commit
36f8f73b0f
3 changed files with 20 additions and 29 deletions
|
|
@ -247,7 +247,6 @@ void Level3ProductView::UpdateColorTableLut()
|
|||
return;
|
||||
}
|
||||
|
||||
std::int16_t productCode = descriptionBlock->product_code();
|
||||
float offset = descriptionBlock->offset();
|
||||
float scale = descriptionBlock->scale();
|
||||
std::uint8_t threshold = static_cast<std::uint8_t>(
|
||||
|
|
@ -292,7 +291,7 @@ void Level3ProductView::UpdateColorTableLut()
|
|||
std::optional<float> f = descriptionBlock->data_value(i);
|
||||
|
||||
// Different products use different scale/offset formulas
|
||||
if (numberOfLevels > 16 || productCode == 34)
|
||||
if (numberOfLevels > 16 || !descriptionBlock->IsDataLevelCoded())
|
||||
{
|
||||
if (i == RANGE_FOLDED && threshold > RANGE_FOLDED)
|
||||
{
|
||||
|
|
@ -312,11 +311,14 @@ void Level3ProductView::UpdateColorTableLut()
|
|||
}
|
||||
else
|
||||
{
|
||||
uint16_t th = descriptionBlock->data_level_threshold(i);
|
||||
if ((th & 0x8000u) == 0)
|
||||
std::optional<wsr88d::DataLevelCode> dataLevelCode =
|
||||
descriptionBlock->data_level_code(i);
|
||||
|
||||
if (dataLevelCode == wsr88d::DataLevelCode::RangeFolded)
|
||||
{
|
||||
// If bit 0 is zero, then the LSB is numeric
|
||||
if (f.has_value())
|
||||
lut[lutIndex] = p->colorTable_->rf_color();
|
||||
}
|
||||
else if (f.has_value())
|
||||
{
|
||||
lut[lutIndex] = p->colorTable_->Color(f.value());
|
||||
}
|
||||
|
|
@ -325,23 +327,6 @@ void Level3ProductView::UpdateColorTableLut()
|
|||
lut[lutIndex] = boost::gil::rgba8_pixel_t {0, 0, 0, 0};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If bit 0 is one, then the LSB is coded
|
||||
uint16_t lsb = th & 0x00ffu;
|
||||
|
||||
switch (lsb)
|
||||
{
|
||||
case 3: // RF
|
||||
lut[lutIndex] = p->colorTable_->rf_color();
|
||||
break;
|
||||
|
||||
default: // Ignore other values
|
||||
lut[lutIndex] = boost::gil::rgba8_pixel_t {0, 0, 0, 0};
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
p->colorTableMin_ = rangeMin;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ public:
|
|||
units::angle::degrees<double> elevation() const;
|
||||
|
||||
bool IsCompressionEnabled() const;
|
||||
bool IsDataLevelCoded() const;
|
||||
|
||||
size_t data_size() const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -633,6 +633,11 @@ bool ProductDescriptionBlock::IsCompressionEnabled() const
|
|||
return isCompressed;
|
||||
}
|
||||
|
||||
bool ProductDescriptionBlock::IsDataLevelCoded() const
|
||||
{
|
||||
return !uncodedDataLevelProducts_.contains(p->productCode_);
|
||||
}
|
||||
|
||||
size_t ProductDescriptionBlock::data_size() const
|
||||
{
|
||||
return SIZE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue