mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:30:05 +00:00 
			
		
		
		
	RPG clang-tidy cleanup
This commit is contained in:
		
							parent
							
								
									e49adafda9
								
							
						
					
					
						commit
						68a5baa5c4
					
				
					 6 changed files with 223 additions and 204 deletions
				
			
		|  | @ -9,22 +9,17 @@ | |||
| #include <scwx/wsr88d/rpg/tabular_product_message.hpp> | ||||
| 
 | ||||
| #include <unordered_map> | ||||
| #include <vector> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace wsr88d | ||||
| { | ||||
| namespace rpg | ||||
| namespace scwx::wsr88d::rpg | ||||
| { | ||||
| 
 | ||||
| static const std::string logPrefix_ = | ||||
|    "scwx::wsr88d::rpg::level3_message_factory"; | ||||
| static const auto logger_ = util::Logger::Create(logPrefix_); | ||||
| 
 | ||||
| typedef std::function<std::shared_ptr<Level3Message>(Level3MessageHeader&&, | ||||
|                                                      std::istream&)> | ||||
|    CreateLevel3MessageFunction; | ||||
| using CreateLevel3MessageFunction = | ||||
|    std::function<std::shared_ptr<Level3Message>(Level3MessageHeader&&, | ||||
|                                                 std::istream&)>; | ||||
| 
 | ||||
| static const std::unordered_map<int, CreateLevel3MessageFunction> //
 | ||||
|    create_ {{2, GeneralStatusMessage::Create}, | ||||
|  | @ -154,13 +149,12 @@ std::shared_ptr<Level3Message> Level3MessageFactory::Create(std::istream& is) | |||
|    else if (headerValid) | ||||
|    { | ||||
|       // Seek to the end of the current message
 | ||||
|       is.seekg(header.length_of_message() - Level3MessageHeader::SIZE, | ||||
|       is.seekg(static_cast<std::streamoff>(header.length_of_message()) - | ||||
|                   static_cast<std::streamoff>(Level3MessageHeader::SIZE), | ||||
|                std::ios_base::cur); | ||||
|    } | ||||
| 
 | ||||
|    return message; | ||||
| } | ||||
| 
 | ||||
| } // namespace rpg
 | ||||
| } // namespace wsr88d
 | ||||
| } // namespace scwx
 | ||||
| } // namespace scwx::wsr88d::rpg
 | ||||
|  |  | |||
|  | @ -28,18 +28,14 @@ | |||
| 
 | ||||
| #include <unordered_map> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace wsr88d | ||||
| { | ||||
| namespace rpg | ||||
| namespace scwx::wsr88d::rpg | ||||
| { | ||||
| 
 | ||||
| static const std::string logPrefix_ = "scwx::wsr88d::rpg::packet_factory"; | ||||
| static const auto        logger_    = util::Logger::Create(logPrefix_); | ||||
| 
 | ||||
| typedef std::function<std::shared_ptr<Packet>(std::istream&)> | ||||
|    CreateMessageFunction; | ||||
| using CreateMessageFunction = | ||||
|    std::function<std::shared_ptr<Packet>(std::istream&)>; | ||||
| 
 | ||||
| static const std::unordered_map<unsigned int, CreateMessageFunction> create_ { | ||||
|    {1, TextAndSpecialSymbolPacket::Create}, | ||||
|  | @ -83,7 +79,7 @@ std::shared_ptr<Packet> PacketFactory::Create(std::istream& is) | |||
|    std::shared_ptr<Packet> packet      = nullptr; | ||||
|    bool                    packetValid = true; | ||||
| 
 | ||||
|    uint16_t packetCode; | ||||
|    std::uint16_t packetCode {0}; | ||||
| 
 | ||||
|    is.read(reinterpret_cast<char*>(&packetCode), 2); | ||||
|    packetCode = ntohs(packetCode); | ||||
|  | @ -110,6 +106,4 @@ std::shared_ptr<Packet> PacketFactory::Create(std::istream& is) | |||
|    return packet; | ||||
| } | ||||
| 
 | ||||
| } // namespace rpg
 | ||||
| } // namespace wsr88d
 | ||||
| } // namespace scwx
 | ||||
| } // namespace scwx::wsr88d::rpg
 | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| #include <cstddef> | ||||
