mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:20:05 +00:00 
			
		
		
		
	Radar coded message stub
This commit is contained in:
		
							parent
							
								
									9b48db3d8d
								
							
						
					
					
						commit
						97ab1de94c
					
				
					 4 changed files with 159 additions and 0 deletions
				
			
		
							
								
								
									
										43
									
								
								wxdata/include/scwx/wsr88d/rpg/radar_coded_message.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								wxdata/include/scwx/wsr88d/rpg/radar_coded_message.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include <scwx/wsr88d/rpg/level3_message.hpp> | ||||||
|  | #include <scwx/wsr88d/rpg/product_description_block.hpp> | ||||||
|  | 
 | ||||||
|  | #include <cstdint> | ||||||
|  | #include <memory> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace wsr88d | ||||||
|  | { | ||||||
|  | namespace rpg | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | class RadarCodedMessageImpl; | ||||||
|  | 
 | ||||||
|  | class RadarCodedMessage : public Level3Message | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |    explicit RadarCodedMessage(); | ||||||
|  |    ~RadarCodedMessage(); | ||||||
|  | 
 | ||||||
|  |    RadarCodedMessage(const RadarCodedMessage&) = delete; | ||||||
|  |    RadarCodedMessage& operator=(const RadarCodedMessage&) = delete; | ||||||
|  | 
 | ||||||
|  |    RadarCodedMessage(RadarCodedMessage&&) noexcept; | ||||||
|  |    RadarCodedMessage& operator=(RadarCodedMessage&&) noexcept; | ||||||
|  | 
 | ||||||
|  |    std::shared_ptr<ProductDescriptionBlock> description_block() const; | ||||||
|  | 
 | ||||||
|  |    bool Parse(std::istream& is) override; | ||||||
|  | 
 | ||||||
|  |    static std::shared_ptr<RadarCodedMessage> | ||||||
|  |    Create(Level3MessageHeader&& header, std::istream& is); | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |    std::unique_ptr<RadarCodedMessageImpl> p; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | } // namespace rpg
 | ||||||
|  | } // namespace wsr88d
 | ||||||
|  | } // namespace scwx
 | ||||||
|  | @ -3,6 +3,7 @@ | ||||||
| #include <scwx/util/vectorbuf.hpp> | #include <scwx/util/vectorbuf.hpp> | ||||||
| #include <scwx/wsr88d/rpg/general_status_message.hpp> | #include <scwx/wsr88d/rpg/general_status_message.hpp> | ||||||
| #include <scwx/wsr88d/rpg/graphic_product_message.hpp> | #include <scwx/wsr88d/rpg/graphic_product_message.hpp> | ||||||
|  | #include <scwx/wsr88d/rpg/radar_coded_message.hpp> | ||||||
| #include <scwx/wsr88d/rpg/tabular_product_message.hpp> | #include <scwx/wsr88d/rpg/tabular_product_message.hpp> | ||||||
| 
 | 
 | ||||||
| #include <unordered_map> | #include <unordered_map> | ||||||
|  | @ -48,6 +49,7 @@ static const std::unordered_map<int16_t, CreateLevel3MessageFunction> // | ||||||
|             {65, GraphicProductMessage::Create}, |             {65, GraphicProductMessage::Create}, | ||||||
|             {66, GraphicProductMessage::Create}, |             {66, GraphicProductMessage::Create}, | ||||||
|             {67, GraphicProductMessage::Create}, |             {67, GraphicProductMessage::Create}, | ||||||
|  |             {74, RadarCodedMessage::Create}, | ||||||
|             {75, TabularProductMessage::Create}, |             {75, TabularProductMessage::Create}, | ||||||
|             {77, TabularProductMessage::Create}, |             {77, TabularProductMessage::Create}, | ||||||
|             {78, GraphicProductMessage::Create}, |             {78, GraphicProductMessage::Create}, | ||||||
|  |  | ||||||
							
								
								
									
										112
									
								
								wxdata/source/scwx/wsr88d/rpg/radar_coded_message.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								wxdata/source/scwx/wsr88d/rpg/radar_coded_message.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,112 @@ | ||||||
|  | #include <scwx/wsr88d/rpg/radar_coded_message.hpp> | ||||||
|  | 
 | ||||||
|  | #include <istream> | ||||||
|  | #include <string> | ||||||
|  | 
 | ||||||
