mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 12:40:06 +00:00 
			
		
		
		
	Exposing additional data from text products and messages
This commit is contained in:
		
							parent
							
								
									917926a0ec
								
							
						
					
					
						commit
						3ae001c3b9
					
				
					 4 changed files with 100 additions and 60 deletions
				
			
		|  | @ -25,6 +25,7 @@ public: | ||||||
|    TextProductFile& operator=(TextProductFile&&) noexcept; |    TextProductFile& operator=(TextProductFile&&) noexcept; | ||||||
| 
 | 
 | ||||||
|    size_t                                           message_count() const; |    size_t                                           message_count() const; | ||||||
|  |    std::vector<std::shared_ptr<TextProductMessage>> messages() const; | ||||||
|    std::shared_ptr<TextProductMessage>              message(size_t i) const; |    std::shared_ptr<TextProductMessage>              message(size_t i) const; | ||||||
| 
 | 
 | ||||||
|    bool LoadFile(const std::string& filename); |    bool LoadFile(const std::string& filename); | ||||||
|  |  | ||||||
|  | @ -1,16 +1,72 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include <scwx/awips/coded_location.hpp> | ||||||
|  | #include <scwx/awips/coded_time_motion_location.hpp> | ||||||
|  | #include <scwx/awips/pvtec.hpp> | ||||||
| #include <scwx/awips/message.hpp> | #include <scwx/awips/message.hpp> | ||||||
| #include <scwx/awips/wmo_header.hpp> | #include <scwx/awips/wmo_header.hpp> | ||||||
| 
 | 
 | ||||||
