Rinex3ClockData.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
41 
42 #include "Rinex3ClockStream.hpp"
43 #include "Rinex3ClockHeader.hpp"
44 #include "Rinex3ClockData.hpp"
45 #include "RinexSatID.hpp"
46 #include "StringUtils.hpp"
47 #include "TimeString.hpp"
48 #include "CivilTime.hpp"
49 
50 using namespace gnsstk::StringUtils;
51 using namespace std;
52 
53 namespace gnsstk
54 {
57  bias(0), sig_bias(0), drift(0), sig_drift(0), accel(0), sig_accel(0)
58  {
59  }
60 
61 
63  {
64  // cast the stream to be an Rinex3ClockStream
65  Rinex3ClockStream& strm = dynamic_cast<Rinex3ClockStream&>(ffs);
66 
67  strm << datatype << ' ';
68 
69  if (datatype == string("AR"))
70  {
71  strm << setw(4) << right << site;
72  }
73  else if (datatype == string("AS"))
74  {
75  strm << sat.systemChar() << setw(2) << right << setfill('0') << sat.id
76  << setfill(' ') << ' ';
77  }
78  else
79  {
80  FFStreamError e("Unknown data type: " + datatype);
81  GNSSTK_THROW(e);
82  }
83  strm << ' ' << printTime(time,"%4Y %02m %02d %02H %02M %9.6f");
84 
85  // must count the data to output
86  int n(2);
87  if (drift != 0.0)
88  n=3;
89  if (sig_drift != 0.0)
90  n=4;
91  if (accel != 0.0)
92  n=5;
93  if (sig_accel != 0.0)
94  n=6;
95  strm << setw(3) << n << " " << bias << ' ' << sig_bias << endl;
96 
97  strm.lineNumber++;
98 
99  // continuation line
100 
101  if (n > 2)
102  {
103  strm << drift << ' ';
104  if (n > 3)
105  {
106  strm << sig_drift << ' ';
107  }
108  if (n > 4)
109  {
110  strm << accel << ' ';
111  }
112  if (n > 5)
113  {
114  strm << sig_accel << ' ';
115  }
116  strm << endl;
117  strm.lineNumber++;
118  }
119 
120  } // end reallyPutRecord()
121 
122 
124  {
125  // cast the stream to be an Rinex3ClockStream
126  Rinex3ClockStream& strm = dynamic_cast<Rinex3ClockStream&>(ffs);
127 
128  clear();
129 
130  string line;
131  strm.formattedGetLine(line,true); // true means 'expect possible EOF'
132  stripTrailing(line);
133  if (line.length() < 59) {
134  FFStreamError e("Short line : " + line);
135  GNSSTK_THROW(e);
136  }
137 
138  //cout << "Data Line: /" << line << "/" << endl;
139  datatype = line.substr(0,2);
140  site = line.substr(3,4);
141  if (datatype == string("AS"))
142  {
143  strip(site);
144  try
145  {
147  }
148  catch (Exception& exc)
149  {
150  FFStreamError e(exc);
151  e.addText("Invalid sat : /" + site + "/");
152  GNSSTK_THROW(e);
153  }
154  site = string();
155  }
156 
157  time = CivilTime(asInt(line.substr( 8,4)),
158  asInt(line.substr(12,3)),
159  asInt(line.substr(15,3)),
160  asInt(line.substr(18,3)),
161  asInt(line.substr(21,3)),
162  asDouble(line.substr(24,10)),
164 
165  int n(asInt(line.substr(34,3)));
166  bias = line.substr(40,19);
167  if (n > 1 && line.length() >= 59)
168  sig_bias = line.substr(60,19);
169 
170  if (n > 2)
171  {
172  strm.formattedGetLine(line,true);
173  stripTrailing(line);
174  if (int(line.length()) < (n-2)*20-1)
175  {
176  FFStreamError e("Short line : " + line);
177  GNSSTK_THROW(e);
178  }
179  drift = line.substr( 0,19);
180  if (n > 3)
181  sig_drift = line.substr(20,19);
182  if (n > 4)
183  accel = line.substr(40,19);
184  if (n > 5)
185  sig_accel = line.substr(60,19);
186  }
187 
188  } // end reallyGetRecord()
189 
190  void Rinex3ClockData::dump(ostream& s) const noexcept
191  {
192  // dump record type, sat id / site, current epoch, and data
193  s << " " << datatype;
194  if (datatype == string("AR"))
195  {
196  s << " " << site;
197  }
198  else
199  {
200  s << " " << sat.toString();
201  }
202  s << " " << printTime(time,"%Y/%02m/%02d %2H:%02M:%06.3f = %F/%10.3g %P")
203  << " " << bias << " " << sig_bias << " " << drift << " " << sig_drift
204  << " " << accel << " " << sig_accel << endl;
205  } // end dump()
206 
207 } // namespace
208 
209 //------------------------------------------------------------------------------------
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
gnsstk::Rinex3ClockStream
Definition: Rinex3ClockStream.hpp:59
gnsstk::SatID::id
int id
Satellite identifier, e.g. PRN.
Definition: SatID.hpp:154
gnsstk::RinexSatID::fromString
void fromString(const std::string &s)
Definition: RinexSatID.cpp:122
gnsstk::FFStream
Definition: FFStream.hpp:119
gnsstk::BEGINNING_OF_TIME
const Epoch BEGINNING_OF_TIME(CommonTime::BEGINNING_OF_TIME)
Earliest representable Epoch.
StringUtils.hpp
gnsstk::FFTextStream::formattedGetLine
void formattedGetLine(std::string &line, const bool expectEOF=false)
Definition: FFTextStream.cpp:149
gnsstk::SatelliteSystem
SatelliteSystem
Supported satellite systems.
Definition: SatelliteSystem.hpp:55
Rinex3ClockStream.hpp
gnsstk::FFTextStream::lineNumber
unsigned int lineNumber
Definition: FFTextStream.hpp:98
gnsstk::Rinex3ClockData::reallyGetRecord
virtual void reallyGetRecord(FFStream &s)
Definition: Rinex3ClockData.cpp:123
gnsstk::TimeSystem::Any
@ Any
wildcard; allows comparison with any other type
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Rinex3ClockData::sig_bias
R3CDouble sig_bias
Clock bias sigma in seconds.
Definition: Rinex3ClockData.hpp:107
gnsstk::Rinex3ClockData::bias
R3CDouble bias
Clock bias in seconds.
Definition: Rinex3ClockData.hpp:106
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::SatelliteSystem::GPS
@ GPS
gnsstk::StringUtils::stripTrailing
std::string & stripTrailing(std::string &s, const std::string &aString, std::string::size_type num=std::string::npos)
Definition: StringUtils.hpp:1453
gnsstk::Rinex3ClockData::sig_accel
R3CDouble sig_accel
Clock acceleration sigma in 1/sec.
Definition: Rinex3ClockData.hpp:111
gnsstk::Rinex3ClockData::time
CommonTime time
Time of epoch for this record.
Definition: Rinex3ClockData.hpp:105
gnsstk::Rinex3ClockData::dump
virtual void dump(std::ostream &s=std::cout) const noexcept
Debug output function.
Definition: Rinex3ClockData.cpp:190
Rinex3ClockData.hpp
example4.time
time
Definition: example4.py:103
gnsstk::Rinex3ClockData::sig_drift
R3CDouble sig_drift
Clock drift sigma in sec/sec.
Definition: Rinex3ClockData.hpp:109
gnsstk::CommonTime
Definition: CommonTime.hpp:84
CivilTime.hpp
gnsstk::Rinex3ClockData::drift
R3CDouble drift
Clock drift in sec/sec.
Definition: Rinex3ClockData.hpp:108
gnsstk::StringUtils::asDouble
double asDouble(const std::string &s)
Definition: StringUtils.hpp:705
Rinex3ClockHeader.hpp
gnsstk::Rinex3ClockData::site
std::string site
Site label (4-char) (if AR)
Definition: Rinex3ClockData.hpp:104
gnsstk::Rinex3ClockData::Rinex3ClockData
Rinex3ClockData()
Constructor.
Definition: Rinex3ClockData.cpp:55
gnsstk::Rinex3ClockData::clear
void clear() noexcept
Definition: Rinex3ClockData.hpp:115
gnsstk::CivilTime
Definition: CivilTime.hpp:55
gnsstk::StringUtils
Definition: IonexStoreStrategy.cpp:44
gnsstk::Rinex3ClockData::reallyPutRecord
virtual void reallyPutRecord(FFStream &s) const
Definition: Rinex3ClockData.cpp:62
gnsstk::printTime
std::string printTime(const CommonTime &t, const std::string &fmt)
Definition: TimeString.cpp:64
std
Definition: Angle.hpp:142
gnsstk::StringUtils::strip
std::string & strip(std::string &s, const std::string &aString, std::string::size_type num=std::string::npos)
Definition: StringUtils.hpp:1482
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
RinexSatID.hpp
gnsstk::Rinex3ClockData::sat
RinexSatID sat
Satellite ID (if AS)
Definition: Rinex3ClockData.hpp:103
gnsstk::Rinex3ClockData::accel
R3CDouble accel
Clock acceleration in 1/sec.
Definition: Rinex3ClockData.hpp:110
gnsstk::Rinex3ClockData::datatype
std::string datatype
Data type : AR, AS, etc.
Definition: Rinex3ClockData.hpp:102
TimeString.hpp
gnsstk::RinexSatID::systemChar
char systemChar() const noexcept
Definition: RinexSatID.cpp:62


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:40