From 2c11f50fac66c8bf4fcb719dbe9b099dbfc07c4c Mon Sep 17 00:00:00 2001 From: Jayden Vasquez <173734205+jayden1711@users.noreply.github.com> Date: Sat, 21 Nov 2026 15:41:06 -0500 Subject: [PATCH] Fix BeiDou C39, C49 and C59 names in Sat::GetStr() The BDS string table had "C30", "C40" and "C50" in the slots for C39, C49 and C59, so those satellites printed as the wrong PRN and Sat(sat.GetStr()) did not round-trip. Add a round-trip test over all valid satellites of every constellation. --- fpsdk_common/src/gnss.cpp | 6 +++--- fpsdk_common/test/gnss_test.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/fpsdk_common/src/gnss.cpp b/fpsdk_common/src/gnss.cpp index 051e33e0..ef18525c 100644 --- a/fpsdk_common/src/gnss.cpp +++ b/fpsdk_common/src/gnss.cpp @@ -350,9 +350,9 @@ const char* Sat::GetStr() const "C01", "C02", "C03", "C04", "C05", "C06", "C07", "C08", "C09", "C10", "C11", "C12", "C13", "C14", "C15", "C16", "C17", "C18", "C19", "C20", "C21", "C22", "C23", "C24", "C25", "C26", "C27", "C28", "C29", "C30", - "C31", "C32", "C33", "C34", "C35", "C36", "C37", "C38", "C30", "C40", - "C41", "C42", "C43", "C44", "C45", "C46", "C47", "C48", "C40", "C50", - "C51", "C52", "C53", "C54", "C55", "C56", "C57", "C58", "C50", "C60", + "C31", "C32", "C33", "C34", "C35", "C36", "C37", "C38", "C39", "C40", + "C41", "C42", "C43", "C44", "C45", "C46", "C47", "C48", "C49", "C50", + "C51", "C52", "C53", "C54", "C55", "C56", "C57", "C58", "C59", "C60", "C61", "C62", "C63" }}; // clang-format on const int ix = (int)svnr - (int)FIRST_BDS; diff --git a/fpsdk_common/test/gnss_test.cpp b/fpsdk_common/test/gnss_test.cpp index 4f28d412..14579938 100644 --- a/fpsdk_common/test/gnss_test.cpp +++ b/fpsdk_common/test/gnss_test.cpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include /* EXTERNAL */ #include @@ -196,6 +198,9 @@ TEST(GnssTest, SatStr) EXPECT_EQ(std::string(Sat(Gnss::BDS, 5).GetStr()), std::string("C05")); EXPECT_EQ(std::string(Sat(Gnss::QZSS, 9).GetStr()), std::string("J09")); EXPECT_EQ(std::string(Sat(Gnss::GLO, 15).GetStr()), std::string("R15")); + EXPECT_EQ(std::string(Sat(Gnss::BDS, 39).GetStr()), std::string("C39")); + EXPECT_EQ(std::string(Sat(Gnss::BDS, 49).GetStr()), std::string("C49")); + EXPECT_EQ(std::string(Sat(Gnss::BDS, 59).GetStr()), std::string("C59")); // Invalid EXPECT_EQ(std::string(Sat(Gnss::GPS, 0).GetStr()), std::string("G??")); @@ -213,6 +218,27 @@ TEST(GnssTest, SatStr) // --------------------------------------------------------------------------------------------------------------------- +TEST(GnssTest, SatStrRoundtrip) +{ + const std::vector>> ranges = { + { Gnss::GPS, { FIRST_GPS, NUM_GPS } }, + { Gnss::SBAS, { FIRST_SBAS, NUM_SBAS } }, + { Gnss::GAL, { FIRST_GAL, NUM_GAL } }, + { Gnss::BDS, { FIRST_BDS, NUM_BDS } }, + { Gnss::QZSS, { FIRST_QZSS, NUM_QZSS } }, + { Gnss::GLO, { FIRST_GLO, NUM_GLO } }, + { Gnss::NAVIC, { FIRST_NAVIC, NUM_NAVIC } }, + }; + for (const auto& range : ranges) { + for (int n = range.second.first; n < (range.second.first + range.second.second); n++) { + const Sat sat(range.first, (SvNr)n); + EXPECT_EQ(Sat(sat.GetStr()), sat) << sat.GetStr() << " is not " << GnssStr(range.first) << " " << n; + } + } +} + +// --------------------------------------------------------------------------------------------------------------------- + TEST(GnssTest, StrSat) { // clang-format off