source: ntrip/trunk/BNC/src/satObs.cpp@ 6557

Last change on this file since 6557 was 6556, checked in by stuerze, 10 years ago

separate consideration of ssr update interval

File size: 11.5 KB
RevLine 
[6176]1#include <iostream>
[6177]2#include <iomanip>
[6176]3#include <sstream>
[6495]4#include <newmatio.h>
[6144]5
6#include "satObs.h"
[6178]7
[6144]8using namespace std;
9
[6466]10// Constructor
[6144]11////////////////////////////////////////////////////////////////////////////
[6466]12t_clkCorr::t_clkCorr() {
[6160]13 _iod = 0;
14 _dClk = 0.0;
15 _dotDClk = 0.0;
16 _dotDotDClk = 0.0;
[6144]17}
18
19//
20////////////////////////////////////////////////////////////////////////////
[6507]21void t_clkCorr::writeEpoch(ostream* out, const QList<t_clkCorr>& corrList) {
[6456]22 if (!out || corrList.size() == 0) {
23 return;
24 }
[6457]25 out->setf(ios::fixed);
26 bncTime epoTime;
27 QListIterator<t_clkCorr> it(corrList);
28 while (it.hasNext()) {
29 const t_clkCorr& corr = it.next();
30 if (!epoTime.valid()) {
31 epoTime = corr._time;
[6556]32 *out << "> CLOCK " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
33 << corr._updateInt << " "
[6458]34 << corrList.size() << ' ' << corr._staID << endl;
[6457]35 }
36 *out << corr._prn.toString() << ' ' << setw(3) << corr._iod << ' '
37 << setw(10) << setprecision(4) << corr._dClk * t_CST::c << ' '
38 << setw(10) << setprecision(4) << corr._dotDClk * t_CST::c << ' '
39 << setw(10) << setprecision(4) << corr._dotDotDClk * t_CST::c << endl;
40 }
[6456]41 out->flush();
[6144]42}
43
44//
45////////////////////////////////////////////////////////////////////////////
[6507]46void t_clkCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_clkCorr>& corrList) {
[6556]47 bncTime epoTime;
48 unsigned int updateInt;
49 int numCorr;
50 string staID;
51 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::clkCorr) {
[6502]52 return;
53 }
[6503]54 for (int ii = 0; ii < numCorr; ii++) {
[6504]55 t_clkCorr corr;
[6556]56 corr._time = epoTime;
57 corr._updateInt = updateInt;
58 corr._staID = staID;
[6503]59
60 string line;
[6507]61 getline(inStream, line);
[6503]62 istringstream in(line.c_str());
63
[6504]64 in >> corr._prn >> corr._iod >> corr._dClk >> corr._dotDClk >> corr._dotDotDClk;
[6503]65
[6513]66 corr._dClk /= t_CST::c;
67 corr._dotDClk /= t_CST::c;
68 corr._dotDotDClk /= t_CST::c;
69
[6504]70 corrList.push_back(corr);
[6503]71 }
[6180]72}
73
[6466]74// Constructor
[6180]75////////////////////////////////////////////////////////////////////////////
[6466]76t_orbCorr::t_orbCorr() {
77 _iod = 0;
78 _system = 'R';
[6160]79 _xr.ReSize(3); _xr = 0.0;
80 _dotXr.ReSize(3); _dotXr = 0.0;
[6144]81}
82
83//
84////////////////////////////////////////////////////////////////////////////
[6507]85void t_orbCorr::writeEpoch(ostream* out, const QList<t_orbCorr>& corrList) {
[6456]86 if (!out || corrList.size() == 0) {
87 return;
88 }
[6460]89 out->setf(ios::fixed);
90 bncTime epoTime;
91 QListIterator<t_orbCorr> it(corrList);
92 while (it.hasNext()) {
93 const t_orbCorr& corr = it.next();
94 if (!epoTime.valid()) {
95 epoTime = corr._time;
[6556]96 *out << "> ORBIT " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
97 << corr._updateInt << " "
[6460]98 << corrList.size() << ' ' << corr._staID << endl;
99 }
100 *out << corr._prn.toString() << ' ' << setw(3) << corr._iod << ' '
101 << setw(10) << setprecision(4) << corr._xr[0] << ' '
102 << setw(10) << setprecision(4) << corr._xr[1] << ' '
103 << setw(10) << setprecision(4) << corr._xr[2] << " "
104 << setw(10) << setprecision(4) << corr._dotXr[0] << ' '
105 << setw(10) << setprecision(4) << corr._dotXr[1] << ' '
106 << setw(10) << setprecision(4) << corr._dotXr[2] << endl;
107 }
[6456]108 out->flush();
[6144]109}
110
[6455]111//
112////////////////////////////////////////////////////////////////////////////
[6507]113void t_orbCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_orbCorr>& corrList) {
[6556]114 bncTime epoTime;
115 unsigned int updateInt;
116 int numCorr;
117 string staID;
118 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::orbCorr) {
[6504]119 return;
120 }
121 for (int ii = 0; ii < numCorr; ii++) {
122 t_orbCorr corr;
[6556]123 corr._time = epoTime;
124 corr._updateInt = updateInt;
125 corr._staID = staID;
[6504]126
127 string line;
[6507]128 getline(inStream, line);
[6504]129 istringstream in(line.c_str());
130
131 in >> corr._prn >> corr._iod
132 >> corr._xr[0] >> corr._xr[1] >> corr._xr[2]
133 >> corr._dotXr[0] >> corr._dotXr[1] >> corr._dotXr[2];
134
135 corrList.push_back(corr);
136 }
[6455]137}
[6475]138
139//
140////////////////////////////////////////////////////////////////////////////
[6507]141void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
[6476]142 if (!out || biasList.size() == 0) {
143 return;
144 }
145 out->setf(ios::fixed);
146 bncTime epoTime;
147 QListIterator<t_satCodeBias> it(biasList);
148 while (it.hasNext()) {
149 const t_satCodeBias& satCodeBias = it.next();
150 if (!epoTime.valid()) {
151 epoTime = satCodeBias._time;
[6556]152 *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
153 << satCodeBias._updateInt << " "
[6476]154 << biasList.size() << ' ' << satCodeBias._staID << endl;
155 }
[6477]156 *out << satCodeBias._prn.toString();
157 for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
158 const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
159 *out << " " << frqCodeBias._rnxType2ch << ' '
160 << setw(10) << setprecision(4) << frqCodeBias._value;
161 }
[6476]162 *out << endl;
163 }
164 out->flush();
[6475]165}
166
167//
168////////////////////////////////////////////////////////////////////////////
[6507]169void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
[6556]170 bncTime epoTime;
171 unsigned int updateInt;
172 int numSat;
173 string staID;
174 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::codeBias) {
[6505]175 return;
176 }
177 for (int ii = 0; ii < numSat; ii++) {
178 t_satCodeBias satCodeBias;
[6556]179 satCodeBias._time = epoTime;
180 satCodeBias._updateInt = updateInt;
181 satCodeBias._staID = staID;
[6505]182
183 string line;
[6507]184 getline(inStream, line);
[6505]185 istringstream in(line.c_str());
186
187 in >> satCodeBias._prn;
188
189 while (in.good()) {
190 t_frqCodeBias frqCodeBias;
191 in >> frqCodeBias._rnxType2ch >> frqCodeBias._value;
192 if (!frqCodeBias._rnxType2ch.empty()) {
193 satCodeBias._bias.push_back(frqCodeBias);
194 }
195 }
196
197 biasList.push_back(satCodeBias);
198 }
[6475]199}
[6481]200
201//
202////////////////////////////////////////////////////////////////////////////
[6507]203void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
[6493]204 if (!out || biasList.size() == 0) {
205 return;
206 }
207 out->setf(ios::fixed);
208 bncTime epoTime;
209 QListIterator<t_satPhaseBias> it(biasList);
210 while (it.hasNext()) {
211 const t_satPhaseBias& satPhaseBias = it.next();
212 if (!epoTime.valid()) {
213 epoTime = satPhaseBias._time;
[6556]214 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
215 << satPhaseBias._updateInt << " "
[6493]216 << biasList.size() << ' ' << satPhaseBias._staID << endl;
217 }
[6494]218 *out << satPhaseBias._prn.toString() << ' '
219 << setw(12) << setprecision(8) << satPhaseBias._yawDeg << ' '
220 << setw(12) << setprecision(8) << satPhaseBias._yawDegRate << " ";
[6493]221 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
222 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
223 *out << " " << frqPhaseBias._rnxType2ch << ' '
[6494]224 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
225 << setw(3) << frqPhaseBias._fixIndicator << ' '
226 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
227 << setw(3) << frqPhaseBias._jumpCounter;
[6493]228 }
229 *out << endl;
230 }
231 out->flush();
[6481]232}
233
234//
235////////////////////////////////////////////////////////////////////////////
[6507]236void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
[6556]237 bncTime epoTime;
238 unsigned int updateInt;
239 int numSat;
240 string staID;
241 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::phaseBias) {
[6506]242 return;
243 }
244 for (int ii = 0; ii < numSat; ii++) {
245 t_satPhaseBias satPhaseBias;
[6556]246 satPhaseBias._time = epoTime;
247 satPhaseBias._updateInt = updateInt;
248 satPhaseBias._staID = staID;
[6506]249
250 string line;
[6507]251 getline(inStream, line);
[6506]252 istringstream in(line.c_str());
253
254 in >> satPhaseBias._prn >> satPhaseBias._yawDeg >> satPhaseBias._yawDegRate;
255
256 while (in.good()) {
257 t_frqPhaseBias frqPhaseBias;
258 in >> frqPhaseBias._rnxType2ch >> frqPhaseBias._value
259 >> frqPhaseBias._fixIndicator >> frqPhaseBias._fixWideLaneIndicator
260 >> frqPhaseBias._jumpCounter;
261 if (!frqPhaseBias._rnxType2ch.empty()) {
262 satPhaseBias._bias.push_back(frqPhaseBias);
263 }
264 }
265
266 biasList.push_back(satPhaseBias);
267 }
[6481]268}
[6482]269
270//
271////////////////////////////////////////////////////////////////////////////
[6507]272void t_vTec::write(ostream* out, const t_vTec& vTec) {
[6493]273 if (!out || vTec._layers.size() == 0) {
274 return;
275 }
276 out->setf(ios::fixed);
277 bncTime epoTime = vTec._time;
[6556]278 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
279 << vTec._updateInt << " "
[6493]280 << vTec._layers.size() << ' ' << vTec._staID << endl;
[6495]281 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
282 const t_vTecLayer& layer = vTec._layers[ii];
[6496]283 *out << setw(2) << ii+1 << ' '
284 << setw(2) << layer._C.Nrows() << ' '
285 << setw(2) << layer._C.Ncols() << ' '
286 << setw(10) << setprecision(1) << layer._height << endl
[6495]287 << setw(10) << setprecision(4) << layer._C
288 << setw(10) << setprecision(4) << layer._S;
289 }
[6493]290 out->flush();
[6482]291}
292
293//
294////////////////////////////////////////////////////////////////////////////
[6507]295void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
[6556]296 bncTime epoTime;
297 unsigned int updateInt;
298 int numLayers;
299 string staID;
300 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numLayers, staID) != t_corrSSR::vTec) {
[6507]301 return;
302 }
303 if (numLayers <= 0) {
304 return;
305 }
[6556]306 vTec._time = epoTime;
307 vTec._updateInt = updateInt;
308 vTec._staID = staID;
[6507]309 for (int ii = 0; ii < numLayers; ii++) {
310 t_vTecLayer layer;
311
312 string line;
313 getline(inStream, line);
314 istringstream in(line.c_str());
315
316 int dummy, maxDeg, maxOrd;
[6515]317 in >> dummy >> maxDeg >> maxOrd >> layer._height;
[6507]318
319 layer._C.ReSize(maxDeg, maxOrd);
320 layer._S.ReSize(maxDeg, maxOrd);
321
[6508]322 for (int iDeg = 0; iDeg < maxDeg; iDeg++) {
323 for (int iOrd = 0; iOrd < maxOrd; iOrd++) {
324 inStream >> layer._C[iDeg][iOrd];
325 }
326 }
327 for (int iDeg = 0; iDeg < maxDeg; iDeg++) {
328 for (int iOrd = 0; iOrd < maxOrd; iOrd++) {
329 inStream >> layer._S[iDeg][iOrd];
330 }
331 }
[6507]332
333 vTec._layers.push_back(layer);
334 }
[6482]335}
[6498]336
337//
338////////////////////////////////////////////////////////////////////////////
[6501]339t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
[6556]340 unsigned int& updateInt, int& numEntries,
341 string& staID) {
[6498]342
[6500]343 istringstream inLine(line.c_str());
344
345 char epoChar;
346 string typeString;
347 int year, month, day, hour, min;
348 double sec;
349
[6501]350 inLine >> epoChar >> typeString
[6556]351 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
[6500]352
353 if (epoChar == '>') {
354 epoTime.set(year, month, day, hour, min, sec);
355 if (typeString == "CLOCK") {
356 return clkCorr;
357 }
358 else if (typeString == "ORBIT") {
359 return orbCorr;
360 }
361 else if (typeString == "CODE_BIAS") {
362 return codeBias;
363 }
364 else if (typeString == "PHASE_BIAS") {
365 return phaseBias;
366 }
367 else if (typeString == "VTEC") {
368 return vTec;
369 }
370 }
371
372 return unknown;
[6498]373}
Note: See TracBrowser for help on using the repository browser.