|  | #include <boost/log/trivial.hpp> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace wsr88d | ||||||
|  | { | ||||||
|  | namespace rpg | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | static const std::string logPrefix_ = | ||||||
|  |    "[scwx::wsr88d::rpg::radar_coded_message] "; | ||||||
|  | 
 | ||||||
|  | class RadarCodedMessageImpl | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |    explicit RadarCodedMessageImpl() : | ||||||
|  |        descriptionBlock_ {0}, | ||||||
|  |        pupSiteIdentifier_ {}, | ||||||
|  |        productCategory_ {}, | ||||||
|  |        rdaSiteIdentifier_ {} | ||||||
|  |    { | ||||||
|  |    } | ||||||
|  |    ~RadarCodedMessageImpl() = default; | ||||||
|  | 
 | ||||||
|  |    bool LoadBlocks(std::istream& is); | ||||||
|  | 
 | ||||||
|  |    std::shared_ptr<ProductDescriptionBlock> descriptionBlock_; | ||||||
|  | 
 | ||||||
|  |    std::string pupSiteIdentifier_; | ||||||
|  |    std::string productCategory_; | ||||||
|  |    std::string rdaSiteIdentifier_; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | RadarCodedMessage::RadarCodedMessage() : | ||||||
|  |     p(std::make_unique<RadarCodedMessageImpl>()) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | RadarCodedMessage::~RadarCodedMessage() = default; | ||||||
|  | 
 | ||||||
|  | RadarCodedMessage::RadarCodedMessage(RadarCodedMessage&&) noexcept = default; | ||||||
|  | RadarCodedMessage& | ||||||
|  | RadarCodedMessage::operator=(RadarCodedMessage&&) noexcept = default; | ||||||
|  | 
 | ||||||
|  | std::shared_ptr<ProductDescriptionBlock> | ||||||
|  | RadarCodedMessage::description_block() const | ||||||
|  | { | ||||||
|  |    return p->descriptionBlock_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool RadarCodedMessage::Parse(std::istream& is) | ||||||
|  | { | ||||||
|  |    bool dataValid = true; | ||||||
|  | 
 | ||||||
|  |    const std::streampos dataStart = is.tellg(); | ||||||
|  | 
 | ||||||
|  |    p->descriptionBlock_ = std::make_shared<ProductDescriptionBlock>(); | ||||||
|  |    dataValid            = p->descriptionBlock_->Parse(is); | ||||||
|  | 
 | ||||||
|  |    if (dataValid) | ||||||
|  |    { | ||||||
|  |       dataValid = p->LoadBlocks(is); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    const std::streampos dataEnd = is.tellg(); | ||||||
|  |    if (!ValidateMessage(is, dataEnd - dataStart)) | ||||||
|  |    { | ||||||
|  |       dataValid = false; | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    return dataValid; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool RadarCodedMessageImpl::LoadBlocks(std::istream& is) | ||||||
|  | { | ||||||
|  |    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Blocks"; | ||||||
|  | 
 | ||||||
|  |    pupSiteIdentifier_.resize(4); | ||||||
|  |    productCategory_.resize(5); | ||||||
|  |    rdaSiteIdentifier_.resize(4); | ||||||
|  | 
 | ||||||
|  |    is.read(pupSiteIdentifier_.data(), 4); | ||||||
|  |    is.seekg(1, std::ios_base::cur); | ||||||
|  |    is.read(productCategory_.data(), 5); | ||||||
|  |    is.seekg(1, std::ios_base::cur); | ||||||
|  |    is.read(rdaSiteIdentifier_.data(), 4); | ||||||
|  | 
 | ||||||
|  |    return !is.eof(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::shared_ptr<RadarCodedMessage> | ||||||
|  | RadarCodedMessage::Create(Level3MessageHeader&& header, std::istream& is) | ||||||
|  | { | ||||||
|  |    std::shared_ptr<RadarCodedMessage> message = | ||||||
|  |       std::make_shared<RadarCodedMessage>(); | ||||||
|  |    message->set_header(std::move(header)); | ||||||
|  | 
 | ||||||
|  |    if (!message->Parse(is)) | ||||||
|  |    { | ||||||
|  |       message.reset(); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    return message; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } // namespace rpg
 | ||||||
|  | } // namespace wsr88d
 | ||||||
|  | } // namespace scwx
 | ||||||
|  | @ -69,6 +69,7 @@ set(HDR_WSR88D_RPG include/scwx/wsr88d/rpg/ccb_header.hpp | ||||||
|                    include/scwx/wsr88d/rpg/precipitation_rate_data_array_packet.hpp |                    include/scwx/wsr88d/rpg/precipitation_rate_data_array_packet.hpp | ||||||
|                    include/scwx/wsr88d/rpg/product_description_block.hpp |                    include/scwx/wsr88d/rpg/product_description_block.hpp | ||||||
|                    include/scwx/wsr88d/rpg/product_symbology_block.hpp |                    include/scwx/wsr88d/rpg/product_symbology_block.hpp | ||||||
|  |                    include/scwx/wsr88d/rpg/radar_coded_message.hpp | ||||||
|                    include/scwx/wsr88d/rpg/radial_data_packet.hpp |                    include/scwx/wsr88d/rpg/radial_data_packet.hpp | ||||||
|                    include/scwx/wsr88d/rpg/raster_data_packet.hpp |                    include/scwx/wsr88d/rpg/raster_data_packet.hpp | ||||||
|                    include/scwx/wsr88d/rpg/scit_forecast_data_packet.hpp |                    include/scwx/wsr88d/rpg/scit_forecast_data_packet.hpp | ||||||
|  | @ -107,6 +108,7 @@ set(SRC_WSR88D_RPG source/scwx/wsr88d/rpg/ccb_header.cpp | ||||||
|                    source/scwx/wsr88d/rpg/precipitation_rate_data_array_packet.cpp |                    source/scwx/wsr88d/rpg/precipitation_rate_data_array_packet.cpp | ||||||
|                    source/scwx/wsr88d/rpg/product_description_block.cpp |                    source/scwx/wsr88d/rpg/product_description_block.cpp | ||||||
|                    source/scwx/wsr88d/rpg/product_symbology_block.cpp |                    source/scwx/wsr88d/rpg/product_symbology_block.cpp | ||||||
|  |                    source/scwx/wsr88d/rpg/radar_coded_message.cpp | ||||||
|                    source/scwx/wsr88d/rpg/radial_data_packet.cpp |                    source/scwx/wsr88d/rpg/radial_data_packet.cpp | ||||||
|                    source/scwx/wsr88d/rpg/raster_data_packet.cpp |                    source/scwx/wsr88d/rpg/raster_data_packet.cpp | ||||||
|                    source/scwx/wsr88d/rpg/scit_forecast_data_packet.cpp |                    source/scwx/wsr88d/rpg/scit_forecast_data_packet.cpp | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat