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

Last change on this file since 9250 was 8694, checked in by stuerze, 5 years ago

minor changes

File size: 14.0 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
[8483]20//
[6144]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
[8483]45//
[6144]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());
[8483]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
[8483]87//
[6144]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
[8483]115//
[6455]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());
[8483]134
[7003]135 in >> corr._prn >> corr._iod
[8483]136 >> corr._xr[0] >> corr._xr[1] >> corr._xr[2]
[6504]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
[8483]146// Constructor
[6475]147////////////////////////////////////////////////////////////////////////////
[8483]148t_URA::t_URA() {
149 _updateInt = 0;
150 _iod = 0;
151 _ura = 0.0;
152}
153
154//
155////////////////////////////////////////////////////////////////////////////
156void t_URA::writeEpoch(ostream* out, const QList<t_URA>& corrList) {
157 if (!out || corrList.size() == 0) {
158 return;
159 }
160 out->setf(ios::fixed);
161 bncTime epoTime;
162 QListIterator<t_URA> it(corrList);
163 while (it.hasNext()) {
164 const t_URA& corr = it.next();
165 if (!epoTime.valid()) {
166 epoTime = corr._time;
167 *out << "> URA " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
168 << corr._updateInt << " "
169 << corrList.size() << ' ' << corr._staID << endl;
170 }
171 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
172 << setw(10) << setprecision(4) << corr._ura << endl;
173 }
174 out->flush();
175}
176
177//
178////////////////////////////////////////////////////////////////////////////
179void t_URA::readEpoch(const string& epoLine, istream& inStream, QList<t_URA>& corrList) {
180 bncTime epoTime;
181 unsigned int updateInt;
182 int numCorr;
183 string staID;
184 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::URA) {
185 return;
186 }
187 for (int ii = 0; ii < numCorr; ii++) {
188 t_URA corr;
189 corr._time = epoTime;
190 corr._updateInt = updateInt;
191 corr._staID = staID;
192
193 string line;
194 getline(inStream, line);
195 istringstream in(line.c_str());
196
197 in >> corr._prn >> corr._iod >> corr._ura;
198
199 corrList.push_back(corr);
200 }
201}
202
203//
204////////////////////////////////////////////////////////////////////////////
[6507]205void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
[6476]206 if (!out || biasList.size() == 0) {
207 return;
208 }
209 out->setf(ios::fixed);
210 bncTime epoTime;
211 QListIterator<t_satCodeBias> it(biasList);
212 while (it.hasNext()) {
213 const t_satCodeBias& satCodeBias = it.next();
214 if (!epoTime.valid()) {
215 epoTime = satCodeBias._time;
[6556]216 *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
217 << satCodeBias._updateInt << " "
[6476]218 << biasList.size() << ' ' << satCodeBias._staID << endl;
219 }
[8694]220 if (!satCodeBias._bias.size()) {
221 continue;
222 }
[6567]223 *out << satCodeBias._prn.toString() << " " << setw(2) << satCodeBias._bias.size();
[6477]224 for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
225 const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
226 *out << " " << frqCodeBias._rnxType2ch << ' '
227 << setw(10) << setprecision(4) << frqCodeBias._value;
228 }
[6476]229 *out << endl;
230 }
231 out->flush();
[6475]232}
233
[8483]234//
[6475]235////////////////////////////////////////////////////////////////////////////
[6507]236void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& 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::codeBias) {
[6505]242 return;
243 }
244 for (int ii = 0; ii < numSat; ii++) {
245 t_satCodeBias satCodeBias;
[6556]246 satCodeBias._time = epoTime;
247 satCodeBias._updateInt = updateInt;
248 satCodeBias._staID = staID;
[6505]249
250 string line;
[6507]251 getline(inStream, line);
[6505]252 istringstream in(line.c_str());
[8483]253
[6567]254 int numBias;
255 in >> satCodeBias._prn >> numBias;
[6505]256
257 while (in.good()) {
258 t_frqCodeBias frqCodeBias;
259 in >> frqCodeBias._rnxType2ch >> frqCodeBias._value;
260 if (!frqCodeBias._rnxType2ch.empty()) {
261 satCodeBias._bias.push_back(frqCodeBias);
262 }
263 }
264
265 biasList.push_back(satCodeBias);
266 }
[6475]267}
[6481]268
[8483]269//
[6481]270////////////////////////////////////////////////////////////////////////////
[6507]271void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
[6493]272 if (!out || biasList.size() == 0) {
273 return;
274 }
275 out->setf(ios::fixed);
276 bncTime epoTime;
277 QListIterator<t_satPhaseBias> it(biasList);
278 while (it.hasNext()) {
279 const t_satPhaseBias& satPhaseBias = it.next();
280 if (!epoTime.valid()) {
281 epoTime = satPhaseBias._time;
[6556]282 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
283 << satPhaseBias._updateInt << " "
[6857]284 << biasList.size() << ' ' << satPhaseBias._staID << endl;
[6859]285 *out << " " << satPhaseBias._dispBiasConstistInd << " "
286 << satPhaseBias._MWConsistInd << endl;
[6493]287 }
[6494]288 *out << satPhaseBias._prn.toString() << ' '
[8617]289 << setw(12) << setprecision(8) << satPhaseBias._yaw * 180.0 / M_PI << ' '
290 << setw(12) << setprecision(8) << satPhaseBias._yawRate * 180.0 / M_PI<< " "
[6567]291 << setw(2) << satPhaseBias._bias.size();
[6493]292 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
293 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
294 *out << " " << frqPhaseBias._rnxType2ch << ' '
[6494]295 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
296 << setw(3) << frqPhaseBias._fixIndicator << ' '
297 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
298 << setw(3) << frqPhaseBias._jumpCounter;
[6493]299 }
300 *out << endl;
301 }
302 out->flush();
[6481]303}
[8483]304
305//
[6481]306////////////////////////////////////////////////////////////////////////////
[6507]307void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
[6556]308 bncTime epoTime;
309 unsigned int updateInt;
310 int numSat;
311 string staID;
[6859]312 unsigned int dispInd;
313 unsigned int mwInd;
[6556]314 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::phaseBias) {
[6506]315 return;
316 }
[6859]317 for (int ii = 0; ii <= numSat; ii++) {
[6506]318 t_satPhaseBias satPhaseBias;
[6556]319 satPhaseBias._time = epoTime;
320 satPhaseBias._updateInt = updateInt;
321 satPhaseBias._staID = staID;
[6506]322
323 string line;
[6507]324 getline(inStream, line);
[6506]325 istringstream in(line.c_str());
[6857]326
[6859]327 if (ii == 0) {
328 in >> dispInd >> mwInd;
329 continue;
330 }
331 satPhaseBias._dispBiasConstistInd = dispInd;
332 satPhaseBias._MWConsistInd = mwInd;
333
[6567]334 int numBias;
[8617]335 double yawDeg, yawDegRate;
336 in >> satPhaseBias._prn >> yawDeg >> yawDegRate >> numBias;
337 satPhaseBias._yaw = yawDeg * M_PI / 180.0;
338 satPhaseBias._yawRate = yawDegRate * M_PI / 180.0;
[6506]339
340 while (in.good()) {
341 t_frqPhaseBias frqPhaseBias;
342 in >> frqPhaseBias._rnxType2ch >> frqPhaseBias._value
343 >> frqPhaseBias._fixIndicator >> frqPhaseBias._fixWideLaneIndicator
344 >> frqPhaseBias._jumpCounter;
345 if (!frqPhaseBias._rnxType2ch.empty()) {
346 satPhaseBias._bias.push_back(frqPhaseBias);
347 }
348 }
349
350 biasList.push_back(satPhaseBias);
351 }
[6481]352}
[6482]353
[8483]354//
[6482]355////////////////////////////////////////////////////////////////////////////
[6507]356void t_vTec::write(ostream* out, const t_vTec& vTec) {
[6493]357 if (!out || vTec._layers.size() == 0) {
358 return;
359 }
360 out->setf(ios::fixed);
361 bncTime epoTime = vTec._time;
[6556]362 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
363 << vTec._updateInt << " "
[6493]364 << vTec._layers.size() << ' ' << vTec._staID << endl;
[6495]365 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
366 const t_vTecLayer& layer = vTec._layers[ii];
[6496]367 *out << setw(2) << ii+1 << ' '
[6878]368 << setw(2) << layer._C.Nrows()-1 << ' '
369 << setw(2) << layer._C.Ncols()-1 << ' '
[8483]370 << setw(10) << setprecision(1) << layer._height << endl
371 << setw(10) << setprecision(4) << layer._C
[6495]372 << setw(10) << setprecision(4) << layer._S;
373 }
[6493]374 out->flush();
[6482]375}
376
[8483]377//
[6482]378////////////////////////////////////////////////////////////////////////////
[6507]379void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
[6556]380 bncTime epoTime;
381 unsigned int updateInt;
382 int numLayers;
383 string staID;
384 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numLayers, staID) != t_corrSSR::vTec) {
[6507]385 return;
386 }
387 if (numLayers <= 0) {
388 return;
389 }
[6556]390 vTec._time = epoTime;
391 vTec._updateInt = updateInt;
392 vTec._staID = staID;
[6507]393 for (int ii = 0; ii < numLayers; ii++) {
394 t_vTecLayer layer;
395
396 string line;
397 getline(inStream, line);
398 istringstream in(line.c_str());
399
400 int dummy, maxDeg, maxOrd;
[6515]401 in >> dummy >> maxDeg >> maxOrd >> layer._height;
[6507]402
[6878]403 layer._C.ReSize(maxDeg+1, maxOrd+1);
404 layer._S.ReSize(maxDeg+1, maxOrd+1);
[6507]405
[6878]406 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
407 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
[6508]408 inStream >> layer._C[iDeg][iOrd];
409 }
410 }
[6878]411 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
412 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
[6508]413 inStream >> layer._S[iDeg][iOrd];
414 }
415 }
[6507]416
417 vTec._layers.push_back(layer);
418 }
[6482]419}
[6498]420
[8483]421//
[6498]422////////////////////////////////////////////////////////////////////////////
[8483]423t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
[6556]424 unsigned int& updateInt, int& numEntries,
425 string& staID) {
[6498]426
[6500]427 istringstream inLine(line.c_str());
428
429 char epoChar;
430 string typeString;
431 int year, month, day, hour, min;
432 double sec;
433
[8483]434 inLine >> epoChar >> typeString
[6556]435 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
[6500]436
437 if (epoChar == '>') {
438 epoTime.set(year, month, day, hour, min, sec);
439 if (typeString == "CLOCK") {
440 return clkCorr;
441 }
442 else if (typeString == "ORBIT") {
443 return orbCorr;
444 }
445 else if (typeString == "CODE_BIAS") {
446 return codeBias;
447 }
448 else if (typeString == "PHASE_BIAS") {
449 return phaseBias;
450 }
451 else if (typeString == "VTEC") {
452 return vTec;
453 }
[8483]454 else if (typeString == "URA") {
455 return URA;
456 }
[6500]457 }
458
459 return unknown;
[6498]460}
Note: See TracBrowser for help on using the repository browser.