RinexClockData.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 
44 #include <string>
45 #include "RinexClockData.hpp"
46 #include "RinexClockHeader.hpp"
47 #include "RinexClockStream.hpp"
48 #include "StringUtils.hpp"
49 #include "FFStream.hpp"
50 #include "FFStreamError.hpp"
51 
52 using namespace std;
53 
54 namespace gnsstk
55 {
56  using namespace StringUtils;
57 
58  void RinexClockData::dump(ostream& s) const
59  {
60  s << "Type: " << type.type << " "
61  << "Name: " << name << " "
62  << "Epoch Time: " << writeTime(epochTime) << " "
63  << "#of Data Values: " << dvCount;
64 
65  for (int i = 0; i < dvCount; i++)
66  {
67  if (i%4 == 0)
68  {
69  s << endl
70  << " ";
71  }
72 
73  s << clockData[i]
74  << " ";
75  }
76 
77  } // dump
78 
79 
80  void RinexClockData::reallyPutRecord(FFStream& s) const
81  {
82  if ( type != AR &&
83  type != AS &&
84  type != CR &&
85  type != DR &&
86  type != MS )
87  {
88  // invalid type - throw
89  FFStreamError e("Invalid type: " + type.type);
90  GNSSTK_THROW(e);
91  }
92 
93  if ( dvCount < 1 || dvCount > 6 )
94  {
95  // invalid dvCount - throw
96  FFStreamError e("Invalid number of data values: " + asString(dvCount));
97  GNSSTK_THROW(e);
98  }
99 
100  s << setw(2) << type.type << ' '
101  << setw(4) << name << ' '
102  << writeTime(epochTime)
103  << right << setw(3) << dvCount << left << " "
104  << clockData[0]
105  << ' ';
106 
107  if (dvCount >= 2)
108  {
109  s << clockData[1]
110  << endlpp;
111  }
112  else // dvCount == 1
113  {
114  s << endlpp;
115  }
116 
117  if (dvCount > 2)
118  {
119  for (int i = 2; i < dvCount; i++)
120  {
121  s << clockData[i];
122 
123  if ( i < 5 )
124  {
125  s << ' ';
126  }
127  }
128  s << endlpp;
129  }
130 
131  } // reallyPutRecord
132 
133 
134  void RinexClockData::reallyGetRecord(FFStream& ffs)
135  {
136  RinexClockStream& strm = dynamic_cast<RinexClockStream&>(ffs);
137 
138  // If the header hasn't been read, read it...
139  if(!strm.headerRead)
140  {
141  strm >> strm.header;
142  }
143 
144  // Clear out this object
145  RinexClockHeader& hdr = strm.header;
146 
147  RinexClockData rcd;
148  *this=rcd;
149 
150  string line;
151 
152  strm.formattedGetLine(line, true);
153 
154  if (line.size() < 59 || line.size() > 80 )
155  {
156  // invalid record size - throw
157  FFStreamError e("Invalid record length: " + asString(line.size()));
158  GNSSTK_THROW(e);
159  }
160 
161  if ( line[2] != ' ' || line[7] != ' ' ||
162  line[37] != ' ' || line[38] != ' ' )
163  {
164  // invalid record - throw
165  FFStreamError e("Invalid clock record.");
166  GNSSTK_THROW(e);
167  }
168 
169  string ts = upperCase(line.substr(0,2));
170  if (ts == "AR") type = AR;
171  else if (ts == "AS") type = AS;
172  else if (ts == "CR") type = CR;
173  else if (ts == "DR") type = DR;
174  else if (ts == "MS") type = MS;
175  else
176  {
177  // invalid type - throw
178  FFStreamError e("Invalid clock type: " + type.type);
179  GNSSTK_THROW(e);
180  }
181 
182  name = line.substr(3,4);
183 
184  epochTime = parseTime(line.substr(8,26));
185 
186  dvCount = asInt(line.substr(34,3));
187  if ( dvCount < 1 || dvCount > 6 )
188  {
189  // invalid dvCount - throw
190  FFStreamError e("Invalid number of data values: " + asString(dvCount));
191  GNSSTK_THROW(e);
192  }
193 
194  clockData[0] = line.substr(40,19);
195 
196  if (dvCount >= 2)
197  {
198  clockData[1] = line.substr(60,19);
199  }
200 
201  if (dvCount > 2)
202  {
203  // get continuation line
204  strm.formattedGetLine(line, true);
205 
206  if (line.size() < 19 || line.size() > 80)
207  {
208  // invalid continuation line size - throw
209  FFStreamError e("Invalid continuation line length: " +
210  asString(line.size()));
211  GNSSTK_THROW(e);
212  }
213 
214  for (int i = 2; i < dvCount; i++)
215  {
216  clockData[i] = line.substr( (i-2)*20, 19 );
217  }
218  }
219 
220  } // reallyGetRecord
221 
222 
223 } // namespace
224 
225 
RinexClockHeader.hpp
gnsstk::dump
void dump(vector< SatPass > &SatPassList, ostream &os, bool rev, bool dbug)
Definition: SatPassUtilities.cpp:59
gnsstk::StringUtils::upperCase
std::string & upperCase(std::string &s)
Definition: StringUtils.hpp:2117
gnsstk::StringUtils::asInt
long asInt(const std::string &s)
Definition: StringUtils.hpp:713
gnsstk::FFStream
Definition: FFStream.hpp:119
RinexClockData.hpp
gnsstk::RinexClockStream::headerRead
bool headerRead
Whether or not the RinexClockHeader has been read.
Definition: RinexClockStream.hpp:104
StringUtils.hpp
FFStreamError.hpp
gnsstk::FFTextStream::formattedGetLine
void formattedGetLine(std::string &line, const bool expectEOF=false)
Definition: FFTextStream.cpp:149
gnsstk::StringUtils::asString
std::string asString(IonexStoreStrategy e)
Convert a IonexStoreStrategy to a whitespace-free string name.
Definition: IonexStoreStrategy.cpp:46
RinexClockStream.hpp
gnsstk::RinexClockData
Definition: RinexClockData.hpp:62
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::RinexClockStream::header
RinexClockHeader header
The header for this file.
Definition: RinexClockStream.hpp:107
gnsstk::RinexClockHeader
Definition: RinexClockHeader.hpp:61
std
Definition: Angle.hpp:142
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
endlpp
std::ostream & endlpp(std::ostream &os)
Definition: FFTextStream.hpp:147
gnsstk::RinexClockStream
Definition: RinexClockStream.hpp:62
FFStream.hpp


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