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

Last change on this file since 6630 was 6589, checked in by stuerze, 10 years ago

minor changes

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