From 03aedaa7c7f4f65728e0c02b7a4b3329c8e8b006 Mon Sep 17 00:00:00 2001 From: renfrob Date: Tue, 19 Jun 2018 19:54:22 -0500 Subject: [PATCH 1/2] Removing health checks. Implementing a separate fit interval check. --- ext/lib/GNSSEph/OrbAlmStore.cpp | 28 +++++++++++++++++----------- ext/lib/GNSSEph/OrbAlmStore.hpp | 20 ++++++++++---------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/ext/lib/GNSSEph/OrbAlmStore.cpp b/ext/lib/GNSSEph/OrbAlmStore.cpp index 5c1f90c75..bdac47d2d 100644 --- a/ext/lib/GNSSEph/OrbAlmStore.cpp +++ b/ext/lib/GNSSEph/OrbAlmStore.cpp @@ -60,23 +60,28 @@ namespace gpstk const unsigned short OrbAlmStore::ADD_SUBJ = 0x02; //-------------------------------------------------------------------------- - Xvt OrbAlmStore::getXvt(const SatID& subjID, const CommonTime& t) const throw( InvalidRequest ) { try { - // test for GPS satellite system in sat? - const OrbAlm* alm = find(subjID,t); + const OrbAlm* alm = find(subjID,t,false); + Xvt sv = alm->svXvt(t); + return sv; + } + catch(InvalidRequest& ir) + { + GPSTK_RETHROW(ir); + } + } - // If the orbital elements are unhealthy, refuse to - // calculate an SV position and throw. - if (!alm->healthy) - { - InvalidRequest exc( std::string("SV is transmitting unhealhty navigation ") - + std::string("message at time of interest.") ); - GPSTK_THROW( exc ); - } +//-------------------------------------------------------------------------- + Xvt OrbAlmStore::getXvt_WithinValidity(const SatID& subjID, const CommonTime& t) const + throw( InvalidRequest ) + { + try + { + const OrbAlm* alm = find(subjID,t); Xvt sv = alm->svXvt(t); return sv; } @@ -86,6 +91,7 @@ namespace gpstk } } + //------------------------------------------------------------------------------ // This method is basically unimplemented at this level. It may // be overriden by a descendent that needs to limit access to a diff --git a/ext/lib/GNSSEph/OrbAlmStore.hpp b/ext/lib/GNSSEph/OrbAlmStore.hpp index b99308098..fc22c0166 100644 --- a/ext/lib/GNSSEph/OrbAlmStore.hpp +++ b/ext/lib/GNSSEph/OrbAlmStore.hpp @@ -101,19 +101,19 @@ namespace gpstk /// @return the Xvt of the SV at time /// @throw InvalidRequest If the request can not be completed for any /// reason, this is thrown. The text may have additional - /// information as to why the request failed. Possible reasons - /// include - /// 1. No orbital elements stored for the SV - /// 2. No orbital elements with time of validity covering time t - /// 3. Orbital elements appropriate for time t are unhealhty - /// The purpose of getXvt is to be as SAFE as possible. - /// If you MUST obtain SV PVT in the failure conditions noted above, - /// please consider calling findOrbAlm( ) - /// directly to obtain elements, then use OrbAlm.svXvt( ) - /// to obtain positions. + /// information as to why the request failed. The most common reason + /// is that no orbital elements are stored for the SV. virtual Xvt getXvt( const SatID& subjID, const CommonTime& t ) const throw( InvalidRequest ); + + /// As getXvt( ) with the additional check that the elements used + /// must have a fit interval that covers the requested time. If not, + /// InvalidRequest is thrown. + virtual Xvt getXvt_WithinValidity( const SatID& subjID, const CommonTime& t ) const + throw( InvalidRequest ); + + /// A debugging function that outputs in human readable form, /// all data stored in this object. /// @param[in] s the stream to receive the output; defaults to cout From bbe1920b8f99f0519e61b8dad7268309fce41f2f Mon Sep 17 00:00:00 2001 From: renfrob Date: Tue, 19 Jun 2018 19:54:47 -0500 Subject: [PATCH 2/2] Adding getXvt() tests --- ext/tests/GNSSEph/OrbAlmStore_T.cpp | 111 ++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/ext/tests/GNSSEph/OrbAlmStore_T.cpp b/ext/tests/GNSSEph/OrbAlmStore_T.cpp index 5a2ccd0b5..83e1e7f0b 100644 --- a/ext/tests/GNSSEph/OrbAlmStore_T.cpp +++ b/ext/tests/GNSSEph/OrbAlmStore_T.cpp @@ -463,6 +463,115 @@ createAndDump() // Dump terse in time order oas.dump(out,3); + //--- Test getXVT( ) and validity + // Verify that getXvt( ) will return values for times beyond the fit interval + // of the alamanc data. + // + // Verify that getXvtWithinValid( ) will throw an exeption in this condition. + // Expect Expect Test + // getXvt getXvt_WithinValid() Time Comment + // 1. True False 12/31/15 00:00:00 Earlier than fit interval + // 2. True True 12/31/15 12:00:00 Within fit interval + // 3. True False 01/31/16 00:00:00 Later than fit interval currMethod = typeDesc + " getXvt()"; + currMethod = typeDesc + " OrbAlmStore.getXvt()"; + TUCSM(currMethod); + + SatID sidXvt(1,SatID::systemGPS); + CommonTime test1 = CivilTime(2015,12,31,00,00,00,TimeSystem::GPS); + CommonTime test2 = CivilTime(2015,12,31,12,00,00,TimeSystem::GPS); + CommonTime test3 = CivilTime(2016, 1,31,00,00,00,TimeSystem::GPS); + vector ctVector; + ctVector.push_back(test1); + ctVector.push_back(test2); + ctVector.push_back(test3); + + // First, verify getXvt( ) succeeds with out-of-fit-interval times + Xvt saveXvt; + for (int i=0;i<3;i++) + { + try + { + Xvt xvt1 = oas.getXvt(sidXvt, ctVector[i]); + stringstream ss; + ss << "getXvt() succeeded for time "; + switch(i) + { + case 0: ss << " earlier than fit interval."; break; + case 1: ss << " within fit interval."; saveXvt = xvt1; break; + case 2: ss << " later than fit interval."; break; + } + TUPASS(ss.str()); + } + catch(InvalidRequest ir) + { + stringstream ss; + ss << "getXvt() failed for time "; + switch(i) + { + case 0: ss << " earlier than fit interval."; break; + case 1: ss <<" within fit interval."; break; + case 2: ss <<" later than fit interval."; break; + } + ss << endl << ir; + TUFAIL(ss.str()); + } + } + // Next verify getXvt_WithinValid( ) fails in 2-of-3 cases. + for (int i=0;i<3;i++) + { + try + { + Xvt xvt1 = oas.getXvt_WithinValidity(sidXvt, ctVector[i]); + stringstream ss; + switch(i) + { + case 0: + ss << "getXvt_WithinValidity() succeeded (correctly) for time earlier than fit interval."; + TUFAIL(ss.str()); + break; + case 1: + ss << "getXvt_WithinValidity() succeeded for time within fit interval."; + TUPASS(ss.str()); + if (saveXvt.x[0] != xvt1.x[0] || + saveXvt.x[1] != xvt1.x[1] || + saveXvt.x[2] != xvt1.x[2] || + saveXvt.v[0] != xvt1.v[0] || + saveXvt.v[1] != xvt1.v[1] || + saveXvt.v[2] != xvt1.v[2] || + saveXvt.clkbias != xvt1.clkbias || + saveXvt.clkdrift != xvt1.clkdrift) + { + TUFAIL("getXvt() and getXvt_WithinValidity() did not return matching results."); + } + break; + case 2: + ss << "getXvt_WithinValidity() succeeded (correctly) for time later than fit interval."; + TUFAIL(ss.str()); + break; + } + } + catch(InvalidRequest ir) + { + stringstream ss; + ss << "getXvt() failed for time "; + switch(i) + { + case 0: + ss << "getXvt_WithinValid() failed (correctly) for time earlier than fit interval."; + TUPASS(ss.str()); + break; + case 1: + ss << "getXvt_WithinValid() failed for time within fit interval."; + TUFAIL(ss.str()); + break; + case 2: + ss << "getXvt_WithinValid() failed (correctly) for time later than fit interval."; + TUPASS(ss.str()); + break; + } + } + } + /* This checks for a situation where the OrbAlmStore top-level * map has satellites mapped to empty maps. Prior to addressing * this issue, it would seg fault due to trying to dereference @@ -1075,6 +1184,8 @@ setUpGLO() } } + +//--------------------------------------------------------------------------------- int main() { unsigned errorTotal = 0;