mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:20:06 +00:00
Support text product updates
This commit is contained in:
parent
be1d7323bd
commit
a202e0e2a0
7 changed files with 66 additions and 3 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 9d377550477ba00b9da3b594b838ba08d3ebcaaf
|
||||
Subproject commit b8c76bd23f636f9dad08efafa348dcbfe878f0b1
|
||||
|
|
@ -35,5 +35,26 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"/warnings/warnings_20210606_22-59.txt",
|
||||
"/nexrad/level3/KLSX_NOUS63_FTMLSX_202201041404"));
|
||||
|
||||
TEST(TextProductFile, Update)
|
||||
{
|
||||
const std::string filename1 {std::string(SCWX_TEST_DATA_DIR) +
|
||||
"/warnings/warnings_20210606_22-08.txt"};
|
||||
const std::string filename2 {std::string(SCWX_TEST_DATA_DIR) +
|
||||
"/warnings/warnings_20210606_22-19.txt"};
|
||||
const std::string filename3 {std::string(SCWX_TEST_DATA_DIR) +
|
||||
"/warnings/warnings_20210606_22-59.txt"};
|
||||
|
||||
TextProductFile file;
|
||||
|
||||
file.LoadFile(filename1);
|
||||
EXPECT_EQ(file.message_count(), 2);
|
||||
|
||||
file.LoadFile(filename2);
|
||||
EXPECT_EQ(file.message_count(), 4);
|
||||
|
||||
file.LoadFile(filename3);
|
||||
EXPECT_EQ(file.message_count(), 13);
|
||||
}
|
||||
|
||||
} // namespace awips
|
||||
} // namespace scwx
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/awips/message.hpp>
|
||||
#include <scwx/awips/wmo_header.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
|
@ -24,6 +25,8 @@ public:
|
|||
TextProductMessage(TextProductMessage&&) noexcept;
|
||||
TextProductMessage& operator=(TextProductMessage&&) noexcept;
|
||||
|
||||
std::shared_ptr<WmoHeader> wmo_header() const;
|
||||
|
||||
size_t data_size() const;
|
||||
|
||||
bool Parse(std::istream& is) override;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ public:
|
|||
WmoHeader(WmoHeader&&) noexcept;
|
||||
WmoHeader& operator=(WmoHeader&&) noexcept;
|
||||
|
||||
bool operator==(const WmoHeader& o) const;
|
||||
|
||||
const std::string& sequence_number() const;
|
||||
const std::string& data_type() const;
|
||||
const std::string& geographic_designator() const;
|
||||
|
|
|
|||
|
|
@ -68,10 +68,23 @@ bool TextProductFile::LoadData(std::istream& is)
|
|||
{
|
||||
std::shared_ptr<TextProductMessage> message =
|
||||
TextProductMessage::Create(is);
|
||||
bool duplicate = false;
|
||||
|
||||
if (message != nullptr)
|
||||
{
|
||||
p->messages_.push_back(message);
|
||||
for (auto m : p->messages_)
|
||||
{
|
||||
if (*m->wmo_header().get() == *message->wmo_header().get())
|
||||
{
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!duplicate)
|
||||
{
|
||||
p->messages_.push_back(message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include <scwx/awips/text_product_message.hpp>
|
||||
#include <scwx/awips/pvtec.hpp>
|
||||
#include <scwx/awips/wmo_header.hpp>
|
||||
#include <scwx/common/characters.hpp>
|
||||
#include <scwx/util/streams.hpp>
|
||||
|
||||
|
|
@ -100,6 +99,11 @@ TextProductMessage::TextProductMessage(TextProductMessage&&) noexcept = default;
|
|||
TextProductMessage&
|
||||
TextProductMessage::operator=(TextProductMessage&&) noexcept = default;
|
||||
|
||||
std::shared_ptr<WmoHeader> TextProductMessage::wmo_header() const
|
||||
{
|
||||
return p->wmoHeader_;
|
||||
}
|
||||
|
||||
size_t TextProductMessage::data_size() const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ public:
|
|||
}
|
||||
~WmoHeaderImpl() = default;
|
||||
|
||||
bool operator==(const WmoHeaderImpl& o) const;
|
||||
|
||||
std::string sequenceNumber_;
|
||||
std::string dataType_;
|
||||
std::string geographicDesignator_;
|
||||
|
|
@ -54,6 +56,24 @@ WmoHeader::~WmoHeader() = default;
|
|||
WmoHeader::WmoHeader(WmoHeader&&) noexcept = default;
|
||||
WmoHeader& WmoHeader::operator=(WmoHeader&&) noexcept = default;
|
||||
|
||||
bool WmoHeader::operator==(const WmoHeader& o) const
|
||||
{
|
||||
return (*p.get() == *o.p.get());
|
||||
}
|
||||
|
||||
bool WmoHeaderImpl::operator==(const WmoHeaderImpl& o) const
|
||||
{
|
||||
return (sequenceNumber_ == o.sequenceNumber_ && //
|
||||
dataType_ == o.dataType_ && //
|
||||
geographicDesignator_ == o.geographicDesignator_ && //
|
||||
bulletinId_ == o.bulletinId_ && //
|
||||
icao_ == o.icao_ && //
|
||||
dateTime_ == o.dateTime_ && //
|
||||
bbbIndicator_ == o.bbbIndicator_ && //
|
||||
productCategory_ == o.productCategory_ && //
|
||||
productDesignator_ == o.productDesignator_);
|
||||
}
|
||||
|
||||
const std::string& WmoHeader::sequence_number() const
|
||||
{
|
||||
return p->sequenceNumber_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue