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

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

separate consideration of ssr update interval

File size: 11.5 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 _iod = 0;
14 _dClk = 0.0;
15 _dotDClk = 0.0;
16 _dotDotDClk = 0.0;
17}
18
19//
20////////////////////////////////////////////////////////////////////////////
21void t_clkCorr::writeEpoch(ostream* out, const QList<t_clkCorr>& corrList) {
22 if (!out || corrList.size() == 0) {
23 return;
24 }
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;
32 *out << "> CLOCK " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
33 << corr._updateInt << " "
34 << corrList.size() << ' ' << corr._staID << endl;
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 }
41 out->flush();
42}
43
44//
45////////////////////////////////////////////////////////////////////////////
46void t_clkCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_clkCorr>& corrList) {
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) {
52 return;
53 }
54 for (int ii = 0; ii < numCorr; ii++) {
55 t_clkCorr corr;
56 corr._time = epoTime;
57 corr._updateInt = updateInt;
58 corr._staID = staID;
59
60 string line;
61 getline(inStream, line);
62 istringstream in(line.c_str());
63
64 in >> corr._prn >> corr._iod >> corr._dClk >> corr._dotDClk >> corr._dotDotDClk;
65
66 corr._dClk /= t_CST::c;
67 corr._dotDClk /= t_CST::c;
68 corr._dotDotDClk /= t_CST::c;
69
70 corrList.push_back(corr);
71 }
72}
73
74// Constructor
75////////////////////////////////////////////////////////////////////////////
76t_orbCorr::t_orbCorr() {
77 _iod = 0;
78 _system = 'R';
79 _xr.ReSize(3); _xr = 0.0;
80 _dotXr.ReSize(3); _dotXr = 0.0;
81}
82
83//
84////////////////////////////////////////////////////////////////////////////
85void t_orbCorr::writeEpoch(ostream* out, const QList<t_orbCorr>& corrList) {
86 if (!out || corrList.size() == 0) {
87 return;
88 }
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;
96 *out << "> ORBIT " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
97 << corr._updateInt << " "
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 }
108 out->flush();
109}
110
111//
112////////////////////////////////////////////////////////////////////////////
113void t_orbCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_orbCorr>& corrList) {
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) {
119 return;
120 }
121 for (int ii = 0; ii < numCorr; ii++) {
122 t_orbCorr corr;
123 corr._time = epoTime;
124 corr._updateInt = updateInt;
125 corr._staID = staID;
126
127 string line;
128 getline(inStream, line);
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 }
137}
138
139//
140////////////////////////////////////////////////////////////////////////////
141void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
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;
152 *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
153 << satCodeBias._updateInt << " "
154 << biasList.size() << ' ' << satCodeBias._staID << endl;
155 }
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 }
162 *out << endl;
163 }
164 out->flush();
165}
166
167//
168////////////////////////////////////////////////////////////////////////////
169void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
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) {
175 return;
176 }
177 for (int ii = 0; ii < numSat; ii++) {
178 t_satCodeBias satCodeBias;
179 satCodeBias._time = epoTime;
180 satCodeBias._updateInt = updateInt;
181 satCodeBias._staID = staID;
182
183 string line;
184 getline(inStream, line);
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 }
199}
200
201//
202////////////////////////////////////////////////////////////////////////////
203void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
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;
214 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
215 << satPhaseBias._updateInt << " "
216 << biasList.size() << ' ' << satPhaseBias._staID << endl;
217 }
218 *out << satPhaseBias._prn.toString() << ' '
219 << setw(12) << setprecision(8) << satPhaseBias._yawDeg << ' '
220 << setw(12) << setprecision(8) << satPhaseBias._yawDegRate << " ";
221 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
222 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
223 *out << " " << frqPhaseBias._rnxType2ch << ' '
224 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
225 << setw(3) << frqPhaseBias._fixIndicator << ' '
226 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
227 << setw(3) << frqPhaseBias._jumpCounter;
228 }
229 *out << endl;
230 }
231 out->flush();
232}
233
234//
235////////////////////////////////////////////////////////////////////////////
236void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
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) {
242 return;
243 }
244 for (int ii = 0; ii < numSat; ii++) {
245 t_satPhaseBias satPhaseBias;
246 satPhaseBias._time = epoTime;
247 satPhaseBias._updateInt = updateInt;
248 satPhaseBias._staID = staID;
249
250 string line;
251 getline(inStream, line);
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 }
268}
269
270//
271////////////////////////////////////////////////////////////////////////////
272void t_vTec::write(ostream* out, const t_vTec& vTec) {
273 if (!out || vTec._layers.size() == 0) {
274 return;
275 }
276 out->setf(ios::fixed);
277 bncTime epoTime = vTec._time;
278 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
279 << vTec._updateInt << " "
280 << vTec._layers.size() << ' ' << vTec._staID << endl;
281 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
282 const t_vTecLayer& layer = vTec._layers[ii];
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
287 << setw(10) << setprecision(4) << layer._C
288 << setw(10) << setprecision(4) << layer._S;
289 }
290 out->flush();
291}
292
293//
294////////////////////////////////////////////////////////////////////////////
295void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
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) {
301 return;
302 }
303 if (numLayers <= 0) {
304 return;
305 }
306 vTec._time = epoTime;
307 vTec._updateInt = updateInt;
308 vTec._staID = staID;
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;
317 in >> dummy >> maxDeg >> maxOrd >> layer._height;
318
319 layer._C.ReSize(maxDeg, maxOrd);
320 layer._S.ReSize(maxDeg, maxOrd);
321
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 }
332
333 vTec._layers.push_back(layer);
334 }
335}
336
337//
338////////////////////////////////////////////////////////////////////////////
339t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
340 unsigned int& updateInt, int& numEntries,
341 string& staID) {
342
343 istringstream inLine(line.c_str());
344
345 char epoChar;
346 string typeString;
347 int year, month, day, hour, min;
348 double sec;
349
350 inLine >> epoChar >> typeString
351 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
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;
373}
Note: See TracBrowser for help on using the repository browser.