source: ntrip/branches/BNC_2.12/src/bncsp3.cpp@ 10076

Last change on this file since 10076 was 8484, checked in by stuerze, 6 years ago

SSR parameter clock rate, clock drift and URA are added within RTNET format

File size: 6.8 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Server
4 * -------------------------------------------------------------------------
5 *
6 * Class: bncSP3
7 *
8 * Purpose: writes SP3 files
9 *
10 * Author: L. Mervart
11 *
12 * Created: 25-Apr-2008
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iomanip>
19#include <sstream>
20#include <math.h>
21
22#include "bncsp3.h"
23#include "bncutils.h"
24
25using namespace std;
26
27// Constructor
28////////////////////////////////////////////////////////////////////////////
29bncSP3::bncSP3(const QString& fileName) : bncoutf(QString(), QString(), 0) {
30 _inpOut = input;
31 _currEpoch = 0;
32 _prevEpoch = 0;
33
34 _stream.open(fileName.toAscii().data());
35 if (!_stream.good()) {
36 throw "t_sp3File: cannot open file " + fileName;
37 }
38
39 while (_stream.good()) {
40 getline(_stream, _lastLine);
41 if (_lastLine[0] == '*') {
42 break;
43 }
44 }
45}
46
47// Constructor
48////////////////////////////////////////////////////////////////////////////
49bncSP3::bncSP3(const QString& sklFileName, const QString& intr, int sampl)
50 : bncoutf(sklFileName, intr, sampl) {
51 _inpOut = output;
52 _currEpoch = 0;
53 _prevEpoch = 0;
54}
55
56// Destructor
57////////////////////////////////////////////////////////////////////////////
58bncSP3::~bncSP3() {
59 delete _currEpoch;
60 delete _prevEpoch;
61}
62
63// Write One Epoch
64////////////////////////////////////////////////////////////////////////////
65t_irc bncSP3::write(int GPSweek, double GPSweeks, const QString& prn,
66 const ColumnVector& xCoM, double sp3Clk,
67 const ColumnVector& v, double sp3ClkRate) {
68
69 if (reopen(GPSweek, GPSweeks) == success) {
70
71 bncTime epoTime(GPSweek, GPSweeks);
72
73 if (epoTime != _lastEpoTime) {
74
75 // Check the sampling interval (print empty epochs)
76 // ------------------------------------------------
77 if (_lastEpoTime.valid() && _sampl > 0) {
78 for (bncTime ep = _lastEpoTime +_sampl; ep < epoTime; ep = ep +_sampl) {
79 _out << "* " << ep.datestr(' ') << ' ' << ep.timestr(8, ' ') << endl;
80 }
81 }
82
83 // Print the new epoch
84 // -------------------
85 _out << "* " << epoTime.datestr(' ') << ' ' << epoTime.timestr(8, ' ') << endl;
86
87 _lastEpoTime = epoTime;
88 }
89
90 _out << "P" << prn.toLatin1().data()
91 << setw(14) << setprecision(6) << xCoM(1) / 1000.0 // [km]
92 << setw(14) << setprecision(6) << xCoM(2) / 1000.0 // [km]
93 << setw(14) << setprecision(6) << xCoM(3) / 1000.0 // [km]
94 << setw(14) << setprecision(6) << sp3Clk * 1e6 // microseconds
95 << endl;
96
97 if (sp3ClkRate) {
98 _out << "V" << prn.toLatin1().data()
99 << setw(14) << setprecision(6) << v(1) * 10.0 // [dm/s]
100 << setw(14) << setprecision(6) << v(2) * 10.0 // [dm/s]
101 << setw(14) << setprecision(6) << v(3) * 10.0 // [dm/s]
102 << setw(14) << setprecision(6) << sp3ClkRate * 1e2 // 10^⁻4 microseconds/sec
103 << endl;
104 }
105 return success;
106 }
107 else {
108 return failure;
109 }
110}
111
112// Close File (write last line)
113////////////////////////////////////////////////////////////////////////////
114void bncSP3::closeFile() {
115 _out << "EOF" << endl;
116 bncoutf::closeFile();
117}
118
119// Write Header
120////////////////////////////////////////////////////////////////////////////
121void bncSP3::writeHeader(const QDateTime& datTim) {
122
123 int GPSWeek;
124 double GPSWeeks;
125 GPSweekFromDateAndTime(datTim, GPSWeek, GPSWeeks);
126
127 double sec = fmod(GPSWeeks, 60.0);
128
129 int mjd;
130 double dayfrac;
131 mjdFromDateAndTime(datTim, mjd, dayfrac);
132
133 int numEpo = _numSec;
134 if (_sampl > 0) {
135 numEpo /= _sampl;
136 }
137
138 _out << "#aP" << datTim.toString("yyyy MM dd hh mm").toAscii().data()
139 << setw(12) << setprecision(8) << sec
140 << " " << setw(7) << numEpo << " ORBIT IGS14 HLM IGS" << endl;
141
142 _out << "## "
143 << setw(4) << GPSWeek
144 << setw(16) << setprecision(8) << GPSWeeks
145 << setw(15) << setprecision(8) << double(_sampl)
146 << setw(6) << mjd
147 << setw(16) << setprecision(13) << dayfrac << endl;
148
149 _out << "+ 56 G01G02G03G04G05G06G07G08G09G10G11G12G13G14G15G16G17\n"
150 << "+ G18G19G20G21G22G23G24G25G26G27G28G29G30G31G32R01R02\n"
151 << "+ R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19\n"
152 << "+ R20R21R22R23R24 0 0 0 0 0 0 0 0 0 0 0 0\n"
153 << "+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
154 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
155 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
156 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
157 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
158 << "++ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
159 << "%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc\n"
160 << "%c cc cc ccc ccc cccc cccc cccc cccc ccccc ccccc ccccc ccccc\n"
161 << "%f 0.0000000 0.000000000 0.00000000000 0.000000000000000\n"
162 << "%f 0.0000000 0.000000000 0.00000000000 0.000000000000000\n"
163 << "%i 0 0 0 0 0 0 0 0 0\n"
164 << "%i 0 0 0 0 0 0 0 0 0\n"
165 << "/* \n"
166 << "/* \n"
167 << "/* \n"
168 << "/* \n";
169}
170
171// Read Next Epoch
172////////////////////////////////////////////////////////////////////////////
173const bncSP3::t_sp3Epoch* bncSP3::nextEpoch() {
174
175 delete _prevEpoch; _prevEpoch = _currEpoch; _currEpoch = 0;
176
177 if (_lastLine[0] == '*') {
178 _currEpoch = new t_sp3Epoch();
179 istringstream in(_lastLine.substr(1).c_str());
180 int YY, MM, DD, hh, mm;
181 double ss;
182 in >> YY >> MM >> DD >> hh >> mm >> ss;
183 _currEpoch->_tt.set(YY, MM, DD, hh, mm, ss);
184 }
185
186 while (_stream.good()) {
187 getline(_stream, _lastLine);
188 if (_stream.eof() || _lastLine.find("EOF") == 0) {
189 _stream.close();
190 break;
191 }
192 if (_lastLine[0] == '*') {
193 break;
194 }
195
196 t_sp3Sat* sp3Sat = new t_sp3Sat();
197 istringstream in(_lastLine.substr(1).c_str());
198 in >> sp3Sat->_prn >> sp3Sat->_xyz(1) >> sp3Sat->_xyz(2) >> sp3Sat->_xyz(3) >> sp3Sat->_clk;
199
200 if (sp3Sat->_xyz.norm_Frobenius() == 0.0) {
201 delete sp3Sat;
202 continue;
203 }
204
205 sp3Sat->_xyz *= 1.e3;
206 if (sp3Sat->_clk == 999999.999999) {
207 sp3Sat->_clkValid = false;
208 sp3Sat->_clk = 0.0;
209 }
210 else {
211 sp3Sat->_clkValid = true;
212 sp3Sat->_clk *= t_CST::c * 1.e-6;
213 }
214
215 _currEpoch->_sp3Sat.push_back(sp3Sat);
216 }
217
218 return _currEpoch;
219}
Note: See TracBrowser for help on using the repository browser.