| #include <scwx/wsr88d/rpg/product_description_block.hpp> | ||||
| #include <scwx/util/float.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
|  | @ -95,73 +96,57 @@ static const std::unordered_map<std::int16_t, float> grScale_ { | |||
|    {174, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})}, | ||||
|    {175, ((units::inches<float> {1} * 0.01f) / units::millimeters<float> {1})}}; | ||||
| 
 | ||||
| class ProductDescriptionBlockImpl | ||||
| class ProductDescriptionBlock::Impl | ||||
| { | ||||
| public: | ||||
|    explicit ProductDescriptionBlockImpl() : | ||||
|        blockDivider_ {0}, | ||||
|        latitudeOfRadar_ {0}, | ||||
|        longitudeOfRadar_ {0}, | ||||
|        heightOfRadar_ {0}, | ||||
|        productCode_ {0}, | ||||
|        operationalMode_ {0}, | ||||
|        volumeCoveragePattern_ {0}, | ||||
|        sequenceNumber_ {0}, | ||||
|        volumeScanNumber_ {0}, | ||||
|        volumeScanDate_ {0}, | ||||
|        volumeScanStartTime_ {0}, | ||||
|        generationDateOfProduct_ {0}, | ||||
|        generationTimeOfProduct_ {0}, | ||||
|        elevationNumber_ {0}, | ||||
|        version_ {0}, | ||||
|        spotBlank_ {0}, | ||||
|        offsetToSymbology_ {0}, | ||||
|        offsetToGraphic_ {0}, | ||||
|        offsetToTabular_ {0}, | ||||
|        parameters_ {0}, | ||||
|        halfwords_ {0} | ||||
|    { | ||||
|    } | ||||
|    ~ProductDescriptionBlockImpl() = default; | ||||
|    explicit Impl() = default; | ||||
|    ~Impl()         = default; | ||||
| 
 | ||||
|    uint16_t halfword(size_t i); | ||||
|    Impl(const Impl&)             = delete; | ||||
|    Impl& operator=(const Impl&)  = delete; | ||||
|    Impl(const Impl&&)            = delete; | ||||
|    Impl& operator=(const Impl&&) = delete; | ||||
| 
 | ||||
|    int16_t  blockDivider_; | ||||
|    int32_t  latitudeOfRadar_; | ||||
|    int32_t  longitudeOfRadar_; | ||||
|    int16_t  heightOfRadar_; | ||||
|    int16_t  productCode_; | ||||
|    uint16_t operationalMode_; | ||||
|    uint16_t volumeCoveragePattern_; | ||||
|    int16_t  sequenceNumber_; | ||||
|    uint16_t volumeScanNumber_; | ||||
|    uint16_t volumeScanDate_; | ||||
|    uint32_t volumeScanStartTime_; | ||||
|    uint16_t generationDateOfProduct_; | ||||
|    uint32_t generationTimeOfProduct_; | ||||
|    std::uint16_t halfword(std::size_t i); | ||||
| 
 | ||||
|    std::int16_t  blockDivider_ {0}; | ||||
|    std::int32_t  latitudeOfRadar_ {0}; | ||||
|    std::int32_t  longitudeOfRadar_ {0}; | ||||
|    std::int16_t  heightOfRadar_ {0}; | ||||
|    std::int16_t  productCode_ {0}; | ||||
|    std::uint16_t operationalMode_ {0}; | ||||
|    std::uint16_t volumeCoveragePattern_ {0}; | ||||
|    std::int16_t  sequenceNumber_ {0}; | ||||
|    std::uint16_t volumeScanNumber_ {0}; | ||||
|    std::uint16_t volumeScanDate_ {0}; | ||||
|    std::uint32_t volumeScanStartTime_ {0}; | ||||
|    std::uint16_t generationDateOfProduct_ {0}; | ||||
|    std::uint32_t generationTimeOfProduct_ {0}; | ||||
|    // 27-28: Product dependent parameters 1 and 2 (Table V)
 | ||||
|    uint16_t elevationNumber_; | ||||
|    std::uint16_t elevationNumber_ {0}; | ||||
|    // 30:    Product dependent parameter 3 (Table V)
 | ||||
|    // 31-46: Product dependent (Note 1)
 | ||||
|    // 47-53: Product dependent parameters 4-10 (Table V, Note 3)
 | ||||
|    uint8_t  version_; | ||||
|    uint8_t  spotBlank_; | ||||
|    uint32_t offsetToSymbology_; | ||||
|    uint32_t offsetToGraphic_; | ||||
|    uint32_t offsetToTabular_; | ||||
|    std::uint8_t  version_ {0}; | ||||
|    std::uint8_t  spotBlank_ {0}; | ||||
|    std::uint32_t offsetToSymbology_ {0}; | ||||
|    std::uint32_t offsetToGraphic_ {0}; | ||||
|    std::uint32_t offsetToTabular_ {0}; | ||||
| 
 | ||||
|    std::array<uint16_t, 10> parameters_; | ||||
|    std::array<uint16_t, 16> halfwords_; | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
|    std::array<std::uint16_t, 10> parameters_ {0}; | ||||
|    std::array<std::uint16_t, 16> halfwords_ {0}; | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| }; | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlockImpl::halfword(size_t i) | ||||
| std::uint16_t ProductDescriptionBlock::Impl::halfword(std::size_t i) | ||||
| { | ||||
|    // Halfwords start at halfword 31
 | ||||
|    return halfwords_[i - 31]; | ||||
|    // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
 | ||||
|    return halfwords_.at(i - 31); | ||||
| } | ||||
| 
 | ||||
