From e237e086f0fe3d3704d5f5f392ded982222d9f70 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 15 Feb 2022 22:00:29 -0600 Subject: [PATCH] Handle null level 2 metadata records --- test/data | 2 +- test/source/scwx/wsr88d/ar2v_file.test.cpp | 10 ++++++++ wxdata/source/scwx/wsr88d/ar2v_file.cpp | 28 ++++++++++++---------- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/test/data b/test/data index 45539a5b..29c40b60 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 45539a5b0ecfc6baaaf7355b6b9542cc31ed9ecd +Subproject commit 29c40b6024935ac9e2c76bd092e2a1dd05c3f307 diff --git a/test/source/scwx/wsr88d/ar2v_file.test.cpp b/test/source/scwx/wsr88d/ar2v_file.test.cpp index c5920f68..03b0a25b 100644 --- a/test/source/scwx/wsr88d/ar2v_file.test.cpp +++ b/test/source/scwx/wsr88d/ar2v_file.test.cpp @@ -19,5 +19,15 @@ TEST(ar2v_file, klsx) EXPECT_EQ(fileValid, true); } +TEST(ar2v_file, tstl) +{ + Ar2vFile file; + bool fileValid = + file.LoadFile(std::string(SCWX_TEST_DATA_DIR) + + "/nexrad/level2/Level2_TSTL_20220213_2357.ar2v"); + + EXPECT_EQ(fileValid, true); +} + } // namespace wsr88d } // namespace scwx diff --git a/wxdata/source/scwx/wsr88d/ar2v_file.cpp b/wxdata/source/scwx/wsr88d/ar2v_file.cpp index d8555014..50e5d981 100644 --- a/wxdata/source/scwx/wsr88d/ar2v_file.cpp +++ b/wxdata/source/scwx/wsr88d/ar2v_file.cpp @@ -329,18 +329,6 @@ void Ar2vFileImpl::ParseLDMRecord(std::istream& is) while (!is.eof()) { - rda::Level2MessageInfo msgInfo = rda::Level2MessageFactory::Create(is); - if (!msgInfo.headerValid) - { - // Invalid message - break; - } - - if (msgInfo.messageValid) - { - HandleMessage(msgInfo.message); - } - off_t offset = 0; uint16_t nextSize = 0u; do @@ -361,6 +349,22 @@ void Ar2vFileImpl::ParseLDMRecord(std::istream& is) BOOST_LOG_TRIVIAL(trace) << logPrefix_ << "Next record offset by " << offset << " bytes"; } + else if (is.eof()) + { + break; + } + + rda::Level2MessageInfo msgInfo = rda::Level2MessageFactory::Create(is); + if (!msgInfo.headerValid) + { + // Invalid message + break; + } + + if (msgInfo.messageValid) + { + HandleMessage(msgInfo.message); + } } }