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
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(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 }
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
67 corr._dClk /= t_CST::c;
68 corr._dotDClk /= t_CST::c;
69 corr._dotDotDClk /= t_CST::c;
70
71 corrList.push_back(corr);
72 }
73}
74
75// Constructor
76////////////////////////////////////////////////////////////////////////////
77t_orbCorr::t_orbCorr() {
78 _updateInt = 0;
79 _iod = 0;
80 _system = 'R';
81 _xr.ReSize(3); _xr = 0.0;
82 _dotXr.ReSize(3); _dotXr = 0.0;
83}
84
85//
86////////////////////////////////////////////////////////////////////////////
87void t_orbCorr::writeEpoch(ostream* out, const QList<t_orbCorr>& corrList) {
88 if (!out || corrList.size() == 0) {
89 return;
90 }
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;
98 *out << "> ORBIT " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
99 << corr._updateInt << " "
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 }
110 out->flush();
111}
112
113//
114////////////////////////////////////////////////////////////////////////////
115void t_orbCorr::readEpoch(const string& epoLine, istream& inStream, QList<t_orbCorr>& corrList) {
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) {
121 return;
122 }
123 for (int ii = 0; ii < numCorr; ii++) {
124 t_orbCorr corr;
125 corr._time = epoTime;
126 corr._updateInt = updateInt;
127 corr._staID = staID;
128
129 string line;
130 getline(inStream, line);
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 }
139}
140
141//
142////////////////////////////////////////////////////////////////////////////
143void t_satCodeBias::writeEpoch(ostream* out, const QList<t_satCodeBias>& biasList) {
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;
154 *out << "> CODE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
155 << satCodeBias._updateInt << " "
156 << biasList.size() << ' ' << satCodeBias._staID << endl;
157 }
158 *out << satCodeBias._prn.toString() << " " << setw(2) << satCodeBias._bias.size();
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 }
164 *out << endl;
165 }
166 out->flush();
167}
168
169//
170////////////////////////////////////////////////////////////////////////////
171void t_satCodeBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satCodeBias>& biasList) {
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) {
177 return;
178 }
179 for (int ii = 0; ii < numSat; ii++) {
180 t_satCodeBias satCodeBias;
181 satCodeBias._time = epoTime;
182 satCodeBias._updateInt = updateInt;
183 satCodeBias._staID = staID;
184
185 string line;
186 getline(inStream, line);
187 istringstream in(line.c_str());
188
189 int numBias;
190 in >> satCodeBias._prn >> numBias;
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 }
202}
203
204//
205////////////////////////////////////////////////////////////////////////////
206void t_satPhaseBias::writeEpoch(ostream* out, const QList<t_satPhaseBias>& biasList) {
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;
217 *out << "> PHASE_BIAS " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
218 << satPhaseBias._updateInt << " "
219 << biasList.size() << ' ' << satPhaseBias._staID << endl;
220 }
221 *out << satPhaseBias._prn.toString() << ' '
222 << setw(12) << setprecision(8) << satPhaseBias._yawDeg << ' '
223 << setw(12) << setprecision(8) << satPhaseBias._yawDegRate << " "
224 << setw(2) << satPhaseBias._bias.size();
225 for (unsigned ii = 0; ii < satPhaseBias._bias.size(); ii++) {
226 const t_frqPhaseBias& frqPhaseBias = satPhaseBias._bias[ii];
227 *out << " " << frqPhaseBias._rnxType2ch << ' '
228 << setw(10) << setprecision(4) << frqPhaseBias._value << ' '
229 << setw(3) << frqPhaseBias._fixIndicator << ' '
230 << setw(3) << frqPhaseBias._fixWideLaneIndicator << ' '
231 << setw(3) << frqPhaseBias._jumpCounter;
232 }
233 *out << endl;
234 }
235 out->flush();
236}
237
238//
239////////////////////////////////////////////////////////////////////////////
240void t_satPhaseBias::readEpoch(const string& epoLine, istream& inStream, QList<t_satPhaseBias>& biasList) {
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) {
246 return;
247 }
248 for (int ii = 0; ii < numSat; ii++) {
249 t_satPhaseBias satPhaseBias;
250 satPhaseBias._time = epoTime;
251 satPhaseBias._updateInt = updateInt;
252 satPhaseBias._staID = staID;
253
254 string line;
255 getline(inStream, line);
256 istringstream in(line.c_str());
257
258 int numBias;
259 in >> satPhaseBias._prn >> satPhaseBias._yawDeg >> satPhaseBias._yawDegRate >> numBias;
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 }
273}
274
275//
276////////////////////////////////////////////////////////////////////////////
277void t_vTec::write(ostream* out, const t_vTec& vTec) {
278 if (!out || vTec._layers.size() == 0) {
279 return;
280 }
281 out->setf(ios::fixed);
282 bncTime epoTime = vTec._time;
283 *out << "> VTEC " << epoTime.datestr(' ') << ' ' << epoTime.timestr(1,' ') << " "
284 << vTec._updateInt << " "
285 << vTec._layers.size() << ' ' << vTec._staID << endl;
286 for (unsigned ii = 0; ii < vTec._layers.size(); ii++) {
287 const t_vTecLayer& layer = vTec._layers[ii];
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
292 << setw(10) << setprecision(4) << layer._C
293 << setw(10) << setprecision(4) << layer._S;
294 }
295 out->flush();
296}
297
298//
299////////////////////////////////////////////////////////////////////////////
300void t_vTec::read(const string& epoLine, istream& inStream, t_vTec& vTec) {
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) {
306 return;
307 }
308 if (numLayers <= 0) {
309 return;
310 }
311 vTec._time = epoTime;
312 vTec._updateInt = updateInt;
313 vTec._staID = staID;
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;
322 in >> dummy >> maxDeg >> maxOrd >> layer._height;
323
324 layer._C.ReSize(maxDeg, maxOrd);
325 layer._S.ReSize(maxDeg, maxOrd);
326
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 }
337
338 vTec._layers.push_back(layer);
339 }
340}
341
342//
343////////////////////////////////////////////////////////////////////////////
344t_corrSSR::e_type t_corrSSR::readEpoLine(const string& line, bncTime& epoTime,
345 unsigned int& updateInt, int& numEntries,
346 string& staID) {
347
348 istringstream inLine(line.c_str());
349
350 char epoChar;
351 string typeString;
352 int year, month, day, hour, min;
353 double sec;
354
355 inLine >> epoChar >> typeString
356 >> year >> month >> day >> hour >> min >> sec >> updateInt >> numEntries >> staID;
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;
378}
Note: See TracBrowser for help on using the repository browser.