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

Last change on this file was 10565, checked in by stuerze, 6 weeks ago

bug fixed in writing CodeBiases into a SSR file

File size: 14.2 KB
Line 
1#include <iostream>
2#include <iomanip>
3#include <sstream>
4#include <newmatio.h>
5
6#include "satObs.h"
7
8using namespace std;
9
10// Constructor
11////////////////////////////////////////////////////////////////////////////
12t_clkCorr::t_clkCorr() {
13 _updateInt = 0;
14 _iod = 0;
15 _dClk = 0.0;
16 _dotDClk = 0.0;
17 _dotDotDClk = 0.0;
18}
19
20//
21////////////////////////////////////////////////////////////////////////////
22void t_clkCorr::writeEpoch(ostream* out, const QList<t_clkCorr>& corrList) {
23 if (!out || corrList.size() == 0) {
24 return;
25 }
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;
33 *out << "> CLOCK " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
34 << corr._updateInt << " "
35 << corrList.size() << ' ' << corr._staID << endl;
36 }
37 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
38 << setw(10) << setprecision(4) << corr._dClk * t_CST::c << ' ' // m
39 << setw(10) << setprecision(4) << corr._dotDClk * t_CST::c * 1.e3 << ' ' // m/s => mm/s
40 << setw(10) << setprecision(4) << corr._dotDotDClk * t_CST::c * 1.e3 << endl; // m/s² => mm/s²
41 }
42 out->flush();
43}
44
45//
46////////////////////////////////////////////////////////////////////////////
47void t_clkCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_clkCorr>& corrList) {
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) {
53 return;
54 }
55 for (int ii = 0; ii < numCorr; ii++) {
56 t_clkCorr corr;
57 corr._time = epoTime;
58 corr._updateInt = updateInt;
59 corr._staID = staID;
60
61 string line;
62 getline(inStream, line);
63 istringstream in(line.c_str());
64
65 in >> corr._prn >> corr._iod >> corr._dClk >> corr._dotDClk >> corr._dotDotDClk;
66 if (corr._prn.system() == 'E') {
67 corr._prn.setFlags(1);// I/NAV
68 }
69 corr._dClk /= (t_CST::c);
70 corr._dotDClk /= (t_CST::c * 1.e3);
71 corr._dotDotDClk /= (t_CST::c * 1.e3);
72
73 corrList.push_back(corr);
74 }
75}
76
77// Constructor
78////////////////////////////////////////////////////////////////////////////
79t_orbCorr::t_orbCorr() {
80 _updateInt = 0;
81 _iod = 0;
82 _system = 'R';
83 _xr.ReSize(3); _xr = 0.0;
84 _dotXr.ReSize(3); _dotXr = 0.0;
85}
86
87//
88////////////////////////////////////////////////////////////////////////////
89void t_orbCorr::writeEpoch(ostream* out, const QList<t_orbCorr>& corrList) {
90 if (!out || corrList.size() == 0) {
91 return;
92 }
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;
100 *out << "> ORBIT " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
101 << corr._updateInt << " "
102 << corrList.size() << ' ' << corr._staID << endl;
103 }
104 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
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] * 1.e3 << ' ' // m/s => mm/s
109 << setw(10) << setprecision(4) << corr._dotXr[1] * 1.e3 << ' ' // m/s => mm/s
110 << setw(10) << setprecision(4) << corr._dotXr[2] * 1.e3 << endl; // m/s => mm/s
111 }
112 out->flush();
113}
114
115//
116////////////////////////////////////////////////////////////////////////////
117void t_orbCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_orbCorr>& corrList) {
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) {
123 return;
124 }
125 for (int ii = 0; ii < numCorr; ii++) {
126 t_orbCorr corr;
127 corr._time = epoTime;
128 corr._updateInt = updateInt;
129 corr._staID = staID;
130
131 string line;
132 getline(inStream, line);
133 istringstream in(line.c_str());
134
135 in >> corr._prn >> corr._iod
136 >> corr._xr[0] >> corr._xr[1] >> corr._xr[2]
137 >> corr._dotXr[0] >> corr._dotXr[1] >> corr._dotXr[2];
138
139 corr._dotXr[0] /= 1.e3; // mm/s => m/s
140 corr._dotXr[1] /= 1.e3; // mm/s => m/s
141 corr._dotXr[2] /= 1.e3; // mm/s => m/s
142
143 if (corr._prn.system() == 'E') {
144 corr._prn.setFlags(1);// I/NAV
145 }
146 corrList.push_back(corr);
147 }
148}
149
150// Constructor
151////////////////////////////////////////////////////////////////////////////
152t_URA::t_URA() {
153 _updateInt = 0;
154 _iod = 0;
155 _ura = 0.0;
156}
157
158//
159////////////////////////////////////////////////////////////////////////////
160void t_URA::writeEpoch(ostream* out, const QList<t_URA>& corrList) {
161 if (!out || corrList.size() == 0) {
162 return;
163 }
164 out->setf(ios::fixed);
165 bncTime epoTime;
166 QListIterator<t_URA> it(corrList);
167 while (it.hasNext()) {
168 const t_URA& corr = it.next();
169 if (!epoTime.valid()) {
170 epoTime = corr._time;
171 *out << "> URA " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
172 << corr._updateInt << " "
173 << corrList.size() << ' ' << corr._staID << endl;
174 }
175 *out << corr._prn.toString() << ' ' << setw(11) << corr._iod << ' '
176 << setw(10) << setprecision(4) << corr._ura << endl;
177 }
178 out->flush();
179}
180
181//
182////////////////////////////////////////////////////////////////////////////
183void t_URA::readEpoch(const string& epoLine, istream& inStream, QList<t_URA>& corrList) {
184 bncTime epoTime;
185 unsigned int updateInt;
186 int numCorr;
187 string staID;
188 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numCorr, staID) != t_corrSSR::URA) {
189 return;
190 }
191 for (int ii = 0; ii < numCorr; ii++) {
192 t_URA corr;
193 corr._time = epoTime;
194 corr._updateInt = updateInt;
195 corr._staID = staID;
196
197 string line;
198 getline(inStream, line);
199 istringstream in(line.c_str());
200
201 in >> corr._prn >> corr._iod >> corr._ura;
202
203 corrList.push_back(corr);
204 }
205}
206
207//
208////////////////////////////////////////////////////////////////////////////
209void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
210 if (!out || biasList.size() == 0) {
211 return;
212 }
213 out->setf(ios::fixed);
214 bncTime epoTime;
215 QListIterator<t_satCodeBias> it(biasList);
216 while (it.hasNext()) {
217 const t_satCodeBias& satCodeBias = it.next();
218 if (!epoTime.valid()) {
219 epoTime = satCodeBias._time;
220 *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
221 << satCodeBias._updateInt << " "
222 << biasList.size() << ' ' << satCodeBias._staID << endl;
223 }
224 *out << satCodeBias._prn.toString() << " " << setw(2) << satCodeBias._bias.size();
225 for (unsigned ii = 0; ii < satCodeBias._bias.size(); ii++) {
226 const t_frqCodeBias& frqCodeBias = satCodeBias._bias[ii];
227 *out << " " << frqCodeBias._rnxType2ch << ' '
228 << setw(10) << setprecision(4) << frqCodeBias._value;
229 }
230 *out << endl;
231 }
232 out->flush();
233}
234
235//
236////////////////////////////////////////////////////////////////////////////
237void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
238 bncTime epoTime;
239 unsigned int updateInt;
240 int numSat;
241 string staID;
242 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::codeBias) {
243 return;
244 }
245 for (int ii = 0; ii < numSat; ii++) {
246 t_satCodeBias satCodeBias;
247 satCodeBias._time = epoTime;
248 satCodeBias._updateInt = updateInt;
249 satCodeBias._staID = staID;
250
251 string line;
252 getline(inStream, line);
253 istringstream in(line.c_str());
254
255 int numBias;
256 in >> satCodeBias._prn >> numBias;
257
258 while (in.good()) {
259 t_frqCodeBias frqCodeBias;
260 in >> frqCodeBias._rnxType2ch >> frqCodeBias._value;
261 if (!frqCodeBias._rnxType2ch.empty()) {
262 satCodeBias._bias.push_back(frqCodeBias);
263 }
264 }
265
266 biasList.push_back(satCodeBias);
267 }
268}
269
270//
271////////////////////////////////////////////////////////////////////////////
272void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
273 if (!out || biasList.size() == 0) {
274 return;
275 }
276 out->setf(ios::fixed);
277 bncTime epoTime;
278 QListIterator<t_satPhaseBias> it(biasList);
279 while (it.hasNext()) {
280 const t_satPhaseBias& satPhaseBias = it.next();
281 if (!epoTime.valid()) {
282 epoTime = satPhaseBias._time;
283 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
284 << satPhaseBias._updateInt << " "
285 << biasList.size() << ' ' << satPhaseBias._staID << endl;
286 *out << " " << satPhaseBias._dispBiasConstistInd << " "
287 << satPhaseBias._MWConsistInd << endl;
288 }
289 *out << satPhaseBias._prn.toString() << ' '
290 << setw(12) << setprecision(8) << satPhaseBias._yaw * 180.0 / M_PI << ' '
291 << setw(12) << setprecision(8) << satPhaseBias._yawRate * 180.0 / M_PI<< " "
292 << setw(2) << satPhaseBias._bias.size();
293 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
294 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
295 *out << " " << frqPhaseBias._rnxType2ch << ' '
296 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
297 << setw(3) << frqPhaseBias._fixIndicator << ' '
298 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
299 << setw(3) << frqPhaseBias._jumpCounter;
300 }
301 *out << endl;
302 }
303 out->flush();
304}
305
306//
307////////////////////////////////////////////////////////////////////////////
308void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
309 bncTime epoTime;
310 unsigned int updateInt;
311 int numSat;
312 string staID;
313 unsigned int dispInd;
314 unsigned int mwInd;
315 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numSat, staID) != t_corrSSR::phaseBias) {
316 return;
317 }
318 for (int ii = 0; ii <= numSat; ii++) {
319 t_satPhaseBias satPhaseBias;
320 satPhaseBias._time = epoTime;
321 satPhaseBias._updateInt = updateInt;
322 satPhaseBias._staID = staID;
323
324 string line;
325 getline(inStream, line);
326 istringstream in(line.c_str());
327
328 if (ii == 0) {
329 in >> dispInd >> mwInd;
330 continue;
331 }
332 satPhaseBias._dispBiasConstistInd = dispInd;
333 satPhaseBias._MWConsistInd = mwInd;
334
335 int numBias;
336 double yawDeg, yawDegRate;
337 in >> satPhaseBias._prn >> yawDeg >> yawDegRate >> numBias;
338 satPhaseBias._yaw = yawDeg * M_PI / 180.0;
339 satPhaseBias._yawRate = yawDegRate * M_PI / 180.0;
340
341 while (in.good()) {
342 t_frqPhaseBias frqPhaseBias;
343 in >> frqPhaseBias._rnxType2ch >> frqPhaseBias._value
344 >> frqPhaseBias._fixIndicator >> frqPhaseBias._fixWideLaneIndicator
345 >> frqPhaseBias._jumpCounter;
346 if (!frqPhaseBias._rnxType2ch.empty()) {
347 satPhaseBias._bias.push_back(frqPhaseBias);
348 }
349 }
350
351 biasList.push_back(satPhaseBias);
352 }
353}
354
355//
356////////////////////////////////////////////////////////////////////////////
357void t_vTec::write(ostream* out, const t_vTec& vTec) {
358 if (!out || vTec._layers.size() == 0) {
359 return;
360 }
361 out->setf(ios::fixed);
362 bncTime epoTime = vTec._time;
363 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
364 << vTec._updateInt << " "
365 << vTec._layers.size() << ' ' << vTec._staID << endl;
366 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
367 const t_vTecLayer& layer = vTec._layers[ii];
368 *out << setw(2) << ii+1 << ' '
369 << setw(2) << layer._C.Nrows()-1 << ' '
370 << setw(2) << layer._C.Ncols()-1 << ' '
371 << setw(10) << setprecision(1) << layer._height << endl
372 << setw(10) << setprecision(4) << layer._C
373 << setw(10) << setprecision(4) << layer._S;
374 }
375 out->flush();
376}
377
378//
379////////////////////////////////////////////////////////////////////////////
380void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
381 bncTime epoTime;
382 unsigned int updateInt;
383 int numLayers;
384 string staID;
385 if (t_corrSSR::readEpoLine(epoLine, epoTime, updateInt, numLayers, staID) != t_corrSSR::vTec) {
386 return;
387 }
388 if (numLayers <= 0) {
389 return;
390 }
391 vTec._time = epoTime;
392 vTec._updateInt = updateInt;
393 vTec._staID = staID;
394 for (int ii = 0; ii < numLayers; ii++) {
395 t_vTecLayer layer;
396
397 string line;
398 getline(inStream, line);
399 istringstream in(line.c_str());
400
401 int dummy, maxDeg, maxOrd;
402 in >> dummy >> maxDeg >> maxOrd >> layer._height;
403
404 layer._C.ReSize(maxDeg+1, maxOrd+1);
405 layer._S.ReSize(maxDeg+1, maxOrd+1);
406
407 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
408 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
409 inStream >> layer._C[iDeg][iOrd];
410 }
411 }
412 for (int iDeg = 0; iDeg <= maxDeg; iDeg++) {
413 for (int iOrd = 0; iOrd <= maxOrd; iOrd++) {
414 inStream >> layer._S[iDeg][iOrd];
415 }
416 }
417
418 vTec._layers.push_back(layer);
419 }
420}
421
422//
423////////////////////////////////////////////////////////////////////////////
424t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
425 unsigned int& updateInt, int& numEntries,
426 string& staID) {
427
428 istringstream inLine(line.c_str());
429
430 char epoChar;
431 string typeString;
432 int year, month, day, hour, min;
433 double sec;
434
435 inLine >> epoChar >> typeString
436 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
437
438 if (epoChar == '>') {
439 epoTime.set(year, month, day, hour, min, sec);
440 if (typeString == "CLOCK") {
441 return clkCorr;
442 }
443 else if (typeString == "ORBIT") {
444 return orbCorr;
445 }
446 else if (typeString == "CODE_BIAS") {
447 return codeBias;
448 }
449 else if (typeString == "PHASE_BIAS") {
450 return phaseBias;
451 }
452 else if (typeString == "VTEC") {
453 return vTec;
454 }
455 else if (typeString == "URA") {
456 return URA;
457 }
458 }
459
460 return unknown;
461}
Note: See TracBrowser for help on using the repository browser.