| #include <cstdint> | #include <cstdint> | ||||||
| #include <memory> | #include <memory> | ||||||
|  | #include <string> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx | ||||||
| { | { | ||||||
| namespace awips | namespace awips | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|  | struct Vtec | ||||||
|  | { | ||||||
|  |    PVtec       pVtec_; | ||||||
|  |    std::string hVtec_; | ||||||
|  | 
 | ||||||
|  |    Vtec() : pVtec_ {}, hVtec_ {} {} | ||||||
|  | 
 | ||||||
|  |    Vtec(const Vtec&)            = delete; | ||||||
|  |    Vtec& operator=(const Vtec&) = delete; | ||||||
|  | 
 | ||||||
|  |    Vtec(Vtec&&) noexcept            = default; | ||||||
|  |    Vtec& operator=(Vtec&&) noexcept = default; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | struct SegmentHeader | ||||||
|  | { | ||||||
|  |    std::string              ugcString_; | ||||||
|  |    std::vector<Vtec>        vtecString_; | ||||||
|  |    std::vector<std::string> ugcNames_; | ||||||
|  |    std::string              issuanceDateTime_; | ||||||
|  | 
 | ||||||
|  |    SegmentHeader() : | ||||||
|  |        ugcString_ {}, vtecString_ {}, ugcNames_ {}, issuanceDateTime_ {} | ||||||
|  |    { | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    SegmentHeader(const SegmentHeader&)            = delete; | ||||||
|  |    SegmentHeader& operator=(const SegmentHeader&) = delete; | ||||||
|  | 
 | ||||||
|  |    SegmentHeader(SegmentHeader&&) noexcept            = default; | ||||||
|  |    SegmentHeader& operator=(SegmentHeader&&) noexcept = default; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | struct Segment | ||||||
|  | { | ||||||
|  |    std::optional<SegmentHeader>           header_; | ||||||
|  |    std::vector<std::string>               productContent_; | ||||||
|  |    std::optional<CodedLocation>           codedLocation_; | ||||||
|  |    std::optional<CodedTimeMotionLocation> codedMotion_; | ||||||
|  | 
 | ||||||
|  |    Segment() : | ||||||
|  |        header_ {}, productContent_ {}, codedLocation_ {}, codedMotion_ {} | ||||||
|  |    { | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    Segment(const Segment&)            = delete; | ||||||
|  |    Segment& operator=(const Segment&) = delete; | ||||||
|  | 
 | ||||||
|  |    Segment(Segment&&) noexcept            = default; | ||||||
|  |    Segment& operator=(Segment&&) noexcept = default; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| class TextProductMessageImpl; | class TextProductMessageImpl; | ||||||
| 
 | 
 | ||||||
| class TextProductMessage : public Message | class TextProductMessage : public Message | ||||||
|  | @ -26,6 +82,11 @@ public: | ||||||
|    TextProductMessage& operator=(TextProductMessage&&) noexcept; |    TextProductMessage& operator=(TextProductMessage&&) noexcept; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<WmoHeader>                  wmo_header() const; |    std::shared_ptr<WmoHeader>                  wmo_header() const; | ||||||
|  |    std::vector<std::string>                    mnd_header() const; | ||||||
|  |    std::vector<std::string>                    overview_block() const; | ||||||
|  |    size_t                                      segment_count() const; | ||||||
|  |    std::vector<std::shared_ptr<const Segment>> segments() const; | ||||||
|  |    std::shared_ptr<const Segment>              segment(size_t s) const; | ||||||
| 
 | 
 | ||||||
|    size_t data_size() const; |    size_t data_size() const; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -34,6 +34,12 @@ size_t TextProductFile::message_count() const | ||||||
|    return p->messages_.size(); |    return p->messages_.size(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::vector<std::shared_ptr<TextProductMessage>> | ||||||
|  | TextProductFile::messages() const | ||||||
|  | { | ||||||
|  |    return p->messages_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| std::shared_ptr<TextProductMessage> TextProductFile::message(size_t i) const | std::shared_ptr<TextProductMessage> TextProductFile::message(size_t i) const | ||||||
| { | { | ||||||
|    return p->messages_[i]; |    return p->messages_[i]; | ||||||
|  |  | ||||||
|  | @ -1,7 +1,4 @@ | ||||||
| #include <scwx/awips/text_product_message.hpp> | #include <scwx/awips/text_product_message.hpp> | ||||||
| #include <scwx/awips/coded_location.hpp> |  | ||||||
| #include <scwx/awips/coded_time_motion_location.hpp> |  | ||||||
| #include <scwx/awips/pvtec.hpp> |  | ||||||
| #include <scwx/common/characters.hpp> | #include <scwx/common/characters.hpp> | ||||||
| #include <scwx/util/streams.hpp> | #include <scwx/util/streams.hpp> | ||||||
| 
 | 
 | ||||||
|  | @ -24,58 +21,6 @@ static const std::string logPrefix_ = "scwx::awips::text_product_message"; | ||||||
| // Look for hhmm (xM|UTC) to key the date/time string
 | // Look for hhmm (xM|UTC) to key the date/time string
 | ||||||
| static const std::regex reDateTimeString {"^[0-9]{3,4} ([AP]M|UTC)"}; | static const std::regex reDateTimeString {"^[0-9]{3,4} ([AP]M|UTC)"}; | ||||||
| 
 | 
 | ||||||
| struct Vtec |  | ||||||
| { |  | ||||||
|    PVtec       pVtec_; |  | ||||||
|    std::string hVtec_; |  | ||||||
| 
 |  | ||||||
|    Vtec() : pVtec_ {}, hVtec_ {} {} |  | ||||||
| 
 |  | ||||||
|    Vtec(const Vtec&) = delete; |  | ||||||
|    Vtec& operator=(const Vtec&) = delete; |  | ||||||
| 
 |  | ||||||
|    Vtec(Vtec&&) noexcept = default; |  | ||||||
|    Vtec& operator=(Vtec&&) noexcept = default; |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| struct SegmentHeader |  | ||||||
| { |  | ||||||
|    std::string              ugcString_; |  | ||||||
|    std::vector<Vtec>        vtecString_; |  | ||||||
|    std::vector<std::string> ugcNames_; |  | ||||||
|    std::string              issuanceDateTime_; |  | ||||||
| 
 |  | ||||||
|    SegmentHeader() : |  | ||||||
|        ugcString_ {}, vtecString_ {}, ugcNames_ {}, issuanceDateTime_ {} |  | ||||||
|    { |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    SegmentHeader(const SegmentHeader&) = delete; |  | ||||||
|    SegmentHeader& operator=(const SegmentHeader&) = delete; |  | ||||||
| 
 |  | ||||||
|    SegmentHeader(SegmentHeader&&) noexcept = default; |  | ||||||
|    SegmentHeader& operator=(SegmentHeader&&) noexcept = default; |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| struct Segment |  | ||||||
| { |  | ||||||
|    std::optional<SegmentHeader>           header_; |  | ||||||
|    std::vector<std::string>               productContent_; |  | ||||||
|    std::optional<CodedLocation>           codedLocation_; |  | ||||||
|    std::optional<CodedTimeMotionLocation> codedMotion_; |  | ||||||
| 
 |  | ||||||
|    Segment() : |  | ||||||
|        header_ {}, productContent_ {}, codedLocation_ {}, codedMotion_ {} |  | ||||||
|    { |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    Segment(const Segment&) = delete; |  | ||||||
|    Segment& operator=(const Segment&) = delete; |  | ||||||
| 
 |  | ||||||
|    Segment(Segment&&) noexcept = default; |  | ||||||
|    Segment& operator=(Segment&&) noexcept = default; |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| static void ParseCodedInformation(std::shared_ptr<Segment> segment, | static void ParseCodedInformation(std::shared_ptr<Segment> segment, | ||||||
|                                   const std::string&       wfo); |                                   const std::string&       wfo); | ||||||
| static std::vector<std::string>     ParseProductContent(std::istream& is); | static std::vector<std::string>     ParseProductContent(std::istream& is); | ||||||
|  | @ -113,6 +58,33 @@ std::shared_ptr<WmoHeader> TextProductMessage::wmo_header() const | ||||||
|    return p->wmoHeader_; |    return p->wmoHeader_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::vector<std::string> TextProductMessage::mnd_header() const | ||||||
|  | { | ||||||
|  |    return p->mndHeader_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::vector<std::string> TextProductMessage::overview_block() const | ||||||
|  | { | ||||||
|  |    return p->overviewBlock_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | size_t TextProductMessage::segment_count() const | ||||||
|  | { | ||||||
|  |    return p->segments_.size(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::vector<std::shared_ptr<const Segment>> TextProductMessage::segments() const | ||||||
|  | { | ||||||
|  |    std::vector<std::shared_ptr<const Segment>> segments(p->segments_.cbegin(), | ||||||
|  |                                                         p->segments_.cend()); | ||||||
|  |    return segments; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::shared_ptr<const Segment> TextProductMessage::segment(size_t s) const | ||||||
|  | { | ||||||
|  |    return p->segments_[s]; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| size_t TextProductMessage::data_size() const | size_t TextProductMessage::data_size() const | ||||||
| { | { | ||||||
|    return 0; |    return 0; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat