mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 13:20:06 +00:00 
			
		
		
		
	Support decompressed level 2 files
This commit is contained in:
		
							parent
							
								
									a32029cb31
								
							
						
					
					
						commit
						a2b1955995
					
				
					 1 changed files with 70 additions and 57 deletions
				
			
		|  | @ -28,17 +28,17 @@ public: | ||||||
|        julianDate_ {0}, |        julianDate_ {0}, | ||||||
|        milliseconds_ {0}, |        milliseconds_ {0}, | ||||||
|        icao_(), |        icao_(), | ||||||
|        numRecords_ {0}, |  | ||||||
|        rawRecords_(), |        rawRecords_(), | ||||||
|        vcpData_ {nullptr}, |        vcpData_ {nullptr}, | ||||||
|        radarData_ {}, |        radarData_ {}, | ||||||
|        index_ {} {}; |        index_ {} {}; | ||||||
|    ~Ar2vFileImpl() = default; |    ~Ar2vFileImpl() = default; | ||||||
| 
 | 
 | ||||||
|  |    size_t DecompressLDMRecords(std::istream& is); | ||||||
|    void   HandleMessage(std::shared_ptr<rda::Level2Message>& message); |    void   HandleMessage(std::shared_ptr<rda::Level2Message>& message); | ||||||
|    void   IndexFile(); |    void   IndexFile(); | ||||||
|    void LoadLDMRecords(std::istream& is); |  | ||||||
|    void   ParseLDMRecords(); |    void   ParseLDMRecords(); | ||||||
|  |    void   ParseLDMRecord(std::istream& is); | ||||||
|    void   ProcessRadarData(std::shared_ptr<rda::DigitalRadarData> message); |    void   ProcessRadarData(std::shared_ptr<rda::DigitalRadarData> message); | ||||||
| 
 | 
 | ||||||
|    std::string tapeFilename_; |    std::string tapeFilename_; | ||||||
|  | @ -47,8 +47,6 @@ public: | ||||||
|    uint32_t    milliseconds_; |    uint32_t    milliseconds_; | ||||||
|    std::string icao_; |    std::string icao_; | ||||||
| 
 | 
 | ||||||
|    size_t numRecords_; |  | ||||||
| 
 |  | ||||||
|    std::shared_ptr<rda::VolumeCoveragePatternData>         vcpData_; |    std::shared_ptr<rda::VolumeCoveragePatternData>         vcpData_; | ||||||
|    std::map<uint16_t, std::shared_ptr<rda::ElevationScan>> radarData_; |    std::map<uint16_t, std::shared_ptr<rda::ElevationScan>> radarData_; | ||||||
| 
 | 
 | ||||||
|  | @ -223,7 +221,15 @@ bool Ar2vFile::LoadData(std::istream& is) | ||||||
|          << logPrefix_ << "Time:      " << p->milliseconds_; |          << logPrefix_ << "Time:      " << p->milliseconds_; | ||||||
|       BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ICAO:      " << p->icao_; |       BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ICAO:      " << p->icao_; | ||||||
| 
 | 
 | ||||||