| ProductDescriptionBlock::ProductDescriptionBlock() : | ||||
|     p(std::make_unique<ProductDescriptionBlockImpl>()) | ||||
| ProductDescriptionBlock::ProductDescriptionBlock() : p(std::make_unique<Impl>()) | ||||
| { | ||||
| } | ||||
| ProductDescriptionBlock::~ProductDescriptionBlock() = default; | ||||
|  | @ -171,102 +156,104 @@ ProductDescriptionBlock::ProductDescriptionBlock( | |||
| ProductDescriptionBlock& ProductDescriptionBlock::operator=( | ||||
|    ProductDescriptionBlock&&) noexcept = default; | ||||
| 
 | ||||
| int16_t ProductDescriptionBlock::block_divider() const | ||||
| std::int16_t ProductDescriptionBlock::block_divider() const | ||||
| { | ||||
|    return p->blockDivider_; | ||||
| } | ||||
| 
 | ||||
| float ProductDescriptionBlock::latitude_of_radar() const | ||||
| { | ||||
|    return p->latitudeOfRadar_ * 0.001f; | ||||
|    static constexpr float kScale = 0.001f; | ||||
|    return static_cast<float>(p->latitudeOfRadar_) * kScale; | ||||
| } | ||||
| 
 | ||||
| float ProductDescriptionBlock::longitude_of_radar() const | ||||
| { | ||||
|    return p->longitudeOfRadar_ * 0.001f; | ||||
|    static constexpr float kScale = 0.001f; | ||||
|    return static_cast<float>(p->longitudeOfRadar_) * kScale; | ||||
| } | ||||
| 
 | ||||
| int16_t ProductDescriptionBlock::height_of_radar() const | ||||
| std::int16_t ProductDescriptionBlock::height_of_radar() const | ||||
| { | ||||
|    return p->heightOfRadar_; | ||||
| } | ||||
| 
 | ||||
| int16_t ProductDescriptionBlock::product_code() const | ||||
| std::int16_t ProductDescriptionBlock::product_code() const | ||||
| { | ||||
|    return p->productCode_; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::operational_mode() const | ||||
| std::uint16_t ProductDescriptionBlock::operational_mode() const | ||||
| { | ||||
|    return p->operationalMode_; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::volume_coverage_pattern() const | ||||
| std::uint16_t ProductDescriptionBlock::volume_coverage_pattern() const | ||||
| { | ||||
|    return p->volumeCoveragePattern_; | ||||
| } | ||||
| 
 | ||||
| int16_t ProductDescriptionBlock::sequence_number() const | ||||
| std::int16_t ProductDescriptionBlock::sequence_number() const | ||||
| { | ||||
|    return p->sequenceNumber_; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::volume_scan_number() const | ||||
| std::uint16_t ProductDescriptionBlock::volume_scan_number() const | ||||
| { | ||||
|    return p->volumeScanNumber_; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::volume_scan_date() const | ||||
| std::uint16_t ProductDescriptionBlock::volume_scan_date() const | ||||
| { | ||||
|    return p->volumeScanDate_; | ||||
| } | ||||
| 
 | ||||
| uint32_t ProductDescriptionBlock::volume_scan_start_time() const | ||||
| std::uint32_t ProductDescriptionBlock::volume_scan_start_time() const | ||||
| { | ||||
|    return p->volumeScanStartTime_; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::generation_date_of_product() const | ||||
| std::uint16_t ProductDescriptionBlock::generation_date_of_product() const | ||||
| { | ||||
|    return p->generationDateOfProduct_; | ||||
| } | ||||
| 
 | ||||
| uint32_t ProductDescriptionBlock::generation_time_of_product() const | ||||
| std::uint32_t ProductDescriptionBlock::generation_time_of_product() const | ||||
| { | ||||
|    return p->generationTimeOfProduct_; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::elevation_number() const | ||||
| std::uint16_t ProductDescriptionBlock::elevation_number() const | ||||
| { | ||||
|    return p->elevationNumber_; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::data_level_threshold(size_t i) const | ||||
| std::uint16_t ProductDescriptionBlock::data_level_threshold(std::size_t i) const | ||||
| { | ||||
|    return p->halfwords_[i]; | ||||
|    return p->halfwords_.at(i); | ||||
| } | ||||
| 
 | ||||
| uint8_t ProductDescriptionBlock::version() const | ||||
| std::uint8_t ProductDescriptionBlock::version() const | ||||
| { | ||||
|    return p->version_; | ||||
| } | ||||
| 
 | ||||
| uint8_t ProductDescriptionBlock::spot_blank() const | ||||
| std::uint8_t ProductDescriptionBlock::spot_blank() const | ||||
| { | ||||
|    return p->spotBlank_; | ||||
| } | ||||
| 
 | ||||
| uint32_t ProductDescriptionBlock::offset_to_symbology() const | ||||
| std::uint32_t ProductDescriptionBlock::offset_to_symbology() const | ||||
| { | ||||
|    return p->offsetToSymbology_; | ||||
| } | ||||
| 
 | ||||
| uint32_t ProductDescriptionBlock::offset_to_graphic() const | ||||
| std::uint32_t ProductDescriptionBlock::offset_to_graphic() const | ||||
| { | ||||
|    return p->offsetToGraphic_; | ||||
| } | ||||
| 
 | ||||
| uint32_t ProductDescriptionBlock::offset_to_tabular() const | ||||
| std::uint32_t ProductDescriptionBlock::offset_to_tabular() const | ||||
| { | ||||
|    return p->offsetToTabular_; | ||||
| } | ||||
|  | @ -276,14 +263,14 @@ float ProductDescriptionBlock::range() const | |||
|    return range_raw(); | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::range_raw() const | ||||
| std::uint16_t ProductDescriptionBlock::range_raw() const | ||||
| { | ||||
|    uint16_t range = 0; | ||||
|    std::uint16_t range = 0; | ||||
| 
 | ||||
|    auto it = rangeMap_.find(p->productCode_); | ||||
|    if (it != rangeMap_.cend()) | ||||
|    { | ||||
|       range = static_cast<uint16_t>(it->second); | ||||
|       range = static_cast<std::uint16_t>(it->second); | ||||
|    } | ||||
| 
 | ||||
|    return range; | ||||
|  | @ -291,17 +278,18 @@ uint16_t ProductDescriptionBlock::range_raw() const | |||
| 
 | ||||
| float ProductDescriptionBlock::x_resolution() const | ||||
| { | ||||
|    return x_resolution_raw() * 0.001f; | ||||
|    static constexpr float kScale = 0.001f; | ||||
|    return static_cast<float>(x_resolution_raw()) * kScale; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::x_resolution_raw() const | ||||
| std::uint16_t ProductDescriptionBlock::x_resolution_raw() const | ||||
| { | ||||
|    uint16_t xResolution = 0; | ||||
|    std::uint16_t xResolution = 0; | ||||
| 
 | ||||
|    auto it = xResolutionMap_.find(p->productCode_); | ||||
|    if (it != xResolutionMap_.cend()) | ||||
|    { | ||||
|       xResolution = static_cast<uint16_t>(it->second); | ||||
|       xResolution = static_cast<std::uint16_t>(it->second); | ||||
|    } | ||||
| 
 | ||||
|    return xResolution; | ||||
|  | @ -309,25 +297,28 @@ uint16_t ProductDescriptionBlock::x_resolution_raw() const | |||
| 
 | ||||
| float ProductDescriptionBlock::y_resolution() const | ||||
| { | ||||
|    return y_resolution_raw() * 0.001f; | ||||
|    static constexpr float kScale = 0.001f; | ||||
|    return static_cast<float>(y_resolution_raw()) * kScale; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::y_resolution_raw() const | ||||
| std::uint16_t ProductDescriptionBlock::y_resolution_raw() const | ||||
| { | ||||
|    uint16_t yResolution = 0; | ||||
|    std::uint16_t yResolution = 0; | ||||
| 
 | ||||
|    auto it = yResolutionMap_.find(p->productCode_); | ||||
|    if (it != yResolutionMap_.cend()) | ||||
|    { | ||||
|       yResolution = static_cast<uint16_t>(it->second); | ||||
|       yResolution = static_cast<std::uint16_t>(it->second); | ||||
|    } | ||||
| 
 | ||||
|    return yResolution; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::threshold() const | ||||
| std::uint16_t ProductDescriptionBlock::threshold() const | ||||
| { | ||||
|    uint16_t threshold = 1; | ||||
|    std::uint16_t threshold = 1; | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|  | @ -384,6 +375,8 @@ uint16_t ProductDescriptionBlock::threshold() const | |||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return threshold; | ||||
| } | ||||
| 
 | ||||
|  | @ -391,6 +384,8 @@ float ProductDescriptionBlock::offset() const | |||
| { | ||||
|    float offset = 0.0f; | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 32: | ||||
|  | @ -406,7 +401,8 @@ float ProductDescriptionBlock::offset() const | |||
|    case 186: | ||||
|    case 193: | ||||
|    case 195: | ||||
|       offset = static_cast<int16_t>(p->halfword(31)) * 0.1f; | ||||
|       offset = | ||||
|          static_cast<float>(static_cast<std::int16_t>(p->halfword(31))) * 0.1f; | ||||
|       break; | ||||
| 
 | ||||
|    case 134: | ||||
|  | @ -414,7 +410,7 @@ float ProductDescriptionBlock::offset() const | |||
|       break; | ||||
| 
 | ||||
|    case 135: | ||||
|       offset = static_cast<int16_t>(p->halfword(33)); | ||||
|       offset = static_cast<std::int16_t>(p->halfword(33)); | ||||
|       break; | ||||
| 
 | ||||
|    case 159: | ||||
|  | @ -435,6 +431,8 @@ float ProductDescriptionBlock::offset() const | |||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return offset; | ||||
| } | ||||
| 
 | ||||
|  | @ -442,6 +440,8 @@ float ProductDescriptionBlock::scale() const | |||
| { | ||||
|    float scale = 1.0f; | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 32: | ||||
|  | @ -456,11 +456,11 @@ float ProductDescriptionBlock::scale() const | |||
|    case 186: | ||||
|    case 193: | ||||
|    case 195: | ||||
|       scale = p->halfword(32) * 0.1f; | ||||
|       scale = static_cast<float>(p->halfword(32)) * 0.1f; | ||||
|       break; | ||||
| 
 | ||||
|    case 81: | ||||
|       scale = p->halfword(32) * 0.001f; | ||||
|       scale = static_cast<float>(p->halfword(32)) * 0.001f; | ||||
|       break; | ||||
| 
 | ||||
|    case 134: | ||||
|  | @ -472,7 +472,7 @@ float ProductDescriptionBlock::scale() const | |||
|       break; | ||||
| 
 | ||||
|    case 138: | ||||
|       scale = p->halfword(32) * 0.01f; | ||||
|       scale = static_cast<float>(p->halfword(32)) * 0.01f; | ||||
|       break; | ||||
| 
 | ||||
|    case 159: | ||||
|  | @ -493,12 +493,16 @@ float ProductDescriptionBlock::scale() const | |||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return scale; | ||||
| } | ||||
| 
 | ||||
| uint16_t ProductDescriptionBlock::number_of_levels() const | ||||
| std::uint16_t ProductDescriptionBlock::number_of_levels() const | ||||
| { | ||||
|    uint16_t numberOfLevels = 16u; | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    std::uint16_t numberOfLevels = 16u; | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|  | @ -613,6 +617,8 @@ uint16_t ProductDescriptionBlock::number_of_levels() const | |||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return numberOfLevels; | ||||
| } | ||||
| 
 | ||||
|  | @ -620,6 +626,8 @@ std::uint16_t ProductDescriptionBlock::log_start() const | |||
| { | ||||
|    std::uint16_t logStart = std::numeric_limits<std::uint16_t>::max(); | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 134: | ||||
|  | @ -630,6 +638,8 @@ std::uint16_t ProductDescriptionBlock::log_start() const | |||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return logStart; | ||||
| } | ||||
| 
 | ||||
|  | @ -637,6 +647,8 @@ float ProductDescriptionBlock::log_offset() const | |||
| { | ||||
|    float logOffset = 0.0f; | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 134: | ||||
|  | @ -647,6 +659,8 @@ float ProductDescriptionBlock::log_offset() const | |||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return logOffset; | ||||
| } | ||||
| 
 | ||||
|  | @ -654,6 +668,8 @@ float ProductDescriptionBlock::log_scale() const | |||
| { | ||||
|    float logScale = 1.0f; | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 134: | ||||
|  | @ -664,6 +680,8 @@ float ProductDescriptionBlock::log_scale() const | |||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return logScale; | ||||
| } | ||||
| 
 | ||||
|  | @ -682,6 +700,8 @@ float ProductDescriptionBlock::gr_scale() const | |||
| 
 | ||||
| std::uint8_t ProductDescriptionBlock::data_mask() const | ||||
| { | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    std::uint8_t dataMask = 0xff; | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|  | @ -694,6 +714,8 @@ std::uint8_t ProductDescriptionBlock::data_mask() const | |||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return dataMask; | ||||
| } | ||||
| 
 | ||||
|  | @ -701,6 +723,8 @@ std::uint8_t ProductDescriptionBlock::topped_mask() const | |||
| { | ||||
|    std::uint8_t toppedMask = 0x00; | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 135: | ||||
|  | @ -711,6 +735,8 @@ std::uint8_t ProductDescriptionBlock::topped_mask() const | |||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return toppedMask; | ||||
| } | ||||
| 
 | ||||
|  | @ -722,7 +748,7 @@ units::angle::degrees<double> ProductDescriptionBlock::elevation() const | |||
|    { | ||||
|       // Elevation is given in tenths of a degree
 | ||||
|       // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
 | ||||
|       elevation = static_cast<int16_t>(p->parameters_[2]) * 0.1; | ||||
|       elevation = static_cast<std::int16_t>(p->parameters_[2]) * 0.1; | ||||
|    } | ||||
| 
 | ||||
|    return units::angle::degrees<double> {elevation}; | ||||
|  | @ -737,11 +763,15 @@ bool ProductDescriptionBlock::IsCompressionEnabled() const | |||
| { | ||||
|    bool isCompressed = false; | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    if (compressedProducts_.contains(p->productCode_)) | ||||
|    { | ||||
|       isCompressed = (p->parameters_[7] == 1u); | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return isCompressed; | ||||
| } | ||||
| 
 | ||||
|  | @ -750,7 +780,7 @@ bool ProductDescriptionBlock::IsDataLevelCoded() const | |||
|    return !uncodedDataLevelProducts_.contains(p->productCode_); | ||||
| } | ||||
| 
 | ||||
| size_t ProductDescriptionBlock::data_size() const | ||||
| std::size_t ProductDescriptionBlock::data_size() const | ||||
| { | ||||
|    return SIZE; | ||||
| } | ||||
|  | @ -761,6 +791,8 @@ bool ProductDescriptionBlock::Parse(std::istream& is) | |||
| 
 | ||||
|    const std::streampos blockStart = is.tellg(); | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    is.read(reinterpret_cast<char*>(&p->blockDivider_), 2);            // 10
 | ||||
|    is.read(reinterpret_cast<char*>(&p->latitudeOfRadar_), 4);         // 11-12
 | ||||
|    is.read(reinterpret_cast<char*>(&p->longitudeOfRadar_), 4);        // 13-14
 | ||||
|  | @ -774,27 +806,31 @@ bool ProductDescriptionBlock::Parse(std::istream& is) | |||
|    is.read(reinterpret_cast<char*>(&p->volumeScanStartTime_), 4);     // 22-23
 | ||||
|    is.read(reinterpret_cast<char*>(&p->generationDateOfProduct_), 2); // 24
 | ||||
|    is.read(reinterpret_cast<char*>(&p->generationTimeOfProduct_), 4); // 25-26
 | ||||
|    is.read(reinterpret_cast<char*>(&p->parameters_[0]), 2 * 2);       // 27-28
 | ||||
|    is.read(reinterpret_cast<char*>(&p->elevationNumber_), 2);         // 29
 | ||||
|    is.read(reinterpret_cast<char*>(&p->parameters_[2]), 2);           // 30
 | ||||
|    is.read(reinterpret_cast<char*>(&p->halfwords_[0]), 16 * 2);       // 31-46
 | ||||
|    is.read(reinterpret_cast<char*>(&p->parameters_[3]), 7 * 2);       // 47-53
 | ||||
|    is.read(reinterpret_cast<char*>(&p->version_), 1);                 // 54
 | ||||
|    is.read(reinterpret_cast<char*>(&p->spotBlank_), 1);               // 54
 | ||||
|    is.read(reinterpret_cast<char*>(&p->offsetToSymbology_), 4);       // 55-56
 | ||||
|    is.read(reinterpret_cast<char*>(&p->offsetToGraphic_), 4);         // 57-58
 | ||||
|    is.read(reinterpret_cast<char*>(&p->offsetToTabular_), 4);         // 59-60
 | ||||
|    is.read(reinterpret_cast<char*>(&p->parameters_[0]), | ||||
|            static_cast<std::streamsize>(2 * 2));              // 27-28
 | ||||
|    is.read(reinterpret_cast<char*>(&p->elevationNumber_), 2); // 29
 | ||||
|    is.read(reinterpret_cast<char*>(&p->parameters_[2]), 2);   // 30
 | ||||
|    is.read(reinterpret_cast<char*>(&p->halfwords_[0]), | ||||
|            static_cast<std::streamsize>(16 * 2)); // 31-46
 | ||||
|    is.read(reinterpret_cast<char*>(&p->parameters_[3]), | ||||
|            static_cast<std::streamsize>(7 * 2));                // 47-53
 | ||||
|    is.read(reinterpret_cast<char*>(&p->version_), 1);           // 54
 | ||||
|    is.read(reinterpret_cast<char*>(&p->spotBlank_), 1);         // 54
 | ||||
|    is.read(reinterpret_cast<char*>(&p->offsetToSymbology_), 4); // 55-56
 | ||||
|    is.read(reinterpret_cast<char*>(&p->offsetToGraphic_), 4);   // 57-58
 | ||||
|    is.read(reinterpret_cast<char*>(&p->offsetToTabular_), 4);   // 59-60
 | ||||
| 
 | ||||
|    p->blockDivider_            = ntohs(p->blockDivider_); | ||||
|    p->latitudeOfRadar_         = ntohl(p->latitudeOfRadar_); | ||||
|    p->longitudeOfRadar_        = ntohl(p->longitudeOfRadar_); | ||||
|    p->heightOfRadar_           = ntohs(p->heightOfRadar_); | ||||
|    p->productCode_             = ntohs(p->productCode_); | ||||
|    p->operationalMode_         = ntohs(p->operationalMode_); | ||||
|    p->volumeCoveragePattern_   = ntohs(p->volumeCoveragePattern_); | ||||
|    p->sequenceNumber_          = ntohs(p->sequenceNumber_); | ||||
|    p->volumeScanNumber_        = ntohs(p->volumeScanNumber_); | ||||
|    p->volumeScanDate_          = ntohs(p->volumeScanDate_); | ||||
|    p->blockDivider_    = static_cast<std::int16_t>(ntohs(p->blockDivider_)); | ||||
|    p->latitudeOfRadar_ = static_cast<std::int32_t>(ntohl(p->latitudeOfRadar_)); | ||||
|    p->longitudeOfRadar_ = | ||||
|       static_cast<std::int32_t>(ntohl(p->longitudeOfRadar_)); | ||||
|    p->heightOfRadar_   = static_cast<std::int16_t>(ntohs(p->heightOfRadar_)); | ||||
|    p->productCode_     = static_cast<std::int16_t>(ntohs(p->productCode_)); | ||||
|    p->operationalMode_ = ntohs(p->operationalMode_); | ||||
|    p->volumeCoveragePattern_ = ntohs(p->volumeCoveragePattern_); | ||||
|    p->sequenceNumber_   = static_cast<std::int16_t>(ntohs(p->sequenceNumber_)); | ||||
|    p->volumeScanNumber_ = ntohs(p->volumeScanNumber_); | ||||
|    p->volumeScanDate_   = ntohs(p->volumeScanDate_); | ||||
|    p->volumeScanStartTime_     = ntohl(p->volumeScanStartTime_); | ||||
|    p->generationDateOfProduct_ = ntohs(p->generationDateOfProduct_); | ||||
|    p->generationTimeOfProduct_ = ntohl(p->generationTimeOfProduct_); | ||||
|  | @ -827,6 +863,8 @@ bool ProductDescriptionBlock::Parse(std::istream& is) | |||
|       } | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    if (blockValid) | ||||
|    { | ||||
|       logger_->trace("Product code: {}", p->productCode_); | ||||
|  | @ -844,6 +882,8 @@ bool ProductDescriptionBlock::Parse(std::istream& is) | |||
| std::optional<DataLevelCode> | ||||
| ProductDescriptionBlock::data_level_code(std::uint8_t level) const | ||||
| { | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 32: | ||||
|  | @ -1033,11 +1073,11 @@ ProductDescriptionBlock::data_level_code(std::uint8_t level) const | |||
|    if (number_of_levels() <= 16 && level < 16 && | ||||
|        !uncodedDataLevelProducts_.contains(p->productCode_)) | ||||
|    { | ||||
|       uint16_t th = data_level_threshold(level); | ||||
|       std::uint16_t th = data_level_threshold(level); | ||||
|       if ((th & 0x8000u)) | ||||
|       { | ||||
|          // If bit 0 is one, then the LSB is coded
 | ||||
|          uint16_t lsb = th & 0x00ffu; | ||||
|          std::uint16_t lsb = th & 0x00ffu; | ||||
| 
 | ||||
|          switch (lsb) | ||||
|          { | ||||
|  | @ -1081,6 +1121,8 @@ ProductDescriptionBlock::data_level_code(std::uint8_t level) const | |||
|       } | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    return std::nullopt; | ||||
| } | ||||
| 
 | ||||
|  | @ -1099,6 +1141,8 @@ ProductDescriptionBlock::data_value(std::uint8_t level) const | |||
| 
 | ||||
|    std::optional<float> f = std::nullopt; | ||||
| 
 | ||||
|    // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    // Different products use different scale/offset formulas
 | ||||
|    if (numberOfLevels > 16 || | ||||
|        uncodedDataLevelProducts_.contains(p->productCode_)) | ||||
|  | @ -1116,17 +1160,17 @@ ProductDescriptionBlock::data_value(std::uint8_t level) const | |||
|       case 174: | ||||
|       case 175: | ||||
|       case 176: | ||||
|          f = (level - dataOffset) / dataScale; | ||||
|          f = (static_cast<float>(level) - dataOffset) / dataScale; | ||||
|          break; | ||||
| 
 | ||||
|       case 134: | ||||
|          if (level < log_start()) | ||||
|          { | ||||
|             f = (level - dataOffset) / dataScale; | ||||
|             f = (static_cast<float>(level) - dataOffset) / dataScale; | ||||
|          } | ||||
|          else | ||||
|          { | ||||
|             f = expf((level - log_offset()) / log_scale()); | ||||
|             f = expf((static_cast<float>(level) - log_offset()) / log_scale()); | ||||
|          } | ||||
|          break; | ||||
| 
 | ||||
|  | @ -1135,7 +1179,7 @@ ProductDescriptionBlock::data_value(std::uint8_t level) const | |||
|          [[fallthrough]]; | ||||
| 
 | ||||
|       default: | ||||
|          f = level * dataScale + dataOffset; | ||||
|          f = static_cast<float>(level) * dataScale + dataOffset; | ||||
|          break; | ||||
|       } | ||||
|    } | ||||
|  | @ -1175,6 +1219,8 @@ ProductDescriptionBlock::data_value(std::uint8_t level) const | |||
|       } | ||||
|    } | ||||
| 
 | ||||
|    // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
 | ||||
| 
 | ||||
|    // Scale for GR compatibility
 | ||||
|    if (f.has_value()) | ||||
|    { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat