mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 13:00:05 +00:00 
			
		
		
		
	Exposing select level 3 file blocks
This commit is contained in:
		
							parent
							
								
									01d24d70b8
								
							
						
					
					
						commit
						9073ec706b
					
				
					 4 changed files with 60 additions and 25 deletions
				
			
		|  | @ -1,5 +1,8 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include <scwx/wsr88d/rpg/level3_message_header.hpp> | ||||||
|  | #include <scwx/wsr88d/rpg/product_symbology_block.hpp> | ||||||
|  | 
 | ||||||
| #include <memory> | #include <memory> | ||||||
| #include <string> | #include <string> | ||||||
| 
 | 
 | ||||||
|  | @ -22,6 +25,9 @@ public: | ||||||
|    Level3File(Level3File&&) noexcept; |    Level3File(Level3File&&) noexcept; | ||||||
|    Level3File& operator=(Level3File&&) noexcept; |    Level3File& operator=(Level3File&&) noexcept; | ||||||
| 
 | 
 | ||||||
|  |    std::shared_ptr<rpg::Level3MessageHeader>   message_header() const; | ||||||
|  |    std::shared_ptr<rpg::ProductSymbologyBlock> product_symbology_block() const; | ||||||
|  | 
 | ||||||
|    bool LoadFile(const std::string& filename); |    bool LoadFile(const std::string& filename); | ||||||
|    bool LoadData(std::istream& is); |    bool LoadData(std::istream& is); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <scwx/wsr88d/message.hpp> | #include <scwx/wsr88d/message.hpp> | ||||||
|  | #include <scwx/wsr88d/rpg/packet.hpp> | ||||||
| 
 | 
 | ||||||
| #include <cstdint> | #include <cstdint> | ||||||
| #include <memory> | #include <memory> | ||||||
|  | @ -27,6 +28,9 @@ public: | ||||||
|    ProductSymbologyBlock& operator=(ProductSymbologyBlock&&) noexcept; |    ProductSymbologyBlock& operator=(ProductSymbologyBlock&&) noexcept; | ||||||
| 
 | 
 | ||||||
|    int16_t  block_divider() const; |    int16_t  block_divider() const; | ||||||
|  |    uint16_t number_of_layers() const; | ||||||
|  | 
 | ||||||
|  |    const std::vector<std::shared_ptr<Packet>>& packet_list(uint16_t i) const; | ||||||
| 
 | 
 | ||||||
|    size_t data_size() const override; |    size_t data_size() const override; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -39,17 +39,14 @@ public: | ||||||
|    bool LoadFileData(std::istream& is); |    bool LoadFileData(std::istream& is); | ||||||
|    bool LoadBlocks(std::istream& is); |    bool LoadBlocks(std::istream& is); | ||||||
| 
 | 
 | ||||||
|    rpg::WmoHeader                  wmoHeader_; |    std::shared_ptr<rpg::WmoHeader>               wmoHeader_; | ||||||
|    std::shared_ptr<rpg::CcbHeader>               ccbHeader_; |    std::shared_ptr<rpg::CcbHeader>               ccbHeader_; | ||||||
|    std::shared_ptr<rpg::WmoHeader>               innerHeader_; |    std::shared_ptr<rpg::WmoHeader>               innerHeader_; | ||||||
|    rpg::Level3MessageHeader        messageHeader_; |    std::shared_ptr<rpg::Level3MessageHeader>     messageHeader_; | ||||||
|    rpg::ProductDescriptionBlock    descriptionBlock_; |    std::shared_ptr<rpg::ProductDescriptionBlock> descriptionBlock_; | ||||||
| 
 |  | ||||||
|    std::shared_ptr<rpg::ProductSymbologyBlock>   symbologyBlock_; |    std::shared_ptr<rpg::ProductSymbologyBlock>   symbologyBlock_; | ||||||
|    std::shared_ptr<void>                         graphicBlock_; |    std::shared_ptr<void>                         graphicBlock_; | ||||||
|    std::shared_ptr<void>                         tabularBlock_; |    std::shared_ptr<void>                         tabularBlock_; | ||||||
| 
 |  | ||||||
|    size_t numRecords_; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Level3File::Level3File() : p(std::make_unique<Level3FileImpl>()) {} | Level3File::Level3File() : p(std::make_unique<Level3FileImpl>()) {} | ||||||
|  | @ -58,6 +55,17 @@ Level3File::~Level3File() = default; | ||||||
| Level3File::Level3File(Level3File&&) noexcept = default; | Level3File::Level3File(Level3File&&) noexcept = default; | ||||||
| Level3File& Level3File::operator=(Level3File&&) noexcept = default; | Level3File& Level3File::operator=(Level3File&&) noexcept = default; | ||||||
| 
 | 
 | ||||||