|       p->LoadLDMRecords(is); |       size_t decompressedRecords = p->DecompressLDMRecords(is); | ||||||
|  |       if (decompressedRecords == 0) | ||||||
|  |       { | ||||||
|  |          p->ParseLDMRecord(is); | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |       { | ||||||
|  |          p->ParseLDMRecords(); | ||||||
|  |       } | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    p->IndexFile(); |    p->IndexFile(); | ||||||
|  | @ -231,11 +237,11 @@ bool Ar2vFile::LoadData(std::istream& is) | ||||||
|    return dataValid; |    return dataValid; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Ar2vFileImpl::LoadLDMRecords(std::istream& is) | size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is) | ||||||
| { | { | ||||||
|    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading LDM Records"; |    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Decompressing LDM Records"; | ||||||
| 
 | 
 | ||||||
|    numRecords_ = 0; |    size_t numRecords = 0; | ||||||
| 
 | 
 | ||||||
|    while (is.peek() != EOF) |    while (is.peek() != EOF) | ||||||
|    { |    { | ||||||
|  | @ -253,6 +259,7 @@ void Ar2vFileImpl::LoadLDMRecords(std::istream& is) | ||||||
| 
 | 
 | ||||||
|       if (recordSize == 0) |       if (recordSize == 0) | ||||||
|       { |       { | ||||||
|  |          is.seekg(startPosition, std::ios_base::beg); | ||||||
|          break; |          break; | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|  | @ -275,18 +282,19 @@ void Ar2vFileImpl::LoadLDMRecords(std::istream& is) | ||||||
|       { |       { | ||||||
|          int error = ex.error(); |          int error = ex.error(); | ||||||
|          BOOST_LOG_TRIVIAL(warning) |          BOOST_LOG_TRIVIAL(warning) | ||||||
|             << logPrefix_ << "Error decompressing record " << numRecords_; |             << logPrefix_ << "Error decompressing record " << numRecords; | ||||||
| 
 | 
 | ||||||
|          is.seekg(startPosition + std::streampos(recordSize)); |          is.seekg(startPosition + std::streampos(recordSize), | ||||||
|  |                   std::ios_base::beg); | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       ++numRecords_; |       ++numRecords; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    ParseLDMRecords(); |  | ||||||
| 
 |  | ||||||
|    BOOST_LOG_TRIVIAL(debug) |    BOOST_LOG_TRIVIAL(debug) | ||||||
|       << logPrefix_ << "Found " << numRecords_ << " LDM Records"; |       << logPrefix_ << "Decompressed " << numRecords << " LDM Records"; | ||||||
|  | 
 | ||||||
|  |    return numRecords; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Ar2vFileImpl::ParseLDMRecords() | void Ar2vFileImpl::ParseLDMRecords() | ||||||
|  | @ -301,13 +309,21 @@ void Ar2vFileImpl::ParseLDMRecords() | ||||||
| 
 | 
 | ||||||
|       BOOST_LOG_TRIVIAL(trace) << logPrefix_ << "Record " << count++; |       BOOST_LOG_TRIVIAL(trace) << logPrefix_ << "Record " << count++; | ||||||
| 
 | 
 | ||||||
|  |       ParseLDMRecord(ss); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    rawRecords_.clear(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void Ar2vFileImpl::ParseLDMRecord(std::istream& is) | ||||||
|  | { | ||||||
|    // The communications manager inserts an extra 12 bytes at the beginning
 |    // The communications manager inserts an extra 12 bytes at the beginning
 | ||||||
|    // of each record
 |    // of each record
 | ||||||
|       ss.seekg(12); |    is.seekg(12, std::ios_base::cur); | ||||||
| 
 | 
 | ||||||
|       while (!ss.eof()) |    while (!is.eof()) | ||||||
|    { |    { | ||||||
|          rda::Level2MessageInfo msgInfo = rda::Level2MessageFactory::Create(ss); |       rda::Level2MessageInfo msgInfo = rda::Level2MessageFactory::Create(is); | ||||||
|       if (!msgInfo.headerValid) |       if (!msgInfo.headerValid) | ||||||
|       { |       { | ||||||
|          // Invalid message
 |          // Invalid message
 | ||||||
|  | @ -323,18 +339,18 @@ void Ar2vFileImpl::ParseLDMRecords() | ||||||
|       uint16_t nextSize = 0u; |       uint16_t nextSize = 0u; | ||||||
|       do |       do | ||||||
|       { |       { | ||||||
|             ss.read(reinterpret_cast<char*>(&nextSize), 2); |          is.read(reinterpret_cast<char*>(&nextSize), 2); | ||||||
|          if (nextSize == 0) |          if (nextSize == 0) | ||||||
|          { |          { | ||||||
|             offset += 2; |             offset += 2; | ||||||
|          } |          } | ||||||
|          else |          else | ||||||
|          { |          { | ||||||
|                ss.seekg(-2, std::ios_base::cur); |             is.seekg(-2, std::ios_base::cur); | ||||||
|          } |          } | ||||||
|          } while (!ss.eof() && nextSize == 0u); |       } while (!is.eof() && nextSize == 0u); | ||||||
| 
 | 
 | ||||||
|          if (!ss.eof() && offset != 0) |       if (!is.eof() && offset != 0) | ||||||
|       { |       { | ||||||
|          BOOST_LOG_TRIVIAL(trace) |          BOOST_LOG_TRIVIAL(trace) | ||||||
|             << logPrefix_ << "Next record offset by " << offset << " bytes"; |             << logPrefix_ << "Next record offset by " << offset << " bytes"; | ||||||
|  | @ -342,9 +358,6 @@ void Ar2vFileImpl::ParseLDMRecords() | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|    rawRecords_.clear(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void Ar2vFileImpl::HandleMessage(std::shared_ptr<rda::Level2Message>& message) | void Ar2vFileImpl::HandleMessage(std::shared_ptr<rda::Level2Message>& message) | ||||||
| { | { | ||||||
|    switch (message->header().message_type()) |    switch (message->header().message_type()) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat