mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Boost.Log -> spdlog - wsr88d
This commit is contained in:
parent
766940e60f
commit
40ef43ed30
3 changed files with 48 additions and 72 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#include <scwx/wsr88d/ar2v_file.hpp>
|
#include <scwx/wsr88d/ar2v_file.hpp>
|
||||||
#include <scwx/wsr88d/rda/level2_message_factory.hpp>
|
#include <scwx/wsr88d/rda/level2_message_factory.hpp>
|
||||||
#include <scwx/wsr88d/rda/types.hpp>
|
#include <scwx/wsr88d/rda/types.hpp>
|
||||||
|
#include <scwx/util/logger.hpp>
|
||||||
#include <scwx/util/rangebuf.hpp>
|
#include <scwx/util/rangebuf.hpp>
|
||||||
#include <scwx/util/time.hpp>
|
#include <scwx/util/time.hpp>
|
||||||
|
|
||||||
|
|
@ -10,14 +11,14 @@
|
||||||
#include <boost/iostreams/copy.hpp>
|
#include <boost/iostreams/copy.hpp>
|
||||||
#include <boost/iostreams/filtering_streambuf.hpp>
|
#include <boost/iostreams/filtering_streambuf.hpp>
|
||||||
#include <boost/iostreams/filter/bzip2.hpp>
|
#include <boost/iostreams/filter/bzip2.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace wsr88d
|
namespace wsr88d
|
||||||
{
|
{
|
||||||
|
|
||||||
static const std::string logPrefix_ = "[scwx::wsr88d::ar2v_file] ";
|
static const std::string logPrefix_ = "scwx::wsr88d::ar2v_file";
|
||||||
|
static const auto logger_ = util::Logger::Create(logPrefix_);
|
||||||
|
|
||||||
class Ar2vFileImpl
|
class Ar2vFileImpl
|
||||||
{
|
{
|
||||||
|
|
@ -115,8 +116,7 @@ Ar2vFile::GetElevationScan(rda::DataBlockType dataBlockType,
|
||||||
float elevation,
|
float elevation,
|
||||||
std::chrono::system_clock::time_point time) const
|
std::chrono::system_clock::time_point time) const
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
logger_->debug("GetElevationScan: {} degrees", elevation);
|
||||||
<< logPrefix_ << "GetElevationScan: " << elevation << " degrees";
|
|
||||||
|
|
||||||
constexpr float scaleFactor = 8.0f / 0.043945f;
|
constexpr float scaleFactor = 8.0f / 0.043945f;
|
||||||
|
|
||||||
|
|
@ -170,14 +170,13 @@ Ar2vFile::GetElevationScan(rda::DataBlockType dataBlockType,
|
||||||
|
|
||||||
bool Ar2vFile::LoadFile(const std::string& filename)
|
bool Ar2vFile::LoadFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadFile(" << filename << ")";
|
logger_->debug("LoadFile: {}", filename);
|
||||||
bool fileValid = true;
|
bool fileValid = true;
|
||||||
|
|
||||||
std::ifstream f(filename, std::ios_base::in | std::ios_base::binary);
|
std::ifstream f(filename, std::ios_base::in | std::ios_base::binary);
|
||||||
if (!f.good())
|
if (!f.good())
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
logger_->warn("Could not open file for reading: {}", filename);
|
||||||
<< logPrefix_ << "Could not open file for reading: " << filename;
|
|
||||||
fileValid = false;
|
fileValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,7 +190,7 @@ bool Ar2vFile::LoadFile(const std::string& filename)
|
||||||
|
|
||||||
bool Ar2vFile::LoadData(std::istream& is)
|
bool Ar2vFile::LoadData(std::istream& is)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Data";
|
logger_->debug("Loading Data");
|
||||||
|
|
||||||
bool dataValid = true;
|
bool dataValid = true;
|
||||||
|
|
||||||
|
|
@ -211,21 +210,17 @@ bool Ar2vFile::LoadData(std::istream& is)
|
||||||
|
|
||||||
if (is.eof())
|
if (is.eof())
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
logger_->warn("Could not read Volume Header Record");
|
||||||
<< logPrefix_ << "Could not read Volume Header Record\n";
|
|
||||||
dataValid = false;
|
dataValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataValid)
|
if (dataValid)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
logger_->debug("Filename: {}", p->tapeFilename_);
|
||||||
<< logPrefix_ << "Filename: " << p->tapeFilename_;
|
logger_->debug("Extension: {}", p->extensionNumber_);
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
logger_->debug("Date: {}", p->julianDate_);
|
||||||
<< logPrefix_ << "Extension: " << p->extensionNumber_;
|
logger_->debug("Time: {}", p->milliseconds_);
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Date: " << p->julianDate_;
|
logger_->debug("ICAO: {}", p->icao_);
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
|
||||||
<< logPrefix_ << "Time: " << p->milliseconds_;
|
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ICAO: " << p->icao_;
|
|
||||||
|
|
||||||
size_t decompressedRecords = p->DecompressLDMRecords(is);
|
size_t decompressedRecords = p->DecompressLDMRecords(is);
|
||||||
if (decompressedRecords == 0)
|
if (decompressedRecords == 0)
|
||||||
|
|
@ -245,7 +240,7 @@ bool Ar2vFile::LoadData(std::istream& is)
|
||||||
|
|
||||||
size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is)
|
size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Decompressing LDM Records";
|
logger_->debug("Decompressing LDM Records");
|
||||||
|
|
||||||
size_t numRecords = 0;
|
size_t numRecords = 0;
|
||||||
|
|
||||||
|
|
@ -260,8 +255,7 @@ size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is)
|
||||||
controlWord = ntohl(controlWord);
|
controlWord = ntohl(controlWord);
|
||||||
recordSize = std::abs(controlWord);
|
recordSize = std::abs(controlWord);
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(trace)
|
logger_->trace("LDM Record Found: Size = {} bytes", recordSize);
|
||||||
<< logPrefix_ << "LDM Record Found: Size = " << recordSize << " bytes";
|
|
||||||
|
|
||||||
if (recordSize == 0)
|
if (recordSize == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -278,17 +272,14 @@ size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::streamsize bytesCopied = boost::iostreams::copy(in, ss);
|
std::streamsize bytesCopied = boost::iostreams::copy(in, ss);
|
||||||
BOOST_LOG_TRIVIAL(trace)
|
logger_->trace("Decompressed record size = {} bytes", bytesCopied);
|
||||||
<< logPrefix_ << "Decompressed record size = " << bytesCopied
|
|
||||||
<< " bytes";
|
|
||||||
|
|
||||||
rawRecords_.push_back(std::move(ss));
|
rawRecords_.push_back(std::move(ss));
|
||||||
}
|
}
|
||||||
catch (const boost::iostreams::bzip2_error& ex)
|
catch (const boost::iostreams::bzip2_error& ex)
|
||||||
{
|
{
|
||||||
int error = ex.error();
|
int error = ex.error();
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
logger_->warn("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);
|
std::ios_base::beg);
|
||||||
|
|
@ -297,15 +288,14 @@ size_t Ar2vFileImpl::DecompressLDMRecords(std::istream& is)
|
||||||
++numRecords;
|
++numRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
logger_->debug("Decompressed {} LDM Records", numRecords);
|
||||||
<< logPrefix_ << "Decompressed " << numRecords << " LDM Records";
|
|
||||||
|
|
||||||
return numRecords;
|
return numRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ar2vFileImpl::ParseLDMRecords()
|
void Ar2vFileImpl::ParseLDMRecords()
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Parsing LDM Records";
|
logger_->debug("Parsing LDM Records");
|
||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
|
|
@ -313,7 +303,7 @@ void Ar2vFileImpl::ParseLDMRecords()
|
||||||
{
|
{
|
||||||
std::stringstream& ss = *it;
|
std::stringstream& ss = *it;
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(trace) << logPrefix_ << "Record " << count++;
|
logger_->trace("Record {}", count++);
|
||||||
|
|
||||||
ParseLDMRecord(ss);
|
ParseLDMRecord(ss);
|
||||||
}
|
}
|
||||||
|
|
@ -346,8 +336,7 @@ void Ar2vFileImpl::ParseLDMRecord(std::istream& is)
|
||||||
|
|
||||||
if (!is.eof() && offset != 0)
|
if (!is.eof() && offset != 0)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(trace)
|
logger_->trace("Next record offset by {} bytes", offset);
|
||||||
<< logPrefix_ << "Next record offset by " << offset << " bytes";
|
|
||||||
}
|
}
|
||||||
else if (is.eof())
|
else if (is.eof())
|
||||||
{
|
{
|
||||||
|
|
@ -382,7 +371,8 @@ void Ar2vFileImpl::HandleMessage(std::shared_ptr<rda::Level2Message>& message)
|
||||||
std::static_pointer_cast<rda::DigitalRadarData>(message));
|
std::static_pointer_cast<rda::DigitalRadarData>(message));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -402,12 +392,11 @@ void Ar2vFileImpl::ProcessRadarData(
|
||||||
|
|
||||||
void Ar2vFileImpl::IndexFile()
|
void Ar2vFileImpl::IndexFile()
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Indexing file";
|
logger_->debug("Indexing file");
|
||||||
|
|
||||||
if (vcpData_ == nullptr)
|
if (vcpData_ == nullptr)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
logger_->warn("Cannot index file without VCP data");
|
||||||
<< logPrefix_ << "Cannot index file without VCP data";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,21 @@
|
||||||
#include <scwx/wsr88d/level3_file.hpp>
|
#include <scwx/wsr88d/level3_file.hpp>
|
||||||
#include <scwx/wsr88d/rpg/ccb_header.hpp>
|
#include <scwx/wsr88d/rpg/ccb_header.hpp>
|
||||||
#include <scwx/wsr88d/rpg/level3_message_factory.hpp>
|
#include <scwx/wsr88d/rpg/level3_message_factory.hpp>
|
||||||
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include <boost/iostreams/copy.hpp>
|
#include <boost/iostreams/copy.hpp>
|
||||||
#include <boost/iostreams/filtering_streambuf.hpp>
|
#include <boost/iostreams/filtering_streambuf.hpp>
|
||||||
#include <boost/iostreams/filter/zlib.hpp>
|
#include <boost/iostreams/filter/zlib.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace wsr88d
|
namespace wsr88d
|
||||||
{
|
{
|
||||||
|
|
||||||
static const std::string logPrefix_ = "[scwx::wsr88d::level3_file] ";
|
static const std::string logPrefix_ = "scwx::wsr88d::level3_file";
|
||||||
|
static const auto logger_ = util::Logger::Create(logPrefix_);
|
||||||
|
|
||||||
class Level3FileImpl
|
class Level3FileImpl
|
||||||
{
|
{
|
||||||
|
|
@ -50,14 +51,13 @@ std::shared_ptr<rpg::Level3Message> Level3File::message() const
|
||||||
|
|
||||||
bool Level3File::LoadFile(const std::string& filename)
|
bool Level3File::LoadFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadFile(" << filename << ")";
|
logger_->debug("LoadFile: {}", filename);
|
||||||
bool fileValid = true;
|
bool fileValid = true;
|
||||||
|
|
||||||
std::ifstream f(filename, std::ios_base::in | std::ios_base::binary);
|
std::ifstream f(filename, std::ios_base::in | std::ios_base::binary);
|
||||||
if (!f.good())
|
if (!f.good())
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
logger_->warn("Could not open file for reading: {}", filename);
|
||||||
<< logPrefix_ << "Could not open file for reading: " << filename;
|
|
||||||
fileValid = false;
|
fileValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ bool Level3File::LoadFile(const std::string& filename)
|
||||||
|
|
||||||
bool Level3File::LoadData(std::istream& is)
|
bool Level3File::LoadData(std::istream& is)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Data";
|
logger_->debug("Loading Data");
|
||||||
|
|
||||||
p->wmoHeader_ = std::make_shared<awips::WmoHeader>();
|
p->wmoHeader_ = std::make_shared<awips::WmoHeader>();
|
||||||
|
|
||||||
|
|
@ -79,16 +79,11 @@ bool Level3File::LoadData(std::istream& is)
|
||||||
|
|
||||||
if (dataValid)
|
if (dataValid)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
logger_->debug("Data Type: {}", p->wmoHeader_->data_type());
|
||||||
<< logPrefix_ << "Data Type: " << p->wmoHeader_->data_type();
|
logger_->debug("ICAO: {}", p->wmoHeader_->icao());
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
logger_->debug("Date/Time: {}", p->wmoHeader_->date_time());
|
||||||
<< logPrefix_ << "ICAO: " << p->wmoHeader_->icao();
|
logger_->debug("Category: {}", p->wmoHeader_->product_category());
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
logger_->debug("Site ID: {}", p->wmoHeader_->product_designator());
|
||||||
<< logPrefix_ << "Date/Time: " << p->wmoHeader_->date_time();
|
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
|
||||||
<< logPrefix_ << "Category: " << p->wmoHeader_->product_category();
|
|
||||||
BOOST_LOG_TRIVIAL(debug)
|
|
||||||
<< logPrefix_ << "Site ID: " << p->wmoHeader_->product_designator();
|
|
||||||
|
|
||||||
// If the header is compressed
|
// If the header is compressed
|
||||||
if (is.peek() == 0x78)
|
if (is.peek() == 0x78)
|
||||||
|
|
@ -146,20 +141,15 @@ bool Level3FileImpl::DecompressFile(std::istream& is, std::stringstream& ss)
|
||||||
{
|
{
|
||||||
int error = ex.error();
|
int error = ex.error();
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
logger_->warn("Error decompressing data: {}", ex.what());
|
||||||
<< logPrefix_ << "Error decompressing data: " << ex.what();
|
|
||||||
|
|
||||||
dataValid = false;
|
dataValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataValid)
|
if (dataValid)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(trace)
|
logger_->trace("Input data consumed = {} bytes", totalBytesCopied);
|
||||||
<< logPrefix_ << "Input data consumed = " << totalBytesCopied
|
logger_->trace("Decompressed data size = {} bytes", totalBytesConsumed);
|
||||||
<< " bytes";
|
|
||||||
BOOST_LOG_TRIVIAL(trace)
|
|
||||||
<< logPrefix_ << "Decompressed data size = " << totalBytesConsumed
|
|
||||||
<< " bytes";
|
|
||||||
|
|
||||||
ccbHeader_ = std::make_shared<rpg::CcbHeader>();
|
ccbHeader_ = std::make_shared<rpg::CcbHeader>();
|
||||||
dataValid = ccbHeader_->Parse(ss);
|
dataValid = ccbHeader_->Parse(ss);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <scwx/wsr88d/nexrad_file_factory.hpp>
|
#include <scwx/wsr88d/nexrad_file_factory.hpp>
|
||||||
#include <scwx/wsr88d/ar2v_file.hpp>
|
#include <scwx/wsr88d/ar2v_file.hpp>
|
||||||
#include <scwx/wsr88d/level3_file.hpp>
|
#include <scwx/wsr88d/level3_file.hpp>
|
||||||
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
@ -8,19 +9,19 @@
|
||||||
#include <boost/iostreams/copy.hpp>
|
#include <boost/iostreams/copy.hpp>
|
||||||
#include <boost/iostreams/filtering_streambuf.hpp>
|
#include <boost/iostreams/filtering_streambuf.hpp>
|
||||||
#include <boost/iostreams/filter/gzip.hpp>
|
#include <boost/iostreams/filter/gzip.hpp>
|
||||||
#include <boost/log/trivial.hpp>
|
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
namespace wsr88d
|
namespace wsr88d
|
||||||
{
|
{
|
||||||
|
|
||||||
static const std::string logPrefix_ = "[scwx::wsr88d::nexrad_file_factory] ";
|
static const std::string logPrefix_ = "scwx::wsr88d::nexrad_file_factory";
|
||||||
|
static const auto logger_ = util::Logger::Create(logPrefix_);
|
||||||
|
|
||||||
std::shared_ptr<NexradFile>
|
std::shared_ptr<NexradFile>
|
||||||
NexradFileFactory::Create(const std::string& filename)
|
NexradFileFactory::Create(const std::string& filename)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Create(" << filename << ")";
|
logger_->debug("Create: {}", filename);
|
||||||
|
|
||||||
std::shared_ptr<NexradFile> nexradFile = nullptr;
|
std::shared_ptr<NexradFile> nexradFile = nullptr;
|
||||||
bool fileValid = true;
|
bool fileValid = true;
|
||||||
|
|
@ -28,8 +29,7 @@ NexradFileFactory::Create(const std::string& filename)
|
||||||
std::ifstream f(filename, std::ios_base::in | std::ios_base::binary);
|
std::ifstream f(filename, std::ios_base::in | std::ios_base::binary);
|
||||||
if (!f.good())
|
if (!f.good())
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
logger_->warn("Could not open file for reading: {}", filename);
|
||||||
<< logPrefix_ << "Could not open file for reading: " << filename;
|
|
||||||
fileValid = false;
|
fileValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,26 +74,23 @@ std::shared_ptr<NexradFile> NexradFileFactory::Create(std::istream& is)
|
||||||
dataValid = ss.good();
|
dataValid = ss.good();
|
||||||
ss.seekg(pisBegin, std::ios_base::beg);
|
ss.seekg(pisBegin, std::ios_base::beg);
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(trace)
|
logger_->trace("Decompressed file = {} bytes", bytesCopied);
|
||||||
<< logPrefix_ << "Decompressed file = " << bytesCopied << " bytes";
|
|
||||||
|
|
||||||
if (!dataValid)
|
if (!dataValid)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
logger_->warn("Error reading decompressed stream");
|
||||||
<< logPrefix_ << "Error reading decompressed stream";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const boost::iostreams::gzip_error& ex)
|
catch (const boost::iostreams::gzip_error& ex)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(warning)
|
logger_->warn("Error decompressing file: {}", ex.what());
|
||||||
<< logPrefix_ << "Error decompressing file: " << ex.what();
|
|
||||||
|
|
||||||
dataValid = false;
|
dataValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!dataValid)
|
else if (!dataValid)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Error reading file";
|
logger_->warn("Error reading file");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataValid)
|
if (dataValid)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue