From e56e46867af770f66d1d72d1a3649ff18c58b776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D1=80=D0=BB=D0=BE=D0=B2=20=D0=9A=D0=B8=D1=80=D0=B8?= =?UTF-8?q?=D0=BB=D0=BB=20=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Tue, 18 Feb 2020 16:59:15 +0300 Subject: [PATCH] 2.3 with our delta to compile navsol --- dev/CMakeLists.txt | 2 + dev/apps/Rinextools/RinDump.cpp | 10 +- dev/apps/Rinextools/RinSum.cpp | 2 +- dev/apps/geomatics/JPLeph/convertSSEph.cpp | 2 +- dev/apps/geomatics/JPLeph/testSSEph.cpp | 2 +- dev/apps/positioning/PRSolve.cpp | 8 +- dev/examples/example3.cpp | 2 +- dev/lib/FileHandling/FFData.cpp | 11 +- dev/lib/FileHandling/FFData.hpp | 27 +- dev/lib/FileHandling/FFStream.cpp | 499 ++++++++++-------- dev/lib/FileHandling/FFStream.hpp | 61 ++- dev/lib/FileHandling/FFTextStream.cpp | 113 ++++ dev/lib/FileHandling/FFTextStream.hpp | 152 +----- .../FileHandling/RINEX3/Rinex3ClockData.cpp | 34 +- .../FileHandling/RINEX3/Rinex3ClockData.hpp | 42 +- dev/lib/FileHandling/RINEX3/Rinex3Datum.h | 24 + dev/lib/FileHandling/RINEX3/Rinex3NavData.cpp | 71 ++- dev/lib/FileHandling/RINEX3/Rinex3NavData.hpp | 18 +- .../FileHandling/RINEX3/Rinex3NavHeader.cpp | 69 ++- .../FileHandling/RINEX3/Rinex3NavHeader.hpp | 49 +- .../FileHandling/RINEX3/Rinex3NavStream.hpp | 21 +- dev/lib/FileHandling/RINEX3/Rinex3ObsData.cpp | 134 +++-- dev/lib/FileHandling/RINEX3/Rinex3ObsData.hpp | 47 +- .../FileHandling/RINEX3/Rinex3ObsHeader.cpp | 110 ++-- .../FileHandling/RINEX3/Rinex3ObsHeader.hpp | 28 +- .../FileHandling/RINEX3/Rinex3ObsStream.hpp | 32 +- dev/lib/GNSSCore/Xvt.hpp | 4 +- dev/lib/ProcLib/ExtractCombinationData.cpp | 2 +- dev/lib/ProcLib/ExtractData.cpp | 2 +- dev/lib/Rxio/ObsReader.cpp | 10 +- 30 files changed, 851 insertions(+), 737 deletions(-) create mode 100644 dev/lib/FileHandling/FFTextStream.cpp create mode 100644 dev/lib/FileHandling/RINEX3/Rinex3Datum.h diff --git a/dev/CMakeLists.txt b/dev/CMakeLists.txt index c52e707f1..f24f0df0f 100755 --- a/dev/CMakeLists.txt +++ b/dev/CMakeLists.txt @@ -102,3 +102,5 @@ install (FILES ${HEADERS} ${HEADERS2} DESTINATION include/gpstk ) add_subdirectory (apps) add_subdirectory (examples) +include(CPack) + diff --git a/dev/apps/Rinextools/RinDump.cpp b/dev/apps/Rinextools/RinDump.cpp index f295b68a1..3545cc45a 100755 --- a/dev/apps/Rinextools/RinDump.cpp +++ b/dev/apps/Rinextools/RinDump.cpp @@ -117,7 +117,7 @@ class LinCom { /// compute the linear combination, given the satellite and RINEX data double Compute(const RinexSatID sat, Rinex3ObsHeader& Rhead, - const vector& vrdata) throw(Exception); + const vector& vrdata) throw(Exception); /// remove a bias if jump larger than limit occurs bool removeBias(const RinexSatID& sat) throw(); @@ -253,7 +253,7 @@ const string Configuration::longfmt = calfmt + " = " + gpsfmt; int Initialize(string& errors) throw(Exception); int ProcessFiles(void) throw(Exception); double getObsData(string tag, RinexSatID sat, Rinex3ObsHeader& Rhead, - const vector& vrdata) throw(Exception); + const vector& vrdata) throw(Exception); double getNonObsData(string tag, RinexSatID sat, const CommonTime& time) throw(Exception); @@ -1687,7 +1687,7 @@ try { } // access the data - const vector& vrdata(it->second); + const vector& vrdata(it->second); // don't output all zero's, or elev > elevlimit ok = false; // reuse ok; if one datum is good, output @@ -1768,7 +1768,7 @@ catch(Exception& e) { GPSTK_RETHROW(e); } //------------------------------------------------------------------------------------ double getObsData(string tag, RinexSatID sat, Rinex3ObsHeader& Rhead, - const vector& vrdata) throw(Exception) + const vector& vrdata) throw(Exception) { try { double data(0); @@ -2200,7 +2200,7 @@ bool LinCom::ParseAndSave(const string& lab, bool save) throw() //------------------------------------------------------------------------------------ double LinCom::Compute(const RinexSatID sat, Rinex3ObsHeader& Rhead, - const vector& vrdata) throw(Exception) + const vector& vrdata) throw(Exception) { Configuration& C(Configuration::Instance()); diff --git a/dev/apps/Rinextools/RinSum.cpp b/dev/apps/Rinextools/RinSum.cpp index e2a115bae..e3c00635f 100755 --- a/dev/apps/Rinextools/RinSum.cpp +++ b/dev/apps/Rinextools/RinSum.cpp @@ -731,7 +731,7 @@ try { RinexSatID(-1,sat.system)) != C.exSats.end()) continue; - const vector& vecData(it->second); + const vector& vecData(it->second); // find this sat in the table; add it if necessary vector::iterator ptab; diff --git a/dev/apps/geomatics/JPLeph/convertSSEph.cpp b/dev/apps/geomatics/JPLeph/convertSSEph.cpp index 7cea26307..a87c1b33e 100755 --- a/dev/apps/geomatics/JPLeph/convertSSEph.cpp +++ b/dev/apps/geomatics/JPLeph/convertSSEph.cpp @@ -203,7 +203,7 @@ try { totaltime = clock()-totaltime; LOG(INFO) << PrgmName << " timing: " << fixed << setprecision(9) << double(totaltime)/double(CLOCKS_PER_SEC) << " seconds."; - if(LOGstrm != cout) cout << PrgmName << " timing: " << fixed << setprecision(9) + if(pLOGstrm != &cout) cout << PrgmName << " timing: " << fixed << setprecision(9) << double(totaltime)/double(CLOCKS_PER_SEC) << " seconds." << endl; return iret; diff --git a/dev/apps/geomatics/JPLeph/testSSEph.cpp b/dev/apps/geomatics/JPLeph/testSSEph.cpp index d19cc1be5..b325540b3 100755 --- a/dev/apps/geomatics/JPLeph/testSSEph.cpp +++ b/dev/apps/geomatics/JPLeph/testSSEph.cpp @@ -216,7 +216,7 @@ try { totaltime = clock()-totaltime; LOG(INFO) << PrgmName << " timing: " << fixed << setprecision(9) << double(totaltime)/double(CLOCKS_PER_SEC) << " seconds."; - if(LOGstrm != cout) cout << PrgmName << " timing: " << fixed << setprecision(9) + if(pLOGstrm != &cout) cout << PrgmName << " timing: " << fixed << setprecision(9) << double(totaltime)/double(CLOCKS_PER_SEC) << " seconds." << endl; return iret; diff --git a/dev/apps/positioning/PRSolve.cpp b/dev/apps/positioning/PRSolve.cpp index 39d8dc60b..7a731475d 100755 --- a/dev/apps/positioning/PRSolve.cpp +++ b/dev/apps/positioning/PRSolve.cpp @@ -362,7 +362,7 @@ class SolutionData { // compute the actual datum, for the given satellite, given the RinexObsData vector // remember which ObsIDs were actually used, in usedobsids // return true if the data could be computed - bool ComputeData(const RinexSatID& sat, const vector& vrd) + bool ComputeData(const RinexSatID& sat, const vector& vrd) { usedobsids.clear(); RawPR.clear(); @@ -491,7 +491,7 @@ class SolutionObject { // indicating whether there is sufficient good data. void CollectData(const RinexSatID& s, const double& elev, const double& ER, - const vector& v) throw(); + const vector& v) throw(); // Compute a solution for the given epoch; call after CollectData() // same return value as RAIMCompute() @@ -1381,7 +1381,7 @@ try { Rinex3ObsData::DataMap::iterator it; for(it=Rdata.obs.begin(); it!=Rdata.obs.end(); ++it) { sat = it->first; - vector& vrdata(it->second); + vector& vrdata(it->second); string sys(asString(sat.systemChar())); // is this system excluded? @@ -2287,7 +2287,7 @@ void SolutionObject::EpochReset(void) throw() //------------------------------------------------------------------------------------ void SolutionObject::CollectData(const RinexSatID& sat, const double& elev, const double& ER, - const vector& vrd) + const vector& vrd) throw() { if(!isValid) return; diff --git a/dev/examples/example3.cpp b/dev/examples/example3.cpp index fcded3090..4fd44e549 100755 --- a/dev/examples/example3.cpp +++ b/dev/examples/example3.cpp @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) roffs.exceptions(ios::failbit); Rinex3ObsHeader roh; Rinex3ObsData roe; - RinexDatum dataobj; + Rinex3Datum dataobj; // Read the RINEX header (don't skip this step) // -------------------------------------------- diff --git a/dev/lib/FileHandling/FFData.cpp b/dev/lib/FileHandling/FFData.cpp index 5dae1cbd3..0d322a5bc 100755 --- a/dev/lib/FileHandling/FFData.cpp +++ b/dev/lib/FileHandling/FFData.cpp @@ -1,14 +1,12 @@ #pragma ident "$Id$" - - //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -38,11 +36,6 @@ // //============================================================================= - - - - - /** * @file FFData.cpp * Formatted File Data base class @@ -54,7 +47,7 @@ namespace gpstk { void FFData::putRecord(FFStream& s) const - throw(FFStreamError, gpstk::StringUtils::StringException) + throw(FFStreamError, gpstk::StringUtils::StringException,std::bad_cast) { s.tryFFStreamPut(*this); } diff --git a/dev/lib/FileHandling/FFData.hpp b/dev/lib/FileHandling/FFData.hpp index 774a01d37..8c7e2dfaf 100755 --- a/dev/lib/FileHandling/FFData.hpp +++ b/dev/lib/FileHandling/FFData.hpp @@ -1,22 +1,12 @@ #pragma ident "$Id$" - - -/** - * @file FFData.hpp - * Formatted File Data base class - */ - -#ifndef GPSTK_FFDATA_HPP -#define GPSTK_FFDATA_HPP - //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -46,10 +36,13 @@ // //============================================================================= +/** + * @file FFData.hpp + * Formatted File Data base class + */ - - - +#ifndef GPSTK_FFDATA_HPP +#define GPSTK_FFDATA_HPP #include #include @@ -102,7 +95,7 @@ namespace gpstk * @param s a FFStream-based stream */ void putRecord(FFStream& s) const - throw(FFStreamError, gpstk::StringUtils::StringException); + throw(FFStreamError, gpstk::StringUtils::StringException, std::bad_cast); /** * Retrieve a "record" from the given stream. @@ -174,9 +167,7 @@ namespace gpstk protected: /// Does the actual reading from the stream into this FFData object. - virtual void reallyGetRecord(FFStream& s) - throw(std::exception, gpstk::StringUtils::StringException, - gpstk::FFStreamError) = 0; + virtual void reallyGetRecord(FFStream& s) = 0; /// Does the actual writing from the stream into this FFData object. virtual void reallyPutRecord(FFStream& s) const diff --git a/dev/lib/FileHandling/FFStream.cpp b/dev/lib/FileHandling/FFStream.cpp index 6f97cfd6e..2577220c0 100755 --- a/dev/lib/FileHandling/FFStream.cpp +++ b/dev/lib/FileHandling/FFStream.cpp @@ -1,17 +1,12 @@ #pragma ident "$Id$" -/** - * @file FFStream.cpp - * Formatted File Stream base class - */ - //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -22,7 +17,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// +// // Copyright 2004, The University of Texas at Austin // //============================================================================ @@ -30,280 +25,324 @@ //============================================================================ // //This software developed by Applied Research Laboratories at the University of -//Texas at Austin, under contract to an agency or agencies within the U.S. +//Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use, -//duplicate, distribute, disclose, or release this software. +//duplicate, distribute, disclose, or release this software. // -//Pursuant to DoD Directive 523024 +//Pursuant to DoD Directive 523024 // -// DISTRIBUTION STATEMENT A: This software has been approved for public +// DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited. // //============================================================================= - +/** + * @file FFStream.cpp + * Formatted File Stream base class + */ #include "FFStream.hpp" + namespace gpstk { - /* - * Overrides fstream:open so derived classes can make appropriate - * internal changes (line count, header info, etc). - */ - void FFStream::open( const char* fn, std::ios::openmode mode ) - { - std::fstream::open(fn, mode); + FFStream::FFStream() + : recordNumber(0) + { + } + + FFStream::FFStream(std::basic_iostream& anotherStream) + { + this->init(anotherStream.rdbuf()); + recordNumber = 0; + clear(); + } + + FFStream::FFStream(const char* fn, std::ios::openmode mode) + { + open(fn, mode); + } + + FFStream::FFStream(const std::string& fn, std::ios::openmode mode) + { + open(fn.c_str(), mode); + } - filename = std::string(fn); - recordNumber = 0; - clear(); + /* + * Overrides fstream:open so derived classes can make appropriate + * internal changes (line count, header info, etc). + */ + void FFStream::open( const char* fn, std::ios::openmode mode ) + { + filename = std::string(fn); + recordNumber = 0; + fileStream.open(fn, mode); + rdbuf(fileStream.rdbuf()); + clear(); - } // End of method 'FFStream::open()' + } // End of method 'FFStream::open()' - // A function to help debug FFStreams - void FFStream::dumpState(std::ostream& s) const - { + // A function to help debug FFStreams - s << "filename:" << filename - << ", recordNumber:" << recordNumber; - s << ", exceptions:"; + void FFStream::dumpState(std::ostream& s) const + { - if (exceptions() & std::ios::badbit) s << "bad "; - if (exceptions() & std::ios::failbit) s << "fail "; - if (exceptions() & std::ios::eofbit) s << "eof "; - if (exceptions() == 0) s << "none"; + s << "filename:" << filename + << ", recordNumber:" << recordNumber; + s << ", exceptions:"; - s << ", rdstate:"; + if (exceptions() & std::ios::badbit) s << "bad "; + if (exceptions() & std::ios::failbit) s << "fail "; + if (exceptions() & std::ios::eofbit) s << "eof "; + if (exceptions() == 0) s << "none"; - if (rdstate() & std::ios::badbit) s << "bad "; - if (rdstate() & std::ios::failbit) s << "fail "; - if (rdstate() & std::ios::eofbit) s << "eof "; - if (rdstate() == 0) s << "none"; - s << std::endl; + s << ", rdstate:"; - } // End of method 'FFStream::dumpState()' + if (rdstate() & std::ios::badbit) s << "bad "; + if (rdstate() & std::ios::failbit) s << "fail "; + if (rdstate() & std::ios::eofbit) s << "eof "; + if (rdstate() == 0) s << "none"; + s << std::endl; + } // End of method 'FFStream::dumpState()' - // the crazy double try block is so that no gpstk::Exception throws - // get masked, allowing all exception information (line numbers, text, - // etc) to be retained. - void FFStream::tryFFStreamGet(FFData& rec) - throw(FFStreamError, gpstk::StringUtils::StringException) - { - // Mark where we start in case there is an error. - long initialPosition = tellg(); - unsigned long initialRecordNumber = recordNumber; - clear(); + // the crazy double try block is so that no gpstk::Exception throws + // get masked, allowing all exception information (line numbers, text, + // etc) to be retained. + void FFStream::tryFFStreamGet(FFData& rec) + throw (FFStreamError, gpstk::StringUtils::StringException) + { + + // Mark where we start in case there is an error. + long initialPosition = tellg(); + unsigned long initialRecordNumber = recordNumber; + clear(); + + try + { try { - try - { - rec.reallyGetRecord(*this); - recordNumber++; - } - catch (EndOfFile& e) - { - // EOF - do nothing - eof causes fail() to be set which - // is handled by std::fstream - e.addText("In record " + - gpstk::StringUtils::asString(recordNumber)); - e.addText("In file " + filename); - e.addLocation(FILE_LOCATION); - mostRecentException = e; - } - catch (std::exception &e) - { - mostRecentException = FFStreamError("std::exception thrown: " + - std::string(e.what())); - mostRecentException.addText("In record " + - gpstk::StringUtils::asString(recordNumber)); - mostRecentException.addText("In file " + filename); - mostRecentException.addLocation(FILE_LOCATION); - clear(); - seekg(initialPosition); - recordNumber = initialRecordNumber; - setstate(std::ios::failbit); - conditionalThrow(); - } - catch (gpstk::StringUtils::StringException& e) - { - e.addText("In record " + - gpstk::StringUtils::asString(recordNumber)); - e.addText("In file " + filename); - e.addLocation(FILE_LOCATION); - mostRecentException = e; - clear(); - seekg(initialPosition); - recordNumber = initialRecordNumber; - setstate(std::ios::failbit); - conditionalThrow(); - } - // catches some errors we can encounter - catch (FFStreamError& e) - { - e.addText("In record " + - gpstk::StringUtils::asString(recordNumber)); - e.addText("In file " + filename); - e.addLocation(FILE_LOCATION); - mostRecentException = e; - clear(); - seekg(initialPosition); - recordNumber = initialRecordNumber; - setstate(std::ios::failbit); - conditionalThrow(); - } + rec.reallyGetRecord(*this); + recordNumber++; } - // this is if you throw an FFStream error in the above catch - // block because the catch(...) below will mask it otherwise. - // This also takes care of catching StringExceptions - catch (gpstk::Exception &e) + catch (EndOfFile& e) { - GPSTK_RETHROW(e); + // EOF - do nothing - eof causes fail() to be set which + // is handled by std::fstream + e.addText("In record " + + gpstk::StringUtils::asString(recordNumber)); + e.addText("In file " + filename); + e.addLocation(FILE_LOCATION); + mostRecentException = e; } - catch (std::ifstream::failure &e) + catch (std::exception &e) { - // setting failbit when catching FFStreamError can cause - // this exception to be thrown. in this case, we don't want - // to lose the exception info so only make a new exception - // if this isn't a fail() case - if (!fail()) - { - mostRecentException = FFStreamError("ifstream::failure thrown: " + - std::string(e.what())); - mostRecentException.addText("In file " + filename); - mostRecentException.addLocation(FILE_LOCATION); - } - conditionalThrow(); + mostRecentException = FFStreamError("std::exception thrown: " + + std::string(e.what())); + mostRecentException.addText("In record " + + gpstk::StringUtils::asString(recordNumber)); + mostRecentException.addText("In file " + filename); + mostRecentException.addLocation(FILE_LOCATION); + clear(); + seekg(initialPosition); + recordNumber = initialRecordNumber; + setstate(std::ios::failbit); + conditionalThrow(); } - catch (std::exception &e) + catch (gpstk::StringUtils::StringException& e) { - mostRecentException = FFStreamError("std::exception thrown: " + - std::string(e.what())); - mostRecentException.addText("In file " + filename); - mostRecentException.addLocation(FILE_LOCATION); - setstate(std::ios::failbit); - conditionalThrow(); + e.addText("In record " + + gpstk::StringUtils::asString(recordNumber)); + e.addText("In file " + filename); + e.addLocation(FILE_LOCATION); + mostRecentException = e; + clear(); + seekg(initialPosition); + recordNumber = initialRecordNumber; + setstate(std::ios::failbit); + conditionalThrow(); } - catch (...) + // catches some errors we can encounter + catch (FFStreamError& e) { - mostRecentException = FFStreamError("Unknown exception thrown"); - mostRecentException.addText("In file " + filename); - mostRecentException.addLocation(FILE_LOCATION); - setstate(std::ios::failbit); - conditionalThrow(); + e.addText("In record " + + gpstk::StringUtils::asString(recordNumber)); + e.addText("In file " + filename); + e.addLocation(FILE_LOCATION); + mostRecentException = e; + clear(); + seekg(initialPosition); + recordNumber = initialRecordNumber; + setstate(std::ios::failbit); + conditionalThrow(); } - - } // End of method 'FFStream::tryFFStreamGet()' - - - - // the crazy double try block is so that no gpstk::Exception throws - // get masked, allowing all exception information (line numbers, text, - // etc) to be retained. - void FFStream::tryFFStreamPut(const FFData& rec) - throw(FFStreamError, gpstk::StringUtils::StringException) - { - // Mark where we start in case there is an error. - long initialPosition = tellg(); - unsigned long initialRecordNumber = recordNumber; - clear(); - + } + // this is if you throw an FFStream error in the above catch + // block because the catch(...) below will mask it otherwise. + // This also takes care of catching StringExceptions + catch (gpstk::Exception &e) + { + GPSTK_RETHROW(e); + } + catch (std::ifstream::failure &e) + { + // setting failbit when catching FFStreamError can cause + // this exception to be thrown. in this case, we don't want + // to lose the exception info so only make a new exception + // if this isn't a fail() case + if (!fail()) + { + mostRecentException = FFStreamError("ifstream::failure thrown: " + + std::string(e.what())); + mostRecentException.addText("In file " + filename); + mostRecentException.addLocation(FILE_LOCATION); + } + conditionalThrow(); + } + catch (std::exception &e) + { + mostRecentException = FFStreamError("std::exception thrown: " + + std::string(e.what())); + mostRecentException.addText("In file " + filename); + mostRecentException.addLocation(FILE_LOCATION); + setstate(std::ios::failbit); + conditionalThrow(); + } + catch (...) + { + mostRecentException = FFStreamError("Unknown exception thrown"); + mostRecentException.addText("In file " + filename); + mostRecentException.addLocation(FILE_LOCATION); + setstate(std::ios::failbit); + conditionalThrow(); + } + + } // End of method 'FFStream::tryFFStreamGet()' + + + + // the crazy double try block is so that no gpstk::Exception throws + // get masked, allowing all exception information (line numbers, text, + // etc) to be retained. + + void FFStream::tryFFStreamPut(const FFData& rec) + throw (FFStreamError, gpstk::StringUtils::StringException, std::bad_cast) + { + // Mark where we start in case there is an error. + long initialPosition = tellg(); + unsigned long initialRecordNumber = recordNumber; + clear(); + + try + { try { - try - { - rec.reallyPutRecord(*this); - recordNumber++; - } - catch (std::exception &e) - { - // if this is a stream failure, don't mask it and let the - // later catch block handle it - if (dynamic_cast(&e)) - throw; - - // the catch(FFStreamError) below will add file information - // to this exception - mostRecentException = FFStreamError("std::exception thrown: " + - std::string(e.what())); - mostRecentException.addLocation(FILE_LOCATION); - setstate(std::ios::failbit); - conditionalThrow(); - } - catch (gpstk::StringUtils::StringException& e) - { - e.addText("In record " + - gpstk::StringUtils::asString(recordNumber)); - e.addText("In file " + filename); - e.addLocation(FILE_LOCATION); - mostRecentException = e; - seekg(initialPosition); - recordNumber = initialRecordNumber; - setstate(std::ios::failbit); - conditionalThrow(); - } - // catches some errors we can encounter - catch (FFStreamError& e) - { - e.addText("In record " + - gpstk::StringUtils::asString(recordNumber)); - e.addText("In file " + filename); - e.addLocation(FILE_LOCATION); - mostRecentException = e; - seekg(initialPosition); - recordNumber = initialRecordNumber; - setstate(std::ios::failbit); - conditionalThrow(); - } + rec.reallyPutRecord(*this); + recordNumber++; } - // this is if you throw an FFStream error in the above catch - // block because the catch(...) below will mask it otherwise. - // This also takes care of catching StringExceptions - catch (gpstk::Exception &e) + catch (std::exception &e) { - GPSTK_RETHROW(e); + // if this is a stream failure, don't mask it and let the + // later catch block handle it + if (dynamic_cast (&e)) + throw; + + // the catch(FFStreamError) below will add file information + // to this exception + mostRecentException = FFStreamError("std::exception thrown: " + + std::string(e.what())); + mostRecentException.addLocation(FILE_LOCATION); + setstate(std::ios::failbit); + conditionalThrow(); } - catch (std::ifstream::failure &e) + catch (gpstk::StringUtils::StringException& e) { - // setting failbit when catching FFStreamError can cause - // this exception to be thrown. in this case, we don't want - // to lose the exception info so only make a new exception - // if this isn't a fail() case - if (!fail()) - { - mostRecentException = FFStreamError("ifstream::failure thrown: " + - std::string(e.what())); - mostRecentException.addText("In file " + filename); - mostRecentException.addLocation(FILE_LOCATION); - } - conditionalThrow(); + e.addText("In record " + + gpstk::StringUtils::asString(recordNumber)); + e.addText("In file " + filename); + e.addLocation(FILE_LOCATION); + mostRecentException = e; + seekg(initialPosition); + recordNumber = initialRecordNumber; + setstate(std::ios::failbit); + conditionalThrow(); } - catch (std::exception &e) + // catches some errors we can encounter + catch (FFStreamError& e) { - mostRecentException = FFStreamError("std::exception thrown: " + - std::string(e.what())); - mostRecentException.addText("In file " + filename); - mostRecentException.addLocation(FILE_LOCATION); - setstate(std::ios::failbit); - conditionalThrow(); + e.addText("In record " + + gpstk::StringUtils::asString(recordNumber)); + e.addText("In file " + filename); + e.addLocation(FILE_LOCATION); + mostRecentException = e; + seekg(initialPosition); + recordNumber = initialRecordNumber; + setstate(std::ios::failbit); + conditionalThrow(); } - catch (...) + } + // this is if you throw an FFStream error in the above catch + // block because the catch(...) below will mask it otherwise. + // This also takes care of catching StringExceptions + catch (gpstk::Exception &e) + { + GPSTK_RETHROW(e); + } + catch (std::ifstream::failure &e) + { + // setting failbit when catching FFStreamError can cause + // this exception to be thrown. in this case, we don't want + // to lose the exception info so only make a new exception + // if this isn't a fail() case + if (!fail()) { - mostRecentException = FFStreamError("Unknown exception thrown"); - mostRecentException.addText("In file " + filename); - mostRecentException.addLocation(FILE_LOCATION); - setstate(std::ios::failbit); - conditionalThrow(); + mostRecentException = FFStreamError("ifstream::failure thrown: " + + std::string(e.what())); + mostRecentException.addText("In file " + filename); + mostRecentException.addLocation(FILE_LOCATION); } + conditionalThrow(); + } + catch (std::exception &e) + { + mostRecentException = FFStreamError("std::exception thrown: " + + std::string(e.what())); + mostRecentException.addText("In file " + filename); + mostRecentException.addLocation(FILE_LOCATION); + setstate(std::ios::failbit); + conditionalThrow(); + } + catch (...) + { + mostRecentException = FFStreamError("Unknown exception thrown"); + mostRecentException.addText("In file " + filename); + mostRecentException.addLocation(FILE_LOCATION); + setstate(std::ios::failbit); + conditionalThrow(); + } + + } // End of method 'FFStream::tryFFStreamPut()' + + void FFStream::close() + { + if (fileStream && fileStream.is_open()) + fileStream.close(); + } + + bool FFStream::is_open() + { + if (fileStream) + return fileStream.is_open(); + return true; + } + - } // End of method 'FFStream::tryFFStreamPut()' diff --git a/dev/lib/FileHandling/FFStream.hpp b/dev/lib/FileHandling/FFStream.hpp index 550b4b3e7..0fbc26c56 100755 --- a/dev/lib/FileHandling/FFStream.hpp +++ b/dev/lib/FileHandling/FFStream.hpp @@ -1,21 +1,12 @@ #pragma ident "$Id$" -/** - * @file FFStream.hpp - * Formatted File Stream, root class to provide formatted I/O - * operators ('<<' & '>>') - */ - -#ifndef GPSTK_FFSTREAM_HPP -#define GPSTK_FFSTREAM_HPP - //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -26,7 +17,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// +// // Copyright 2004, The University of Texas at Austin // //============================================================================ @@ -34,21 +25,29 @@ //============================================================================ // //This software developed by Applied Research Laboratories at the University of -//Texas at Austin, under contract to an agency or agencies within the U.S. +//Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use, -//duplicate, distribute, disclose, or release this software. +//duplicate, distribute, disclose, or release this software. // -//Pursuant to DoD Directive 523024 +//Pursuant to DoD Directive 523024 // -// DISTRIBUTION STATEMENT A: This software has been approved for public +// DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited. // //============================================================================= +/** + * @file FFStream.hpp + * Formatted File Stream, root class to provide formatted I/O + * operators ('<<' & '>>') + */ +#ifndef GPSTK_FFSTREAM_HPP +#define GPSTK_FFSTREAM_HPP #include #include +#include #include #include @@ -117,7 +116,7 @@ namespace gpstk * @warning When using open(), the internal header data of the stream * is not guaranteed to be retained. */ - class FFStream : public std::fstream + class FFStream : public std::basic_iostream { public: @@ -128,18 +127,20 @@ namespace gpstk /** * Default constructor */ - FFStream() - : recordNumber(0) {}; - + FFStream(); + + /** Construction from another stream for decoration + * + * @param anotherStream + */ + FFStream(std::basic_iostream& anotherStream); /** Common constructor. * * @param fn file name. * @param mode file open mode (std::ios) */ - FFStream( const char* fn, std::ios::openmode mode=std::ios::in ) - : std::fstream(fn, mode), recordNumber(0), filename(fn) - { clear(); } + FFStream( const char* fn, std::ios::openmode mode=std::ios::in ); /** Common constructor. @@ -147,9 +148,7 @@ namespace gpstk * @param fn file name. * @param mode file open mode (std::ios) */ - FFStream( const std::string& fn, std::ios::openmode mode=std::ios::in ) - : std::fstream(fn.c_str(), mode), recordNumber(0), filename(fn) - { clear(); }; + FFStream( const std::string& fn, std::ios::openmode mode=std::ios::in ); /** @@ -205,6 +204,9 @@ namespace gpstk return true; } + + virtual void close(); + virtual bool is_open(); ///@name Data members @@ -221,14 +223,17 @@ namespace gpstk std::string filename; //@} - + + /// FFData is a friend so it can access the try* functions. friend class FFData; protected: - + + std::fstream fileStream; // used only in file system case; + /// Encapsulates shared try/catch blocks for all file types /// to hide std::exception. @@ -239,7 +244,7 @@ namespace gpstk /// Encapsulates shared try/catch blocks for all file types /// to hide std::exception. virtual void tryFFStreamPut(const FFData& rec) - throw(FFStreamError, gpstk::StringUtils::StringException); + throw(FFStreamError, gpstk::StringUtils::StringException,std::bad_cast); }; // End of class 'FFStream' diff --git a/dev/lib/FileHandling/FFTextStream.cpp b/dev/lib/FileHandling/FFTextStream.cpp new file mode 100644 index 000000000..84c307d14 --- /dev/null +++ b/dev/lib/FileHandling/FFTextStream.cpp @@ -0,0 +1,113 @@ +#include "FFTextStream.hpp" + +#include + +using namespace gpstk; +using namespace std; + +// the reason for checking ffs.eof() in the try AND catch block is +// because if the user enabled exceptions on the stream with exceptions() +// then eof could throw an exception, in which case we need to catch it +// and rethrow an EOF or FFStream exception. In any event, EndOfFile +// gets thrown whenever there's an EOF and expectEOF is true +void FFTextStream::formattedGetLine( std::string& line, + const bool expectEOF ) + throw(EndOfFile, FFStreamError, gpstk::StringUtils::StringException) +{ + try + { + // The following constant used to be 256, but with the change to + // RINEX3 formats the possible length of a line increased + // considerably. A RINEX3 observation file line for Galileo may + // be 1277 characters long (taking into account all the possible + // types of observations available, plus the end of line + // characters), so this constant was conservatively set to + // 1500 characters. Dagoberto Salazar. + const int MAX_LINE_LENGTH = 1500; + char templine[MAX_LINE_LENGTH + 1]; + getline(templine, MAX_LINE_LENGTH); + lineNumber++; + //check if line was longer than 256 characters, if so error + if(fail() && !eof()) + { + FFStreamError err("Line too long"); + GPSTK_THROW(err); + } + line = templine; + gpstk::StringUtils::stripTrailing(line, '\r'); + // catch EOF when stream exceptions are disabled + if ((gcount() == 0) && eof()) + { + if (expectEOF) + { + EndOfFile err("EOF encountered"); + GPSTK_THROW(err); + } + else + { + FFStreamError err("Unexpected EOF encountered"); + GPSTK_THROW(err); + } + } + } + catch(std::exception &e) + { + // catch EOF when exceptions are enabled + if ((gcount() == 0) && eof()) + { + if (expectEOF) + { + EndOfFile err("EOF encountered"); + GPSTK_THROW(err); + } + else + { + FFStreamError err("Unexpected EOF"); + GPSTK_THROW(err); + } + } + else + { + FFStreamError err("Critical file error: " + + std::string(e.what())); + GPSTK_THROW(err); + } // End of 'if ( (gcount() == 0) && eof())' + + } // End of 'try-catch' block + +} // End of method 'FFTextStream::formattedGetLine()' + +void FFTextStream::tryFFStreamGet(FFData& rec) + throw(FFStreamError, gpstk::StringUtils::StringException) { + + unsigned int initialLineNumber = lineNumber; + + try { + FFStream::tryFFStreamGet(rec); + } catch (gpstk::Exception& e) { + e.addText(std::string("Near file line ") + + gpstk::StringUtils::asString(lineNumber)); + lineNumber = initialLineNumber; + mostRecentException = e; + conditionalThrow(); + } + +} + +void FFTextStream::tryFFStreamPut(const FFData& rec) + throw(FFStreamError, gpstk::StringUtils::StringException,std::bad_cast) { + + unsigned int initialLineNumber = lineNumber; + + try { + FFStream::tryFFStreamPut(rec); + } catch (gpstk::Exception& e) { + e.addText(std::string("Near file line ") + + gpstk::StringUtils::asString(lineNumber)); + lineNumber = initialLineNumber; + mostRecentException = e; + conditionalThrow(); + } + +} + diff --git a/dev/lib/FileHandling/FFTextStream.hpp b/dev/lib/FileHandling/FFTextStream.hpp index 82b792fa3..754899f16 100755 --- a/dev/lib/FileHandling/FFTextStream.hpp +++ b/dev/lib/FileHandling/FFTextStream.hpp @@ -1,20 +1,12 @@ #pragma ident "$Id$" -/** - * @file FFTextStream.hpp - * An FFStream for text files - */ - -#ifndef GPSTK_FFTEXTSTREAM_HPP -#define GPSTK_FFTEXTSTREAM_HPP - //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -25,7 +17,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// +// // Copyright 2004, The University of Texas at Austin // //============================================================================ @@ -33,18 +25,24 @@ //============================================================================ // //This software developed by Applied Research Laboratories at the University of -//Texas at Austin, under contract to an agency or agencies within the U.S. +//Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use, -//duplicate, distribute, disclose, or release this software. +//duplicate, distribute, disclose, or release this software. // -//Pursuant to DoD Directive 523024 +//Pursuant to DoD Directive 523024 // -// DISTRIBUTION STATEMENT A: This software has been approved for public +// DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited. // //============================================================================= +/** + * @file FFTextStream.hpp + * An FFStream for text files + */ +#ifndef GPSTK_FFTEXTSTREAM_HPP +#define GPSTK_FFTEXTSTREAM_HPP #include "FFStream.hpp" @@ -76,7 +74,10 @@ namespace gpstk FFTextStream() : lineNumber(0) {}; - + + FFTextStream(std::basic_iostream& anotherStream) + : FFStream(anotherStream), lineNumber(0) + {}; /** Common constructor. * * @param fn file name. @@ -131,138 +132,23 @@ namespace gpstk * @warning There is a maximum line length of 1500 characters when * using this function. */ - inline void formattedGetLine( std::string& line, + void formattedGetLine( std::string& line, const bool expectEOF = false ) throw(EndOfFile, FFStreamError, gpstk::StringUtils::StringException); protected: - /// calls FFStream::tryFFStreamGet and adds line number information virtual void tryFFStreamGet(FFData& rec) - throw(FFStreamError, gpstk::StringUtils::StringException) - { - - unsigned int initialLineNumber = lineNumber; - - try - { - FFStream::tryFFStreamGet(rec); - } - catch(gpstk::Exception& e) - { - e.addText( std::string("Near file line ") + - gpstk::StringUtils::asString(lineNumber) ); - lineNumber = initialLineNumber; - mostRecentException = e; - conditionalThrow(); - } - - }; + throw(FFStreamError, gpstk::StringUtils::StringException); /// calls FFStream::tryFFStreamPut and adds line number information virtual void tryFFStreamPut(const FFData& rec) - throw(FFStreamError, gpstk::StringUtils::StringException) - { - - unsigned int initialLineNumber = lineNumber; - - try - { - FFStream::tryFFStreamPut(rec); - } - catch(gpstk::Exception& e) - { - e.addText( std::string("Near file line ") + - gpstk::StringUtils::asString(lineNumber) ); - lineNumber = initialLineNumber; - mostRecentException = e; - conditionalThrow(); - } - - } + throw(FFStreamError, gpstk::StringUtils::StringException, std::bad_cast); }; // End of class 'FFTextStream' - - - // the reason for checking ffs.eof() in the try AND catch block is - // because if the user enabled exceptions on the stream with exceptions() - // then eof could throw an exception, in which case we need to catch it - // and rethrow an EOF or FFStream exception. In any event, EndOfFile - // gets thrown whenever there's an EOF and expectEOF is true - void FFTextStream::formattedGetLine( std::string& line, - const bool expectEOF ) - throw(EndOfFile, FFStreamError, gpstk::StringUtils::StringException) - { - - try - { - // The following constant used to be 256, but with the change to - // RINEX3 formats the possible length of a line increased - // considerably. A RINEX3 observation file line for Galileo may - // be 1277 characters long (taking into account all the possible - // types of observations available, plus the end of line - // characters), so this constant was conservatively set to - // 1500 characters. Dagoberto Salazar. - const int MAX_LINE_LENGTH = 1500; - char templine[MAX_LINE_LENGTH + 1]; - getline(templine, MAX_LINE_LENGTH); - lineNumber++; - //check if line was longer than 256 characters, if so error - if(fail() && !eof()) - { - FFStreamError err("Line too long"); - GPSTK_THROW(err); - } - line = templine; - gpstk::StringUtils::stripTrailing(line, '\r'); - // catch EOF when stream exceptions are disabled - if ((gcount() == 0) && eof()) - { - if (expectEOF) - { - EndOfFile err("EOF encountered"); - GPSTK_THROW(err); - } - else - { - FFStreamError err("Unexpected EOF encountered"); - GPSTK_THROW(err); - } - } - } - catch(std::exception &e) - { - - // catch EOF when exceptions are enabled - if ( (gcount() == 0) && eof()) - { - if (expectEOF) - { - EndOfFile err("EOF encountered"); - GPSTK_THROW(err); - } - else - { - FFStreamError err("Unexpected EOF"); - GPSTK_THROW(err); - } - } - else - { - FFStreamError err("Critical file error: " + - std::string(e.what())); - GPSTK_THROW(err); - } // End of 'if ( (gcount() == 0) && eof())' - - } // End of 'try-catch' block - - } // End of method 'FFTextStream::formattedGetLine()' - - //@} - } // End of namespace gpstk #endif // GPSTK_FFTEXTSTREAM_HPP diff --git a/dev/lib/FileHandling/RINEX3/Rinex3ClockData.cpp b/dev/lib/FileHandling/RINEX3/Rinex3ClockData.cpp index 83e221df4..25d558919 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3ClockData.cpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3ClockData.cpp @@ -1,18 +1,12 @@ #pragma ident "$Id$" -/** - * @file Rinex3ClockData.cpp - * Encapsulate RINEX3 clock data file, including I/O - * See more at: ftp://igscb.jpl.nasa.gov/pub/data/format/rinex_clock.txt - */ - //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -23,11 +17,31 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// -// Octavian Andrei - FGI ( http://www.fgi.fi ). 2008 +// +// Copyright 2004, The University of Texas at Austin // //============================================================================ +//============================================================================ +// +//This software developed by Applied Research Laboratories at the University of +//Texas at Austin, under contract to an agency or agencies within the U.S. +//Department of Defense. The U.S. Government retains all rights to use, +//duplicate, distribute, disclose, or release this software. +// +//Pursuant to DoD Directive 523024 +// +// DISTRIBUTION STATEMENT A: This software has been approved for public +// release, distribution is unlimited. +// +//============================================================================= + +/** + * @file Rinex3ClockData.cpp + * Encapsulate RINEX3 clock data file, including I/O + * See more at: ftp://igscb.jpl.nasa.gov/pub/data/format/rinex_clock.txt + */ + //GPSTk #include "CivilTime.hpp" #include "Rinex3ClockData.hpp" @@ -68,8 +82,6 @@ namespace gpstk // This function parses the entire header from the given stream void Rinex3ClockData::reallyGetRecord(FFStream& ffs) - throw(std::exception, FFStreamError, - StringUtils::StringException) { Rinex3ClockStream& strm = dynamic_cast(ffs); diff --git a/dev/lib/FileHandling/RINEX3/Rinex3ClockData.hpp b/dev/lib/FileHandling/RINEX3/Rinex3ClockData.hpp index 33212be4b..c5b7b069b 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3ClockData.hpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3ClockData.hpp @@ -1,21 +1,12 @@ #pragma ident "$Id$" -/** - * @file Rinex3Clockdata.hpp - * Encapsulate RINEX3 clock data file, including I/O - * See more at: ftp://igscb.jpl.nasa.gov/pub/data/format/rinex_clock.txt - */ - -#ifndef GPSTK_RINEX3CLOCKDATA_HPP -#define GPSTK_RINEX3CLOCKDATA_HPP - //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -26,11 +17,34 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// -// Octavian Andrei - FGI ( http://www.fgi.fi ). 2008 +// +// Copyright 2004, The University of Texas at Austin // //============================================================================ +//============================================================================ +// +//This software developed by Applied Research Laboratories at the University of +//Texas at Austin, under contract to an agency or agencies within the U.S. +//Department of Defense. The U.S. Government retains all rights to use, +//duplicate, distribute, disclose, or release this software. +// +//Pursuant to DoD Directive 523024 +// +// DISTRIBUTION STATEMENT A: This software has been approved for public +// release, distribution is unlimited. +// +//============================================================================= + +/** + * @file Rinex3Clockdata.hpp + * Encapsulate RINEX3 clock data file, including I/O + * See more at: ftp://igscb.jpl.nasa.gov/pub/data/format/rinex_clock.txt + */ + +#ifndef GPSTK_RINEX3CLOCKDATA_HPP +#define GPSTK_RINEX3CLOCKDATA_HPP + //system #include //GPSTk @@ -115,9 +129,7 @@ namespace gpstk * a read or formatting error occurs. This also resets the * stream to its pre-read position. */ - virtual void reallyGetRecord(FFStream& s) - throw(std::exception, FFStreamError, - gpstk::StringUtils::StringException); + virtual void reallyGetRecord(FFStream& s); private: /// Writes the CommonTime object into RINEX format. If it's a bad time, diff --git a/dev/lib/FileHandling/RINEX3/Rinex3Datum.h b/dev/lib/FileHandling/RINEX3/Rinex3Datum.h new file mode 100644 index 000000000..383cb22a6 --- /dev/null +++ b/dev/lib/FileHandling/RINEX3/Rinex3Datum.h @@ -0,0 +1,24 @@ +/* + * File: Rinex3Datum.h + * Author: alex + * + * Created on April 3, 2015, 1:35 PM + */ + +#ifndef RINEX3DATUM_H +#define RINEX3DATUM_H + +/// A structure used to store a single RINEX Data point. + +struct Rinex3Datum +{ + inline Rinex3Datum(double data = 0, short lli = 0, short ssi = 0, bool isEmpty = false) : + data(data), lli(lli), ssi(ssi), isEmpty(isEmpty) { } ///< constructor + double data; ///< The actual data point. + short lli; ///< See the RINEX Spec. for an explanation. + short ssi; ///< See the RINEX Spec. for an explanation. + bool isEmpty; +}; + +#endif /* RINEX3DATUM_H */ + diff --git a/dev/lib/FileHandling/RINEX3/Rinex3NavData.cpp b/dev/lib/FileHandling/RINEX3/Rinex3NavData.cpp index c6363fdc8..01e3d5d17 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3NavData.cpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3NavData.cpp @@ -1,5 +1,4 @@ -/// @file Rinex3NavData.cpp -/// Encapsulates RINEX 3 Navigation data. +#pragma ident "$Id$" //============================================================================ // @@ -7,7 +6,7 @@ // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -18,7 +17,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// +// // Copyright 2004, The University of Texas at Austin // //============================================================================ @@ -26,17 +25,20 @@ //============================================================================ // //This software developed by Applied Research Laboratories at the University of -//Texas at Austin, under contract to an agency or agencies within the U.S. +//Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use, -//duplicate, distribute, disclose, or release this software. +//duplicate, distribute, disclose, or release this software. // -//Pursuant to DoD Directive 523024 +//Pursuant to DoD Directive 523024 // -// DISTRIBUTION STATEMENT A: This software has been approved for public +// DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited. // //============================================================================= +/// @file Rinex3NavData.cpp +/// Encapsulates RINEX 3 Navigation data. + #include "Rinex3NavData.hpp" #include "CivilTime.hpp" @@ -47,6 +49,7 @@ #include "TimeString.hpp" #include "GNSSconstants.hpp" #include "StringUtils.hpp" +#include namespace gpstk { @@ -74,6 +77,7 @@ namespace gpstk // clock Toc = rnd.Toc; + assert(Toc >= 0 && Toc < (FULLWEEK)); af0 = rnd.af0; af1 = rnd.af1; af2 = rnd.af2; @@ -110,6 +114,7 @@ namespace gpstk PRNID = sat.id; //Toc = static_cast(oeptr->ctToe).getSOW(); + Toc = 0.0; af0 = oeptr->af0; af1 = oeptr->af1; af2 = oeptr->af2; @@ -139,11 +144,12 @@ namespace gpstk loadFrom(dynamic_cast(&gpseph)); Toc = static_cast(gpseph.ctToc).getSOW(); + assert(Toc >= 0 && Toc < (FULLWEEK)); Toe = static_cast(gpseph.ctToe).getSOW(); HOWtime = gpseph.HOWtime; weeknum = static_cast(gpseph.transmitTime).getWeek(); - accuracy = gpseph.accuracyFlag; + accuracy = gpseph.accuracy; health = gpseph.health; codeflgs = gpseph.codeflags; @@ -163,6 +169,7 @@ namespace gpstk loadFrom(dynamic_cast(&galeph)); Toc = static_cast(galeph.ctToc).getSOW(); + assert(Toc >= 0 && Toc < (FULLWEEK)); Toe = static_cast(galeph.ctToe).getSOW(); HOWtime = galeph.HOWtime; weeknum = static_cast(galeph.transmitTime).getWeek(); @@ -181,6 +188,7 @@ namespace gpstk loadFrom(dynamic_cast(&bdseph)); Toc = static_cast(bdseph.ctToc).getSOW(); + assert(Toc >= 0 && Toc < (FULLWEEK)); Toe = static_cast(bdseph.ctToe).getSOW(); HOWtime = bdseph.HOWtime; weeknum = static_cast(bdseph.transmitTime).getWeek(); @@ -200,6 +208,7 @@ namespace gpstk loadFrom(dynamic_cast(&qzseph)); Toc = static_cast(qzseph.ctToc).getSOW(); + assert(Toc >= 0 && Toc < (FULLWEEK)); Toe = static_cast(qzseph.ctToe).getSOW(); HOWtime = qzseph.HOWtime; weeknum = static_cast(qzseph.transmitTime).getWeek(); @@ -232,6 +241,7 @@ namespace gpstk time = ee.getEpochTime(); Toc = ee.getToc(); + assert(Toc >= 0 && Toc < (FULLWEEK)); HOWtime = long(ee.getHOWTime(1)); weeknum = ee.getFullWeek(); @@ -288,6 +298,8 @@ namespace gpstk sat = RinexSatID(PRNID,SatID::systemGlonass); time = gloe.getEpochTime(); + Toc = 0.0; + // GLONASS parameters TauN = gloe.getTauN(); GammaN = gloe.getGammaN(); @@ -324,7 +336,6 @@ namespace gpstk * to its pre-read position. */ void Rinex3NavData::reallyGetRecord(FFStream& ffs) - throw(exception, FFStreamError, StringException) { try { @@ -633,13 +644,34 @@ namespace gpstk if(!gpse.dataLoadedFlag) return gpse; // throw? + // Special case to address common problem in IGS aggregate brdc + // files. In some cases (typ. beginning of week) the last + // SF 1/2/3 for the previous day is being output with a HOWtime of + // zero. This leaves it in conflict with the first SF 1/2/3 of + // the new day (which typically has a HOW of zero) + long adjHOWtime = HOWtime; + short adjWeeknum = weeknum; + long lToc = (long) Toc; + if ((HOWtime%SEC_PER_DAY)==0 && + ((lToc)%SEC_PER_DAY)==0 && + HOWtime == lToc) + { + adjHOWtime = HOWtime - 30; + if (adjHOWtime<0) + { + adjHOWtime += FULLWEEK; + adjWeeknum--; + } + } + // end special case adjustment (except for use of adjHOWtime below) + // get the epochs right CommonTime ct = time; //unsigned int year = static_cast(ct).year; // Get week for clock, to build Toc - double dt = Toc - HOWtime; - int week = weeknum; + double dt = Toc - adjHOWtime; + int week = adjWeeknum; if(dt < -HALFWEEK) week++; else if(dt > HALFWEEK) week--; gpse.ctToc = GPSWeekSecond(week, Toc, TimeSystem::GPS); gpse.ctToc.setTimeSystem(TimeSystem::GPS); @@ -648,12 +680,13 @@ namespace gpstk gpse.IODC = IODC; gpse.IODE = IODE; gpse.health = health; - gpse.accuracyFlag = accuracy; + gpse.accuracy = accuracy; gpse.Tgd = Tgd; gpse.HOWtime = HOWtime; week = static_cast(gpse.ctToe).getWeek(); - gpse.transmitTime = GPSWeekSecond(weeknum, static_cast(HOWtime), + + gpse.transmitTime = GPSWeekSecond(adjWeeknum, static_cast(adjHOWtime), TimeSystem::GPS); gpse.codeflags = codeflgs; @@ -931,7 +964,13 @@ namespace gpstk if(satSys == "R" || satSys == "S") { line += doubleToScientific(TauN,19,12,2); line += doubleToScientific(GammaN,19,12,2); - line += doubleToScientific((double)MFtime,19,12,2); + if(satSys == "R" && strm.header.version < 3) { + long mftime = MFtime; + mftime -= int(Toc/86400) * 86400; + line += doubleToScientific((double)mftime,19,12,2); + } else { + line += doubleToScientific((double)MFtime,19,12,2); + } } else if(satSys == "G" || satSys == "E" || satSys == "J" || satSys == "C") { line += doubleToScientific(af0,19,12,2); @@ -1168,6 +1207,8 @@ namespace gpstk GPSWeekSecond gws(time); // sow is system-independent Toc = gws.sow; + assert(Toc >= 0 && Toc < (FULLWEEK)); + if(strm.header.version < 3) { // Rinex 2.* if(satSys == "G") { af0 = StringUtils::for2doub(line.substr(22,19)); diff --git a/dev/lib/FileHandling/RINEX3/Rinex3NavData.hpp b/dev/lib/FileHandling/RINEX3/Rinex3NavData.hpp index d669e3e2c..a5047fe4a 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3NavData.hpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3NavData.hpp @@ -1,5 +1,4 @@ -/// @file Rinex3NavData.hpp -/// Encapsulates RINEX ver 3.02 Navigation data +#pragma ident "$Id$" //============================================================================ // @@ -7,7 +6,7 @@ // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -18,7 +17,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// +// // Copyright 2004, The University of Texas at Austin // //============================================================================ @@ -28,15 +27,18 @@ //This software developed by Applied Research Laboratories at the University of //Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use, -//duplicate, distribute, disclose, or release this software. +//duplicate, distribute, disclose, or release this software. // -//Pursuant to DoD Directive 523024 +//Pursuant to DoD Directive 523024 // // DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited. // //============================================================================= +/// @file Rinex3NavData.hpp +/// Encapsulates RINEX ver 3.02 Navigation data + #ifndef GPSTK_RINEXNAVDATA_HPP #define GPSTK_RINEXNAVDATA_HPP @@ -294,9 +296,7 @@ namespace gpstk * or formatting error occurs. This also resets the stream * to its pre-read position. */ - virtual void reallyGetRecord(FFStream& s) - throw(std::exception, FFStreamError, StringUtils::StringException); - + virtual void reallyGetRecord(FFStream& s); /// Outputs the record to the FFStream \a s. virtual void reallyPutRecord(FFStream& s) const diff --git a/dev/lib/FileHandling/RINEX3/Rinex3NavHeader.cpp b/dev/lib/FileHandling/RINEX3/Rinex3NavHeader.cpp index 0e1cf1018..b389818b5 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3NavHeader.cpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3NavHeader.cpp @@ -1,8 +1,4 @@ -/** - * @file Rinex3NavHeader.cpp - * Encapsulate header of RINEX 3 navigation file, including RINEX 2 - * compatibility. - */ +#pragma ident "$Id$" //============================================================================ // @@ -10,7 +6,7 @@ // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -21,7 +17,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// +// // Copyright 2004, The University of Texas at Austin // //============================================================================ @@ -31,15 +27,21 @@ //This software developed by Applied Research Laboratories at the University of //Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use, -//duplicate, distribute, disclose, or release this software. +//duplicate, distribute, disclose, or release this software. // -//Pursuant to DoD Directive 523024 +//Pursuant to DoD Directive 523024 // // DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited. // //============================================================================= +/** + * @file Rinex3NavHeader.cpp + * Encapsulate header of RINEX 3 navigation file, including RINEX 2 + * compatibility. + */ + #include "StringUtils.hpp" #include "GNSSconstants.hpp" #include "SystemTime.hpp" @@ -583,5 +585,54 @@ namespace gpstk << "-------------------------------\n"; } // end of dump + + void Rinex3NavHeader::setFileSystem(const std::string& str) throw(Exception) + { + try + { + if (str[0] == 'M' || str[0] == 'm') + { + if (version < 3) + { + Exception e("RINEX version 2 'Mixed' Nav files do not exist"); + GPSTK_THROW(e); + } + fileType = "NAVIGATION"; + fileSys = "MIXED"; + fileSysSat = SatID(-1, SatID::systemMixed); + } + else + { + RinexSatID sat(std::string(1, str[0])); + fileSysSat = SatID(sat); + fileSys = StringUtils::asString(sat.systemChar()) + + ": (" + sat.systemString3() + ")"; + if (version >= 3) + { + fileType = "NAVIGATION"; + } + else + { // RINEX 2 + if (sat.system == SatID::systemGPS) + fileType = "N (GPS Nav)"; + else if (sat.system == SatID::systemGlonass) + fileType = "G (GLO Nav)"; + else if (sat.system == SatID::systemGeosync) + fileType = "H (GEO Nav)"; + else + { + Exception e( std::string("RINEX version 2 ") + + sat.systemString3() + + std::string(" Nav files do not exist") ); + GPSTK_THROW(e); + } + } + } + } + catch(Exception& e) + { + GPSTK_RETHROW(e); + } + } } // namespace diff --git a/dev/lib/FileHandling/RINEX3/Rinex3NavHeader.hpp b/dev/lib/FileHandling/RINEX3/Rinex3NavHeader.hpp index 057140856..1b97d3469 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3NavHeader.hpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3NavHeader.hpp @@ -1,6 +1,4 @@ -/// @file Rinex3NavHeader.hpp -/// Encapsulate header of RINEX 3 navigation file, including RINEX 2 -/// compatibility. +#pragma ident "$Id$" //============================================================================ // @@ -8,7 +6,7 @@ // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -38,6 +36,10 @@ // //============================================================================= +/// @file Rinex3NavHeader.hpp +/// Encapsulate header of RINEX 3 navigation file, including RINEX 2 +/// compatibility. + #ifndef GPSTK_RINEX3NAVHEADER_HPP #define GPSTK_RINEX3NAVHEADER_HPP @@ -140,44 +142,7 @@ class Rinex3NavHeader : public Rinex3NavBase /// Change the file system, keeping fileType, fileSys, and fileSysSat /// consistent. /// @param string str beginning with system character or "M" for mixed - void setFileSystem(const std::string& str) throw(Exception) - { - try { - if(str[0] == 'M' || str[0] == 'm') { - if(version < 3) { - Exception e("RINEX version 2 'Mixed' Nav files do not exist"); - GPSTK_THROW(e); - } - fileType = "NAVIGATION"; - fileSys = "MIXED"; - fileSysSat = SatID(-1, SatID::systemMixed); - } - else { - RinexSatID sat(std::string(1,str[0])); - fileSysSat = SatID(sat); - fileSys = StringUtils::asString(sat.systemChar()) - + ": (" + sat.systemString3()+")"; - if(version >= 3) { - fileType = "NAVIGATION"; - } - else { // RINEX 2 - if(sat.system == SatID::systemGPS) - fileType = "N (GPS Nav)"; - else if(sat.system == SatID::systemGlonass) - fileType = "G (GLO Nav)"; - else if(sat.system == SatID::systemGeosync) - fileType = "H (GEO Nav)"; - else { - Exception e( std::string("RINEX version 2 ") + - sat.systemString3() + - std::string(" Nav files do not exist") ); - GPSTK_THROW(e); - } - } - } - } - catch(Exception& e) { GPSTK_RETHROW(e); } - } + void setFileSystem(const std::string& str) throw(Exception); //// Member data /// All 'valid..' bits found in this header diff --git a/dev/lib/FileHandling/RINEX3/Rinex3NavStream.hpp b/dev/lib/FileHandling/RINEX3/Rinex3NavStream.hpp index 489e1cb77..5466334c5 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3NavStream.hpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3NavStream.hpp @@ -1,21 +1,12 @@ #pragma ident "$Id$" - -/** - * @file Rinex3NavStream.hpp - * File stream for Rinex 3 navigation file data - */ - -#ifndef GPSTK_RINEX3NAVSTREAM_HPP -#define GPSTK_RINEX3NAVSTREAM_HPP - //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -45,6 +36,13 @@ // //============================================================================= +/** + * @file Rinex3NavStream.hpp + * File stream for Rinex 3 navigation file data + */ + +#ifndef GPSTK_RINEX3NAVSTREAM_HPP +#define GPSTK_RINEX3NAVSTREAM_HPP #include "FFTextStream.hpp" #include "Rinex3NavHeader.hpp" @@ -70,6 +68,9 @@ namespace gpstk : headerRead(false) {} + Rinex3NavStream(std::basic_iostream& anotherStream) + : FFTextStream(anotherStream), headerRead(false) {} + /** Constructor * Opens a file named \a fn using ios::openmode \a mode. */ diff --git a/dev/lib/FileHandling/RINEX3/Rinex3ObsData.cpp b/dev/lib/FileHandling/RINEX3/Rinex3ObsData.cpp index ec229f35a..b89788c02 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3ObsData.cpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3ObsData.cpp @@ -1,5 +1,4 @@ -/// @file Rinex3ObsData.cpp -/// Encapsulate RINEX 3 observation file data, including I/O. +#pragma ident "$Id$" //============================================================================ // @@ -7,7 +6,7 @@ // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -37,6 +36,9 @@ // //============================================================================= +/// @file Rinex3ObsData.cpp +/// Encapsulate RINEX 3 observation file data, including I/O. + #include #include "StringUtils.hpp" #include "CivilTime.hpp" @@ -44,17 +46,16 @@ #include "RinexObsID.hpp" #include "Rinex3ObsStream.hpp" #include "Rinex3ObsData.hpp" +#include using namespace gpstk::StringUtils; using namespace std; namespace gpstk { - - void reallyPutRecordVer2( Rinex3ObsStream& strm, const Rinex3ObsData& rod ) - throw(FFStreamError, StringException) + throw(FFStreamError, StringException, std::bad_cast) { // is there anything to write? @@ -104,7 +105,7 @@ namespace gpstk itr++; } - // add clock offset + // add clock offset if( rod.clockOffset != 0.0 ) { line += string(68 - line.size(), ' '); @@ -150,62 +151,46 @@ namespace gpstk else if( rod.epochFlag == 0 || rod.epochFlag == 1 || rod.epochFlag == 6 ) { size_t i; - const int maxObsPerLine(5); - - // loop over satellites in R3 obs data - for( itr = rod.obs.begin(); itr != rod.obs.end(); ++itr ) - { - - RinexSatID sat(itr->first); // current satellite - string sys(string(1,sat.systemChar())); // system - itr = rod.obs.find(sat); // get data vector to be written - int obsWritten(0); + static const int MAX_OBS_PER_LINE = 5; + + for(Rinex3ObsData::DataMap::const_iterator it = rod.obs.begin(); + it != rod.obs.end(); ++it + ) { + size_t obsWritten = 0; line = string(""); - // loop over R2 obstypes - for( i=0; i& vecData(strm.header.mapObsTypes[sys]); - - vector::const_iterator jt; - jt = find(vecData.begin(), vecData.end(), obsid); - - int ind(-1); // index into vecData - - if( jt != vecData.end() ) ind = jt-vecData.begin(); - - // need a continuation line? - if( obsWritten != 0 && (obsWritten % maxObsPerLine) == 0 ) - { + for(vector::const_iterator jt = it->second.begin(); + jt != it->second.end(); ++jt + ) { + if(obsWritten == MAX_OBS_PER_LINE) { strm << line << endl; strm.lineNumber++; line = string(""); - } - - // write the line - line += rightJustify(asString( // double 14.3 - ( ind == -1 ? 0.0 : itr->second[ind].data),3),14 ); - line += (ind == -1 || itr->second[ind].lli == 0) - ? string(1, ' ') - : rightJustify(asString(itr->second[ind].lli),1); - line += (ind == -1 || itr->second[ind].ssi == 0) - ? string(1, ' ') - : rightJustify(asString(itr->second[ind].ssi),1); - obsWritten++; - - } // End of 'for( i=0; iisEmpty) { + line += string(14 + 1 + 3 + 2, ' '); + } else { + line += rightJustify( + asString(jt->data, 3), 14 + ); + if(jt->lli != 0) { + line += rightJustify(asString(jt->lli), 1); + } else { + line += " "; + } + if(jt->ssi != 0) { + line += rightJustify(asString(jt->ssi), 1); + } else { + line += " "; + } + } + obsWritten++; + } strm << line << endl; strm.lineNumber++; - } // End of 'for( itr = rod.obs.begin(); itr != rod.obs.end();...' + } } // Ebf of 'else if( rod.epochFlag == 0 || rod.epochFlag == 1 || ...' @@ -219,7 +204,7 @@ namespace gpstk * obtained from corresponding RINEX Observation Header * using method 'Rinex3ObsHeader::getObsIndex()'. */ - RinexDatum Rinex3ObsData::getObs( const SatID& sat, int index ) const + Rinex3Datum Rinex3ObsData::getObs( const SatID& sat, int index ) const throw(InvalidRequest) { @@ -237,7 +222,7 @@ namespace gpstk } // Extract a copy of the data vector - vector vecData(it->second); + vector vecData(it->second); // Return the corresponding data return vecData[index]; @@ -251,7 +236,7 @@ namespace gpstk * @param type String representing the observation type. * @param hdr RINEX Observation Header for current RINEX file. */ - RinexDatum Rinex3ObsData::getObs( const SatID& sat, std::string type, + Rinex3Datum Rinex3ObsData::getObs( const SatID& sat, std::string type, const Rinex3ObsHeader& hdr ) const throw(InvalidRequest) { @@ -276,7 +261,7 @@ namespace gpstk void Rinex3ObsData::reallyPutRecord(FFStream& ffs) const - throw(std::exception, FFStreamError, StringException) + throw(std::exception, FFStreamError, StringException, std::bad_cast) { // is there anything to write? if( (epochFlag == 0 || epochFlag == 1 || epochFlag == 6) @@ -318,7 +303,7 @@ namespace gpstk line = itr->first.toString(); for(size_t i=0; i < itr->second.size(); i++) { - RinexDatum thisData = itr->second[i]; + Rinex3Datum thisData = itr->second[i]; line += rightJustify(asString(thisData.data,3),14); if(thisData.lli == 0) @@ -493,7 +478,7 @@ namespace gpstk //line.resize(80, ' '); // pad just in case sat = satIndex[isv]; // sat for this data satsys = asString(sat.systemChar()); // system for this sat - vector data; + vector data; // loop over data in the line for(ndx=0, line_ndx=0; ndx < numObs; ndx++, line_ndx++) { if(! (line_ndx % 5)) { // get a new line @@ -510,14 +495,21 @@ namespace gpstk string R2ot(strm.header.R2ObsTypes[ndx]); string R3ot(strm.header.mapSysR2toR3ObsID[satsys][R2ot].asString()); if(R3ot != string(" ")) { - RinexDatum tempData; - tempData.data = asDouble(line.substr(line_ndx*16, 14)); - tempData.lli = asInt(line.substr(line_ndx*16+14, 1)); - tempData.ssi = asInt(line.substr(line_ndx*16+15, 1)); + Rinex3Datum tempData; + string token = line.substr(line_ndx*16,14); + if(token.find_first_not_of(' ') == std::string::npos) { + tempData.isEmpty = true; + } else { + tempData.data = asDouble(line.substr(line_ndx*16, 14)); + tempData.lli = asInt(line.substr(line_ndx*16+14, 1)); + tempData.ssi = asInt(line.substr(line_ndx*16+15, 1)); + } data.push_back(tempData); } } - rod.obs[sat] = data; + if(rod.obs.find(sat) == rod.obs.end()) { + rod.obs.insert(make_pair(sat, data)); + } } // end loop over sats to read obs data } @@ -590,7 +582,7 @@ namespace gpstk // Read the observations: SV ID and data ---------------------------- if(epochFlag == 0 || epochFlag == 1 || epochFlag == 6) { vector satIndex(numSVs); - map > tempDataMap; + map > tempDataMap; for(int isv = 0; isv < numSVs; isv++) { strm.formattedGetLine(line); @@ -617,10 +609,10 @@ namespace gpstk line += string(minSize-line.size(), ' '); // get the data (# entries in ObsType map of maps from header) - vector data; + vector data; for(int i = 0; i < size; i++) { size_t pos = 3 + 16*i; - RinexDatum tempData; + Rinex3Datum tempData; tempData.data = asDouble(line.substr(pos , 14)); if( line.size() > pos+14 ) tempData.lli = asInt( line.substr(pos+14, 1)); @@ -628,7 +620,9 @@ namespace gpstk tempData.ssi = asInt( line.substr(pos+15, 1)); data.push_back(tempData); } - obs[satIndex[isv]] = data; + if(obs.find(satIndex[isv]) == obs.end()) { + obs.insert(make_pair(satIndex[isv], data)); + } } } diff --git a/dev/lib/FileHandling/RINEX3/Rinex3ObsData.hpp b/dev/lib/FileHandling/RINEX3/Rinex3ObsData.hpp index ce1ed4928..dc6325b05 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3ObsData.hpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3ObsData.hpp @@ -1,7 +1,4 @@ -/** - * @file Rinex3ObsData.hpp - * Encapsulate RINEX observation file data, including I/O - */ +#pragma ident "$Id$" //============================================================================ // @@ -9,7 +6,7 @@ // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -20,7 +17,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// +// // Copyright 2004, The University of Texas at Austin // //============================================================================ @@ -28,17 +25,22 @@ //============================================================================ // //This software developed by Applied Research Laboratories at the University of -//Texas at Austin, under contract to an agency or agencies within the U.S. +//Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use, -//duplicate, distribute, disclose, or release this software. +//duplicate, distribute, disclose, or release this software. // -//Pursuant to DoD Directive 523024 +//Pursuant to DoD Directive 523024 // -// DISTRIBUTION STATEMENT A: This software has been approved for public +// DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited. // //============================================================================= +/** + * @file Rinex3ObsData.hpp + * Encapsulate RINEX observation file data, including I/O + */ + #ifndef RINEX3OBSDATA_HPP #define RINEX3OBSDATA_HPP @@ -46,27 +48,16 @@ #include #include + #include "CommonTime.hpp" #include "FFStream.hpp" #include "Rinex3ObsBase.hpp" #include "Rinex3ObsHeader.hpp" +#include "Rinex3Datum.h" + namespace gpstk { - - /// A structure used to store a single RINEX Data point. - #ifndef GPSTK_RINEXDATUM - #define GPSTK_RINEXDATUM - struct RinexDatum - { - RinexDatum() : data(0), lli(0), ssi(0) {} ///< constructor - double data; ///< The actual data point. - short lli; ///< See the RINEX Spec. for an explanation. - short ssi; ///< See the RINEX Spec. for an explanation. - }; - #endif // GPSTK_RINEXDATUM - - /** @addtogroup Rinex3Obs */ //@{ @@ -87,7 +78,7 @@ namespace gpstk /// Map from RinexSatID to RinexDatum; order of the data matches the /// order of RinexObsIDs in the header - typedef std::map > DataMap; + typedef std::map > DataMap; /// Time corresponding to the observations CommonTime time; @@ -125,7 +116,7 @@ namespace gpstk * obtained from corresponding RINEX Observation Header * using method 'Rinex3ObsHeader::getObsIndex()'. */ - virtual RinexDatum getObs( const SatID& sat, int index ) const + virtual Rinex3Datum getObs( const SatID& sat, int index ) const throw(InvalidRequest); @@ -135,7 +126,7 @@ namespace gpstk * @param type String representing the observation type. * @param hdr RINEX Observation Header for current RINEX file. */ - virtual RinexDatum getObs( const SatID& sat, + virtual Rinex3Datum getObs( const SatID& sat, std::string type, const Rinex3ObsHeader& hdr ) const throw(InvalidRequest); @@ -163,7 +154,7 @@ namespace gpstk /// number for the type of header data you want to write. virtual void reallyPutRecord(FFStream& s) const throw( std::exception, FFStreamError, - gpstk::StringUtils::StringException ); + gpstk::StringUtils::StringException, std::bad_cast); /** This functions obtains a RINEX 3 Observation record from the given diff --git a/dev/lib/FileHandling/RINEX3/Rinex3ObsHeader.cpp b/dev/lib/FileHandling/RINEX3/Rinex3ObsHeader.cpp index 69047d0c9..89ab152b7 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3ObsHeader.cpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3ObsHeader.cpp @@ -1,7 +1,4 @@ -/** - * @file Rinex3ObsHeader.cpp - * Encapsulate header of Rinex observation file, including I/O - */ +#pragma ident "$Id$" //============================================================================ // @@ -9,7 +6,7 @@ // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -39,6 +36,11 @@ // //============================================================================= +/** + * @file Rinex3ObsHeader.cpp + * Encapsulate header of Rinex observation file, including I/O + */ + #include #include @@ -123,7 +125,7 @@ namespace gpstk msg << "Version " << setw(8) << (valid & validVersion ) << endl; msg << "Run By " << setw(8) << (valid & validRunBy ) << endl; msg << "Marker Name " << setw(8) << (valid & validMarkerName ) << endl; - msg << "Marker Type " << setw(8) << (valid & validMarkerType ) << endl; + //msg << "Marker Type " << setw(8) << (valid & validMarkerType ) << endl; msg << "Observer " << setw(8) << (valid & validObserver ) << endl; msg << "Receiver " << setw(8) << (valid & validReceiver ) << endl; msg << "Antenna Type " << setw(8) << (valid & validAntennaType ) << endl; @@ -134,9 +136,12 @@ namespace gpstk msg << "Sys Obs Type " << setw(8) << (valid & validSystemObsType ) << endl; if(version < 3) msg << "Wave Fact " << setw(8) << (valid & validWaveFact) << endl; - msg << "Sys Phs Shft " << setw(8) << (valid & validSystemPhaseShift)<< endl; - msg << "GLO Freq No " << setw(8) << (valid & validGlonassFreqNo ) << endl; - msg << "GLO Cod-Phs Bias" << setw(8) << (valid & validGlonassCodPhsBias) << endl; + if(version >= 3.01) + msg << "Sys Phs Shft " << setw(8) << (valid & validSystemPhaseShift)<< endl; + if(version >= 3.01) + msg << "GLO Freq No " << setw(8) << (valid & validGlonassFreqNo ) << endl; + if(version >= 3.02) + msg << "GLO Cod-Phs Bias" << setw(8) << (valid & validGlonassCodPhsBias) << endl; msg << "Interval " << setw(8) << (valid & validInterval ) << endl; msg << "First Time " << setw(8) << (valid & validFirstTime ) << endl; msg << "End Header " << setw(8) << (validEoH ? "true":"false" ); // no endl @@ -171,18 +176,18 @@ namespace gpstk if(valid & validComment ) n += commentList.size(); if(valid & validMarkerName ) n++; if(valid & validMarkerNumber ) n++; - if(valid & validMarkerType ) n++; + if(version >= 3 && (valid & validMarkerType)) n++; if(valid & validObserver ) n++; if(valid & validReceiver ) n++; if(valid & validAntennaType ) n++; if(valid & validAntennaPosition ) n++; if(valid & validAntennaDeltaHEN ) n++; - if(valid & validAntennaDeltaXYZ ) n++; - if(valid & validAntennaPhaseCtr ) n++; - if(valid & validAntennaBsightXYZ ) n++; - if(valid & validAntennaZeroDirAzi) n++; - if(valid & validAntennaZeroDirXYZ) n++; - if(valid & validCenterOfMass ) n++; + if(version >= 3 && (valid & validAntennaDeltaXYZ)) n++; + if(version >= 3 && (valid & validAntennaPhaseCtr)) n++; + if(version >= 3 && (valid & validAntennaBsightXYZ)) n++; + if(version >= 3 && (valid & validAntennaZeroDirAzi)) n++; + if(version >= 3 && (valid & validAntennaZeroDirXYZ)) n++; + if(version >= 3 && (valid & validCenterOfMass)) n++; if(version < 3 && (valid & validNumObs)) n += 1 + (obsTypeList.size()-1)/9; if(version >= 3 && (valid & validSystemObsType)) @@ -191,17 +196,17 @@ namespace gpstk n++; if(extraWaveFactList.size()) n += (extraWaveFactList.size()-1)/7; } - if(valid & validSigStrengthUnit ) n++; + if(version >= 3 && (valid & validSigStrengthUnit)) n++; if(valid & validInterval ) n++; if(valid & validFirstTime ) n++; if(valid & validLastTime ) n++; if(valid & validReceiverOffset ) n++; - if(valid & validSystemDCBSapplied) n++; - if(valid & validSystemPCVSapplied) n++; - if(valid & validSystemScaleFac ) n++; - if(valid & validSystemPhaseShift ) n++; // one per system at least - if(valid & validGlonassFreqNo ) n++; - if(valid & validGlonassCodPhsBias) n++; + if(version >= 3 && (valid & validSystemDCBSapplied)) n++; + if(version >= 3 && (valid & validSystemPCVSapplied)) n++; + if(version >= 3 && (valid & validSystemScaleFac)) n++; + if(version >= 3.01 && (valid & validSystemPhaseShift)) n++; // one per system at least + if(version >= 3.01 && (valid & validGlonassFreqNo)) n++; // TODO: continuation lines... + if(version >= 3.02 && (valid & validGlonassCodPhsBias)) n++; if(valid & validLeapSeconds ) n++; if(valid & validNumSats ) n++; if(valid & validPrnObs ) @@ -214,7 +219,7 @@ namespace gpstk // This function writes all valid header records. void Rinex3ObsHeader::WriteHeaderRecords(FFStream& ffs) const - throw(FFStreamError, StringException) + throw(FFStreamError, gpstk::StringUtils::StringException, std::bad_cast) { Rinex3ObsStream& strm = dynamic_cast(ffs); string line; @@ -247,7 +252,6 @@ namespace gpstk line += leftJustify(str, 20); line += stringVersion; strm << line << endl; -// cout << "Line >" << line << "<" << endl; strm.lineNumber++; } // cout << "past validVersion" << endl; @@ -297,26 +301,22 @@ namespace gpstk strm.lineNumber++; } // cout << "past validMarkerNumber" << endl; - if(valid & validMarkerType) + if(version >= 3 && (valid & validMarkerType)) { line = leftJustify(markerType, 20); line += string(40, ' '); line += stringMarkerType; strm << line << endl; -// cout << "Line >" << line << "<" << endl; strm.lineNumber++; } -// cout << "past validMarkerType" << endl; if(valid & validObserver) { line = leftJustify(observer, 20); line += leftJustify(agency , 40); line += stringObserver; strm << line << endl; -// cout << "Line >" << line << "<" << endl; strm.lineNumber++; } -// cout << "past validObserver" << endl; if(valid & validReceiver) { line = leftJustify(recNo , 20); @@ -324,10 +324,8 @@ namespace gpstk line += leftJustify(recVers, 20); line += stringReceiver; strm << line << endl; -// cout << "Line >" << line << "<" << endl; strm.lineNumber++; } -// cout << "past validReceiver" << endl; if(valid & validAntennaType) { line = leftJustify(antNo , 20); @@ -335,10 +333,8 @@ namespace gpstk line += string(20, ' '); line += stringAntennaType; strm << line << endl; -// cout << "Line >" << line << "<" << endl; strm.lineNumber++; } -// cout << "past validAntennaType" << endl; if(valid & validAntennaPosition) { line = rightJustify(asString(antennaPosition[0], 4), 14); @@ -347,10 +343,8 @@ namespace gpstk line += string(18, ' '); line += stringAntennaPosition; strm << line << endl; -// cout << "Line >" << line << "<" << endl; strm.lineNumber++; } -// cout << "past validAntennaPosition" << endl; if(valid & validAntennaDeltaHEN) { line = rightJustify(asString(antennaDeltaHEN[0], 4), 14); @@ -359,11 +353,9 @@ namespace gpstk line += string(18, ' '); line += stringAntennaDeltaHEN; strm << line << endl; -// cout << "Line >" << line << "<" << endl; strm.lineNumber++; } -// cout << "past validAntennaDeltaHEN" << endl; - if(valid & validAntennaDeltaXYZ) + if(version >= 3 && (valid & validAntennaDeltaXYZ)) { line = rightJustify(asString(antennaDeltaXYZ[0], 4), 14); line += rightJustify(asString(antennaDeltaXYZ[1], 4), 14); @@ -371,11 +363,9 @@ namespace gpstk line += string(18, ' '); line += stringAntennaDeltaXYZ; strm << line << endl; -// cout << "Line >" << line << "<" << endl; strm.lineNumber++; } -// cout << "past validAntennaDeltaXYZ" << endl; - if(valid & validAntennaPhaseCtr) + if(version >= 3 && (valid & validAntennaPhaseCtr)) { line = leftJustify(antennaSatSys , 1); line += string(1, ' '); @@ -390,7 +380,7 @@ namespace gpstk strm.lineNumber++; } // cout << "past validAntennaPhaseCtr" << endl; - if(valid & validAntennaBsightXYZ) + if(version >= 3 && (valid & validAntennaBsightXYZ)) { line = rightJustify(asString(antennaBsightXYZ[0], 4), 14); line += rightJustify(asString(antennaBsightXYZ[1], 4), 14); @@ -402,7 +392,7 @@ namespace gpstk strm.lineNumber++; } // cout << "past validAntennaBsightXYZ" << endl; - if(valid & validAntennaZeroDirAzi) + if(version >= 3 && (valid & validAntennaZeroDirAzi)) { line = rightJustify(asString(antennaZeroDirAzi, 4), 14); line += string(46, ' '); @@ -412,7 +402,7 @@ namespace gpstk strm.lineNumber++; } // cout << "past validAntennaZeroDirAzi" << endl; - if(valid & validAntennaZeroDirXYZ) + if(version >= 3 && (valid & validAntennaZeroDirXYZ)) { line = rightJustify(asString(antennaZeroDirXYZ[0], 4), 14); line += rightJustify(asString(antennaZeroDirXYZ[1], 4), 14); @@ -424,7 +414,7 @@ namespace gpstk strm.lineNumber++; } // cout << "past validAntennaZeroDirXYZ" << endl; - if(valid & validCenterOfMass) + if(version >= 3 && (valid & validCenterOfMass)) { line = rightJustify(asString(centerOfMass[0], 4), 14); line += rightJustify(asString(centerOfMass[1], 4), 14); @@ -563,7 +553,7 @@ namespace gpstk } } // cout << "past validWaveFact" << endl; - if(valid & validSigStrengthUnit && version >= 3) + if(version >= 3 && valid & validSigStrengthUnit) { line = leftJustify(sigStrengthUnit, 20); line += string(40, ' '); @@ -613,7 +603,7 @@ namespace gpstk strm.lineNumber++; } // cout << "past validReceiverOffset" << endl; - if(valid & validSystemDCBSapplied) + if(version >= 3 && (valid & validSystemDCBSapplied)) { for(size_t i = 0; i < infoDCBS.size(); i++) { @@ -629,7 +619,7 @@ namespace gpstk } } // cout << "past validSystemDCBSapplied" << endl; - if(valid & validSystemPCVSapplied) + if(version >= 3 && (valid & validSystemPCVSapplied)) { for(size_t i = 0; i < infoPCVS.size(); i++) { @@ -645,7 +635,7 @@ namespace gpstk } } // cout << "past validSystemPCVSapplied" << endl; - if(valid & validSystemScaleFac) + if(version >= 3 && (valid & validSystemScaleFac)) { static const int maxObsPerLine = 12; @@ -706,21 +696,18 @@ namespace gpstk } } } -// cout << "past validSystemScaleFac" << endl; - if(valid & validSystemPhaseShift && version >= 3) + if(version >= 3.01 && (valid & validSystemPhaseShift)) { //map > > sysPhaseShift; map > >::const_iterator it; for(it=sysPhaseShift.begin(); it!=sysPhaseShift.end(); ++it) { string sys(it->first); - //cout << "Phase shift for system " << sys << endl; map >::const_iterator jt(it->second.begin()); if(jt == it->second.end()) { line = sys; line += string(60-line.length(), ' '); line += stringSystemPhaseShift; strm << line << endl; - //cout << "Line >" << line << "<" << endl; strm.lineNumber++; } else for( ; jt!=it->second.end(); ++jt) { @@ -763,7 +750,7 @@ namespace gpstk } } //cout << "past validSystemPhaseShift" << endl; - if(valid & validGlonassFreqNo) + if(version >= 3.01 && (valid & validGlonassFreqNo)) { //map GlonassFreqNo; int n(0),nsat(GlonassFreqNo.size()); @@ -786,7 +773,7 @@ namespace gpstk } } // cout << "past validGlonassFreqNo" << endl; - if(valid & validGlonassCodPhsBias) + if(version >= 3.02 && (valid & validGlonassCodPhsBias)) { map::const_iterator it; const string labs[4]={"C1C","C1P","C2C","C2P"}; @@ -1748,6 +1735,9 @@ namespace gpstk tsys = line.substr(48, 3) ; ts.fromString(tsys); + if(ts == TimeSystem::Unknown) { + ts = TimeSystem::GPS; + } return CivilTime(year, month, day, hour, min, sec, ts); } // end parseTime @@ -1870,7 +1860,7 @@ namespace gpstk << ", File type " << fileType << ", System " << str << "." << endl; s << "Prgm: " << fileProgram << ", Run: " << date << ", By: " << fileAgency << endl; - s << "Marker name: " << markerName << ", "; + //s << "Marker name: " << markerName << ", "; s << "Marker type: " << markerType << "." << endl; s << "Observer : " << observer << ", Agency: " << agency << endl; s << "Rec#: " << recNo << ", Type: " << recType @@ -1915,7 +1905,8 @@ namespace gpstk if(!(valid & validRunBy)) s << " Pgm / Run By / Date\n"; if(!(valid & validMarkerName)) s << " Marker Name\n"; //if(version >= 3 && !(valid & validMarkerType)) s << "Marker Type\n"; - // Not actually required in 3.02 - see note in table A2 of R3.02 doc + // Not defined in R2 and not required in > 3, see Table A2 in R3 doc: + // "Record required except for GEODETIC and NON_GEODETIC marker types" if(!(valid & validObserver)) s << " Observer / Agency\n"; if(!(valid & validReceiver)) s << " Receiver # / Type\n"; if(!(valid & validAntennaType)) s << " Antenna Type\n"; @@ -1924,9 +1915,8 @@ namespace gpstk if(version < 3 && !(valid & validNumObs)) s << " # / TYPES OF OBSERV\n"; if(version >= 3 && !(valid & validSystemObsType )) s << " Sys / # / Obs Type\n"; if(!(valid & validFirstTime)) s << " Time of First Obs\n"; - if(!(valid & validSystemPhaseShift)) s << " Sys / Phase Shifts\n"; if(version >= 3.01 && !(valid & validSystemPhaseShift)) s << " SYS / PHASE SHIFT\n"; - if(version >= 3.02 && !(valid & validGlonassFreqNo)) s << " GLONASS SLOT / FRQ #\n"; + if(version >= 3.01 && !(valid & validGlonassFreqNo)) s << " GLONASS SLOT / FRQ #\n"; if(version >= 3.02 && !(valid & validGlonassCodPhsBias)) s << " GLONASS COD/PHS/BIS\n"; if(!(validEoH)) s << " END OF HEADER\n"; s << "END Invalid header records." << endl; diff --git a/dev/lib/FileHandling/RINEX3/Rinex3ObsHeader.hpp b/dev/lib/FileHandling/RINEX3/Rinex3ObsHeader.hpp index de4584f6e..8847b8821 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3ObsHeader.hpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3ObsHeader.hpp @@ -1,10 +1,4 @@ -/** - * @file Rinex3ObsHeader.hpp - * Encapsulate header of Rinex observation file, including I/O - */ - -#ifndef GPSTK_RINEX3OBSHEADER_HPP -#define GPSTK_RINEX3OBSHEADER_HPP +#pragma ident "$Id$" //============================================================================ // @@ -12,7 +6,7 @@ // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -42,6 +36,14 @@ // //============================================================================= +/** + * @file Rinex3ObsHeader.hpp + * Encapsulate header of Rinex observation file, including I/O + */ + +#ifndef GPSTK_RINEX3OBSHEADER_HPP +#define GPSTK_RINEX3OBSHEADER_HPP + #include #include #include @@ -137,7 +139,7 @@ namespace gpstk validComment = 0x4, ///< "COMMENT" optional validMarkerName = 0x8, ///< "MARKER NAME" validMarkerNumber = 0x10, ///< "MARKER NUMBER" optional - validMarkerType = 0x20, ///< "MARKER TYPE" R3 + validMarkerType = 0x20, ///< "MARKER TYPE" optional R3 validObserver = 0x40, ///< "OBSERVER / AGENCY" validReceiver = 0x80, ///< "REC # / TYPE / VERS" validAntennaType = 0x100, ///< "ANT # / TYPE" @@ -160,8 +162,8 @@ namespace gpstk validSystemDCBSapplied = 0x800000, ///< "SYSTEM DCBS APPLIED" optional R3 validSystemPCVSapplied = 0x1000000, ///< "SYSTEM PCVS APPLIED" optional R3 validSystemScaleFac = 0x2000000, ///< "SYSTEM SCALE FACTOR" optional R3 - validSystemPhaseShift = 0x4000000, ///< "SYS / PHASE SHIFT" R3.01,3.02 - validGlonassFreqNo = 0x8000000, ///< "GLONASS SLOT / FRQ #" R3.01 + validSystemPhaseShift = 0x4000000, ///< "SYS / PHASE SHIFT" R3.01 + validGlonassFreqNo = 0x8000000, ///< "GLONASS SLOT / FRQ #" not defined in R3, optional in R3.01, required in R3.02 validGlonassCodPhsBias = 0x10000000, ///< "GLONASS COD/PHS/BIS" R3.02 validLeapSeconds = 0x20000000, ///< "LEAP SECONDS" optional validNumSats = 0x40000000, ///< "# OF SATELLITES" optional @@ -171,7 +173,7 @@ namespace gpstk /// This mask is for all required valid fields allValid2 = 0x001207CB, // RINEX 2 - //allValid30 = 0x001207CB, // RINEX 3.0 for static receivers - AntennaPosition present + //allValid30 = 0x091207CB, // RINEX 3.0 for static receivers - AntennaPosition present allValid30 = 0x001205CB, // RINEX 3.0 for moving receivers -- make default //allValid301 = 0x0C1205AB, // RINEX 3.01 @@ -305,7 +307,7 @@ namespace gpstk /// Write all valid header records to the given stream. /// Used by reallyPutRecord for both Rinex3ObsHeader and Rinex3ObsData. void WriteHeaderRecords(FFStream& s) const - throw(FFStreamError, gpstk::StringUtils::StringException); + throw(FFStreamError, gpstk::StringUtils::StringException, std::bad_cast); /// Return boolean : is this a valid Rinex header? bool isValid() const diff --git a/dev/lib/FileHandling/RINEX3/Rinex3ObsStream.hpp b/dev/lib/FileHandling/RINEX3/Rinex3ObsStream.hpp index 4a74a19d9..99d7f0bd6 100755 --- a/dev/lib/FileHandling/RINEX3/Rinex3ObsStream.hpp +++ b/dev/lib/FileHandling/RINEX3/Rinex3ObsStream.hpp @@ -1,20 +1,12 @@ #pragma ident "$Id$" -/** - * @file Rinex3ObsStream.hpp - * File stream for RINEX 3 observation file data. - */ - -#ifndef GPSTK_RINEX3OBSSTREAM_HPP -#define GPSTK_RINEX3OBSSTREAM_HPP - //============================================================================ // // This file is part of GPSTk, the GPS Toolkit. // // The GPSTk is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published -// by the Free Software Foundation; either version 2.1 of the License, or +// by the Free Software Foundation; either version 3.0 of the License, or // any later version. // // The GPSTk is distributed in the hope that it will be useful, @@ -25,7 +17,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with GPSTk; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -// +// // Copyright 2004, The University of Texas at Austin // //============================================================================ @@ -33,17 +25,25 @@ //============================================================================ // //This software developed by Applied Research Laboratories at the University of -//Texas at Austin, under contract to an agency or agencies within the U.S. +//Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use, -//duplicate, distribute, disclose, or release this software. +//duplicate, distribute, disclose, or release this software. // -//Pursuant to DoD Directive 523024 +//Pursuant to DoD Directive 523024 // -// DISTRIBUTION STATEMENT A: This software has been approved for public +// DISTRIBUTION STATEMENT A: This software has been approved for public // release, distribution is unlimited. // //============================================================================= +/** + * @file Rinex3ObsStream.hpp + * File stream for RINEX 3 observation file data. + */ + +#ifndef GPSTK_RINEX3OBSSTREAM_HPP +#define GPSTK_RINEX3OBSSTREAM_HPP + #include #include #include @@ -71,7 +71,9 @@ namespace gpstk Rinex3ObsStream() : headerRead(false), timesystem(TimeSystem::GPS) {}; - + + Rinex3ObsStream(std::basic_iostream& anotherStream) + : FFTextStream(anotherStream), headerRead(false), timesystem(TimeSystem::GPS) {} /** Common constructor. * diff --git a/dev/lib/GNSSCore/Xvt.hpp b/dev/lib/GNSSCore/Xvt.hpp index dfa5f8a09..6bea03028 100755 --- a/dev/lib/GNSSCore/Xvt.hpp +++ b/dev/lib/GNSSCore/Xvt.hpp @@ -80,11 +80,11 @@ namespace gpstk { return v; } /// access the clock bias, in second - double getClockBias() throw() + double getClockBias() const throw() { return clkbias; } /// access the clock drift, in second/second - double getClockDrift() throw() + double getClockDrift() const throw() { return clkdrift; } /// access the relativity correction, in seconds diff --git a/dev/lib/ProcLib/ExtractCombinationData.cpp b/dev/lib/ProcLib/ExtractCombinationData.cpp index 72cde3538..a9082c7bd 100755 --- a/dev/lib/ProcLib/ExtractCombinationData.cpp +++ b/dev/lib/ProcLib/ExtractCombinationData.cpp @@ -77,7 +77,7 @@ namespace gpstk // The satellites are stored in the first elements of the map... SatID sat(it->first); // .. and vectors of available obs are in the second elements - vector vecData(it->second); + vector vecData(it->second); // Extract observation values double obsValue1( (vecData[indexObs1]).data ); diff --git a/dev/lib/ProcLib/ExtractData.cpp b/dev/lib/ProcLib/ExtractData.cpp index b03668d45..4e425883c 100755 --- a/dev/lib/ProcLib/ExtractData.cpp +++ b/dev/lib/ProcLib/ExtractData.cpp @@ -71,7 +71,7 @@ namespace gpstk // The satellites are stored in the first elements of the map... SatID sat(it->first); // .. and vectors of available obs are in the second elements - std::vector vecData(it->second); + std::vector vecData(it->second); // Extract observation value double obsValue( (vecData[index]).data ); diff --git a/dev/lib/Rxio/ObsReader.cpp b/dev/lib/Rxio/ObsReader.cpp index a94cf71ae..0b996beaf 100755 --- a/dev/lib/Rxio/ObsReader.cpp +++ b/dev/lib/Rxio/ObsReader.cpp @@ -229,15 +229,15 @@ namespace gpstk ObsReader::operator bool () { if (inputType == FFIdentifier::tRinexObs) - return ros; + return static_cast(ros); else if (inputType == FFIdentifier::tMDP) - return mdps; + return static_cast(mdps); else if (inputType == FFIdentifier::tSMODF) - return smos; + return static_cast(smos); else if (inputType == FFIdentifier::tNovatelOem) - return novas; + return static_cast(novas); else if (inputType == FFIdentifier::tAshtechSerial) - return ashs; + return static_cast(ashs); return false; }