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

Last change on this file since 7755 was 7058, checked in by stuerze, 9 years ago

some format changes to support IODs computed from CRC over broadcasted ephemris and clock parameters

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