|  | std::shared_ptr<rpg::Level3MessageHeader> Level3File::message_header() const | ||||||
|  | { | ||||||
|  |    return p->messageHeader_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::shared_ptr<rpg::ProductSymbologyBlock> | ||||||
|  | Level3File::product_symbology_block() const | ||||||
|  | { | ||||||
|  |    return p->symbologyBlock_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| bool Level3File::LoadFile(const std::string& filename) | bool Level3File::LoadFile(const std::string& filename) | ||||||
| { | { | ||||||
|    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadFile(" << filename << ")"; |    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadFile(" << filename << ")"; | ||||||
|  | @ -83,18 +91,20 @@ bool Level3File::LoadData(std::istream& is) | ||||||
| { | { | ||||||
|    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Data"; |    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Data"; | ||||||
| 
 | 
 | ||||||
|    bool dataValid = p->wmoHeader_.Parse(is); |    p->wmoHeader_ = std::make_shared<rpg::WmoHeader>(); | ||||||
|  | 
 | ||||||
|  |    bool dataValid = p->wmoHeader_->Parse(is); | ||||||
| 
 | 
 | ||||||
|    if (dataValid) |    if (dataValid) | ||||||
|    { |    { | ||||||
|       BOOST_LOG_TRIVIAL(debug) |       BOOST_LOG_TRIVIAL(debug) | ||||||
|          << logPrefix_ << "Data Type: " << p->wmoHeader_.data_type(); |          << logPrefix_ << "Data Type: " << p->wmoHeader_->data_type(); | ||||||
|       BOOST_LOG_TRIVIAL(debug) |       BOOST_LOG_TRIVIAL(debug) | ||||||
|          << logPrefix_ << "ICAO:      " << p->wmoHeader_.icao(); |          << logPrefix_ << "ICAO:      " << p->wmoHeader_->icao(); | ||||||
|       BOOST_LOG_TRIVIAL(debug) |       BOOST_LOG_TRIVIAL(debug) | ||||||
|          << logPrefix_ << "Date/Time: " << p->wmoHeader_.date_time(); |          << logPrefix_ << "Date/Time: " << p->wmoHeader_->date_time(); | ||||||
|       BOOST_LOG_TRIVIAL(debug) |       BOOST_LOG_TRIVIAL(debug) | ||||||
|          << logPrefix_ << "Category:  " << p->wmoHeader_.product_category(); |          << logPrefix_ << "Category:  " << p->wmoHeader_->product_category(); | ||||||
| 
 | 
 | ||||||
|       // If the header is compressed
 |       // If the header is compressed
 | ||||||
|       if (is.peek() == 0x78) |       if (is.peek() == 0x78) | ||||||
|  | @ -182,21 +192,25 @@ bool Level3FileImpl::DecompressFile(std::istream& is, std::stringstream& ss) | ||||||
| 
 | 
 | ||||||
| bool Level3FileImpl::LoadFileData(std::istream& is) | bool Level3FileImpl::LoadFileData(std::istream& is) | ||||||
| { | { | ||||||
|    bool dataValid = messageHeader_.Parse(is); |    messageHeader_ = std::make_shared<rpg::Level3MessageHeader>(); | ||||||
|  | 
 | ||||||
|  |    bool dataValid = messageHeader_->Parse(is); | ||||||
| 
 | 
 | ||||||
|    if (dataValid) |    if (dataValid) | ||||||
|    { |    { | ||||||
|       BOOST_LOG_TRIVIAL(debug) |       BOOST_LOG_TRIVIAL(debug) | ||||||
|          << logPrefix_ << "Code:      " << messageHeader_.message_code(); |          << logPrefix_ << "Code:      " << messageHeader_->message_code(); | ||||||
| 
 | 
 | ||||||
|       dataValid = descriptionBlock_.Parse(is); |       descriptionBlock_ = std::make_shared<rpg::ProductDescriptionBlock>(); | ||||||
|  | 
 | ||||||
|  |       dataValid = descriptionBlock_->Parse(is); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    if (dataValid) |    if (dataValid) | ||||||
|    { |    { | ||||||
|       if (descriptionBlock_.IsCompressionEnabled()) |       if (descriptionBlock_->IsCompressionEnabled()) | ||||||
|       { |       { | ||||||
|          size_t messageLength = messageHeader_.length_of_message(); |          size_t messageLength = messageHeader_->length_of_message(); | ||||||
|          size_t prefixLength = |          size_t prefixLength = | ||||||
|             rpg::Level3MessageHeader::SIZE + rpg::ProductDescriptionBlock::SIZE; |             rpg::Level3MessageHeader::SIZE + rpg::ProductDescriptionBlock::SIZE; | ||||||
|          size_t recordSize = |          size_t recordSize = | ||||||
|  | @ -249,9 +263,9 @@ bool Level3FileImpl::LoadBlocks(std::istream& is) | ||||||
|       rpg::Level3MessageHeader::SIZE + rpg::ProductDescriptionBlock::SIZE; |       rpg::Level3MessageHeader::SIZE + rpg::ProductDescriptionBlock::SIZE; | ||||||
| 
 | 
 | ||||||
|    const size_t offsetToSymbology = |    const size_t offsetToSymbology = | ||||||
|       descriptionBlock_.offset_to_symbology() * 2u; |       descriptionBlock_->offset_to_symbology() * 2u; | ||||||
|    const size_t offsetToGraphic = descriptionBlock_.offset_to_graphic() * 2u; |    const size_t offsetToGraphic = descriptionBlock_->offset_to_graphic() * 2u; | ||||||
|    const size_t offsetToTabular = descriptionBlock_.offset_to_tabular() * 2u; |    const size_t offsetToTabular = descriptionBlock_->offset_to_tabular() * 2u; | ||||||
| 
 | 
 | ||||||
|    if (offsetToSymbology >= offsetBase) |    if (offsetToSymbology >= offsetBase) | ||||||
|    { |    { | ||||||
|  |  | ||||||
|  | @ -53,6 +53,17 @@ int16_t ProductSymbologyBlock::block_divider() const | ||||||
|    return p->blockDivider_; |    return p->blockDivider_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | uint16_t ProductSymbologyBlock::number_of_layers() const | ||||||
|  | { | ||||||
|  |    return p->numberOfLayers_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | const std::vector<std::shared_ptr<Packet>>& | ||||||
|  | ProductSymbologyBlock::packet_list(uint16_t i) const | ||||||
|  | { | ||||||
|  |    return p->layerList_[i]; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| size_t ProductSymbologyBlock::data_size() const | size_t ProductSymbologyBlock::data_size() const | ||||||
| { | { | ||||||
|    return p->lengthOfBlock_; |    return p->lengthOfBlock_; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat