1 |
|
---|
2 | /* -------------------------------------------------------------------------
|
---|
3 | * BKG NTRIP Server
|
---|
4 | * -------------------------------------------------------------------------
|
---|
5 | *
|
---|
6 | * Class: bncSinexTro
|
---|
7 | *
|
---|
8 | * Purpose: writes SINEX TRO files
|
---|
9 | *
|
---|
10 | * Author: A. Stürze
|
---|
11 | *
|
---|
12 | * Created: 19-Feb-2015
|
---|
13 | *
|
---|
14 | * Changes:
|
---|
15 | *
|
---|
16 | * -----------------------------------------------------------------------*/
|
---|
17 |
|
---|
18 | #include <math.h>
|
---|
19 | #include <iomanip>
|
---|
20 |
|
---|
21 | #include "bncsinextro.h"
|
---|
22 |
|
---|
23 | using namespace BNC_PPP;
|
---|
24 | using namespace std;
|
---|
25 |
|
---|
26 | // Constructor
|
---|
27 | ////////////////////////////////////////////////////////////////////////////
|
---|
28 | bncSinexTro::bncSinexTro(const t_pppOptions* opt,
|
---|
29 | const QString& sklFileName, const QString& intr,
|
---|
30 | int sampl)
|
---|
31 | : bncoutf(sklFileName, intr, sampl) {
|
---|
32 |
|
---|
33 | _opt = opt;
|
---|
34 | _sampl = sampl;
|
---|
35 |
|
---|
36 | _antex = 0;
|
---|
37 | }
|
---|
38 |
|
---|
39 | // Destructor
|
---|
40 | ////////////////////////////////////////////////////////////////////////////
|
---|
41 | bncSinexTro::~bncSinexTro() {
|
---|
42 | closeFile();
|
---|
43 | if (_antex)
|
---|
44 | delete _antex;
|
---|
45 | }
|
---|
46 |
|
---|
47 | // Write Header
|
---|
48 | ////////////////////////////////////////////////////////////////////////////
|
---|
49 | void bncSinexTro::writeHeader(const QDateTime& datTim) {
|
---|
50 | int GPSWeek;
|
---|
51 | double GPSWeeks;
|
---|
52 | bncSettings settings;
|
---|
53 | GPSweekFromDateAndTime(datTim, GPSWeek, GPSWeeks);
|
---|
54 | int daysec = int(fmod(GPSWeeks, 86400.0));
|
---|
55 | int dayOfYear = datTim.date().dayOfYear();
|
---|
56 | QString yy = datTim.toString("yy");
|
---|
57 | QString creationTime = QString("%1:%2:%3").arg(yy)
|
---|
58 | .arg(dayOfYear, 3, 10, QLatin1Char('0'))
|
---|
59 | .arg(daysec , 5, 10, QLatin1Char('0'));
|
---|
60 | QString startTime = creationTime;
|
---|
61 | QString intStr = settings.value("PPP/snxtroIntr").toString();
|
---|
62 | int intr, indHlp = 0;
|
---|
63 | if ((indHlp = intStr.indexOf("min")) != -1) {
|
---|
64 | intr = intStr.left(indHlp-1).toInt();
|
---|
65 | intr *= 60;
|
---|
66 | }
|
---|
67 | else if ((indHlp = intStr.indexOf("hour")) != -1) {
|
---|
68 | intr = intStr.left(indHlp-1).toInt();
|
---|
69 | intr *= 3600;
|
---|
70 | }
|
---|
71 | else if ((indHlp = intStr.indexOf("day")) != -1) {
|
---|
72 | intr = intStr.left(indHlp-1).toInt();
|
---|
73 | intr *= 86400;
|
---|
74 | }
|
---|
75 | int nominalStartSec = daysec - (int(fmod(double(daysec), double(intr))));
|
---|
76 | int nominalEndSec = nominalStartSec + intr - _sampl;
|
---|
77 | QString endTime = QString("%1:%2:%3").arg(yy)
|
---|
78 | .arg(dayOfYear , 3, 10, QLatin1Char('0'))
|
---|
79 | .arg(nominalEndSec , 5, 10, QLatin1Char('0'));
|
---|
80 | int numEpochs = ((nominalEndSec - daysec) / _sampl) +1;
|
---|
81 | QString epo = QString("%1").arg(numEpochs, 5, 10, QLatin1Char('0'));
|
---|
82 | QString ac = QString("%1").arg(settings.value("PPP/snxtroAc").toString(),3,QLatin1Char(' '));
|
---|
83 | QString sol = QString("%1").arg(settings.value("PPP/snxtroSol").toString(),4,QLatin1Char(' '));
|
---|
84 | QString corr = settings.value("PPP/corrMount").toString();
|
---|
85 |
|
---|
86 | _out << "%=TRO 2.00 " << ac.toStdString() << " "
|
---|
87 | << creationTime.toStdString() << " " << ac.toStdString() << " "
|
---|
88 | << startTime.toStdString() << " " << endTime.toStdString() << " P "
|
---|
89 | << epo.toStdString() << " 0 " << " T " << endl;
|
---|
90 |
|
---|
91 | _out << "+FILE/REFERENCE" << endl;
|
---|
92 | _out << " DESCRIPTION " << "BNC generated SINEX TRO file" << endl;
|
---|
93 | _out << " OUTPUT " << "Total Troposphere Zenith Path Delay Product" << endl;
|
---|
94 | _out << " SOFTWARE " << BNCPGMNAME << endl;
|
---|
95 | _out << " INPUT " << "Ntrip streams, additional Orbit and Clock information from "
|
---|
96 | << corr.toStdString() <<endl;
|
---|
97 | _out << "-FILE/REFERENCE" << endl << endl;
|
---|
98 |
|
---|
99 | double recEll[3];
|
---|
100 | int lonD, lonM, latD, latM;
|
---|
101 | double lonS, latS;
|
---|
102 | xyz2ell(_opt->_xyzAprRover.data(), recEll);
|
---|
103 | deg2DMS(recEll[0] * 180.0 / M_PI, latD, latM, latS);
|
---|
104 | deg2DMS(recEll[1] * 180.0 / M_PI, lonD, lonM, lonS);
|
---|
105 | QString country;
|
---|
106 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
107 | while (it.hasNext()) {
|
---|
108 | QStringList hlp = it.next().split(" ");
|
---|
109 | if (hlp.size() < 7)
|
---|
110 | continue;
|
---|
111 | if (hlp.join(" ").indexOf(QString::fromStdString(_opt->_roverName), 0) != -1) {
|
---|
112 | country = hlp[2];
|
---|
113 | }
|
---|
114 | }
|
---|
115 | _out << "+SITE/ID" << endl;
|
---|
116 | _out << "*CODE PT DOMES____ T _STATION DESCRIPTION__ APPROX_LON_ APPROX_LAT_ _APP_H_" << endl;
|
---|
117 | _out << " " << _opt->_roverName.substr(0,4) << " A P "
|
---|
118 | << country.toStdString() << " "
|
---|
119 | << QString(" %1").arg(lonD, 3, 10, QLatin1Char(' ')).toStdString()
|
---|
120 | << QString(" %1").arg(lonM, 2, 10, QLatin1Char(' ')).toStdString()
|
---|
121 | << QString(" %1").arg(lonS, 4, 'f', 1, QLatin1Char(' ')).toStdString()
|
---|
122 | << QString(" %1").arg(latD, 3, 10, QLatin1Char(' ')).toStdString()
|
---|
123 | << QString(" %1").arg(latM, 2, 10, QLatin1Char(' ')).toStdString()
|
---|
124 | << QString(" %1").arg(latS, 4, 'f', 1, QLatin1Char(' ')).toStdString()
|
---|
125 | << QString(" %1").arg(recEll[2], 7, 'f', 1, QLatin1Char(' ')).toStdString()
|
---|
126 | << endl;
|
---|
127 | _out << "-SITE/ID" << endl << endl;
|
---|
128 |
|
---|
129 | if (!_opt->_recNameRover.empty()) {
|
---|
130 | _out << "+SITE/RECEIVER" << endl;
|
---|
131 | _out << "*SITE PT SOLN T DATA_START__ DATA_END____ DESCRIPTION_________ S/N__ FIRMWARE___" << endl;
|
---|
132 | _out << " " << _opt->_roverName.substr(0,4) << " A " << sol.toStdString() << " P "
|
---|
133 | << startTime.toStdString() << " " << endTime.toStdString()
|
---|
134 | << QString(" %1").arg(_opt->_recNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
135 | << " -----" << " -----------" << endl;
|
---|
136 | _out << "-SITE/RECEIVER" << endl << endl;
|
---|
137 | }
|
---|
138 |
|
---|
139 | _out << "+SITE/ANTENNA" << endl;
|
---|
140 | _out << "*SITE PT SOLN T DATA_START__ DATA_END____ DESCRIPTION_________ S/N__" << endl;
|
---|
141 | _out << " " << _opt->_roverName.substr(0,4) << " A " << sol.toStdString() << " P "
|
---|
142 | << startTime.toStdString() << " " << endTime.toStdString() << " "
|
---|
143 | << _opt->_antNameRover << " -----" << endl;
|
---|
144 | _out << "-SITE/ANTENNA" << endl << endl;
|
---|
145 |
|
---|
146 | if (!_opt->_antexFileName.empty()) {
|
---|
147 | _antex = new bncAntex(_opt->_antexFileName.c_str());
|
---|
148 | if (_opt->_LCsGPS.size()) {
|
---|
149 | _out << "+SITE/GPS_PHASE_CENTER" << endl;
|
---|
150 | _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
|
---|
151 | _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
|
---|
152 | _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
153 | << " -----"
|
---|
154 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::G1).toStdString()
|
---|
155 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::G2).toStdString()
|
---|
156 | << " ---------"
|
---|
157 | << endl;
|
---|
158 | _out << "-SITE/GPS_PHASE_CENTER" << endl << endl;
|
---|
159 | }
|
---|
160 | if (_opt->_LCsGLONASS.size()) {
|
---|
161 | _out << "+SITE/GLONASS_PHASE_CENTER" << endl;
|
---|
162 | _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
|
---|
163 | _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
|
---|
164 | _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
165 | << " -----"
|
---|
166 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::R1).toStdString()
|
---|
167 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::R2).toStdString()
|
---|
168 | << " ---------"
|
---|
169 | << endl;
|
---|
170 | _out << "-SITE/GLONASS_PHASE_CENTER" << endl << endl;
|
---|
171 | }
|
---|
172 | if (_opt->_LCsGalileo.size()) {
|
---|
173 | _out << "+SITE/GALILEO_PHASE_CENTER" << endl;
|
---|
174 | _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
|
---|
175 | _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
|
---|
176 | _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
177 | << " -----"
|
---|
178 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::E1).toStdString()
|
---|
179 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::E5).toStdString()
|
---|
180 | << endl;
|
---|
181 | _out << "-SITE/GALILEO_PHASE_CENTER" << endl << endl;
|
---|
182 | }
|
---|
183 | if (_opt->_LCsBDS.size()) {
|
---|
184 | _out << "+SITE/BEIDOU_PHASE_CENTER" << endl;
|
---|
185 | _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
|
---|
186 | _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
|
---|
187 | _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
|
---|
188 | << " -----"
|
---|
189 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::C2).toStdString()
|
---|
190 | << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::C7).toStdString()
|
---|
191 | << endl;
|
---|
192 | _out << "-SITE/BEIDOU_PHASE_CENTER" << endl << endl;
|
---|
193 | }
|
---|
194 | delete _antex;
|
---|
195 | _antex = 0;
|
---|
196 | }
|
---|
197 |
|
---|
198 | _out << "+SITE/ECCENTRICITY" << endl;
|
---|
199 | _out << "* UP______ NORTH___ EAST____" << endl;
|
---|
200 | _out << "*SITE PT SOLN T DATA_START__ DATA_END____ AXE ARP->BENCHMARK(M)_________" << endl;
|
---|
201 | _out << " " << _opt->_roverName.substr(0,4) << " A " << sol.toStdString() << " P "
|
---|
202 | << startTime.toStdString() << " " << endTime.toStdString() << " UNE"
|
---|
203 | << QString("%1").arg(_opt->_neuEccRover(3), 9, 'f', 4, QLatin1Char(' ')).toStdString()
|
---|
204 | << QString("%1").arg(_opt->_neuEccRover(1), 9, 'f', 4, QLatin1Char(' ')).toStdString()
|
---|
205 | << QString("%1").arg(_opt->_neuEccRover(2), 9, 'f', 4, QLatin1Char(' ')).toStdString() << endl;
|
---|
206 | _out << "-SITE/ECCENTRICITY" << endl << endl;
|
---|
207 |
|
---|
208 | _out << "+TROP/COORDINATES" << endl;
|
---|
209 | _out << "*SITE PT SOLN T STA_X_______ STA_Y_______ STA_Z_______ SYSTEM REMARK" << endl;
|
---|
210 | _out << " " << _opt->_roverName.substr(0,4) << " A " << sol.toStdString() << " P"
|
---|
211 | << QString(" %1").arg(_opt->_xyzAprRover(1), 12, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
212 | << QString(" %1").arg(_opt->_xyzAprRover(2), 12, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
213 | << QString(" %1").arg(_opt->_xyzAprRover(3), 12, 'f', 3, QLatin1Char(' ')).toStdString()
|
---|
214 | << " ITRF14 " << ac.toStdString() << endl;
|
---|
215 | _out << "-TROP/COORDINATES"<< endl << endl;
|
---|
216 |
|
---|
217 | _out << "+TROP/DESCRIPTION" << endl;
|
---|
218 | _out << "*KEYWORD______________________ VALUE(S)______________" << endl;
|
---|
219 | _out << " SAMPLING INTERVAL "
|
---|
220 | << setw(4) << _sampl << endl;
|
---|
221 | _out << " SAMPLING TROP "
|
---|
222 | << setw(4) << _sampl << endl;
|
---|
223 | _out << " ELEVATION CUTOFF ANGLE "
|
---|
224 | << setw(4) << int(_opt->_minEle * 180.0/M_PI) << endl;
|
---|
225 | _out << " TROP MAPPING FUNCTION " << "Saastamoinen" << endl;
|
---|
226 | _out << " SOLUTION_FIELDS_1 " << "TROTOT STDEV" << endl;
|
---|
227 | _out << "-TROP/DESCRIPTION"<< endl << endl;
|
---|
228 |
|
---|
229 | _out << "+TROP/SOLUTION" << endl;
|
---|
230 | _out << "*SITE EPOCH_______ TROTOT STDEV" << endl;
|
---|
231 | }
|
---|
232 |
|
---|
233 | // Write One Epoch
|
---|
234 | ////////////////////////////////////////////////////////////////////////////
|
---|
235 | t_irc bncSinexTro::write(QByteArray staID, int GPSWeek, double GPSWeeks,
|
---|
236 | double trotot, double stdev) {
|
---|
237 |
|
---|
238 | QDateTime datTim = dateAndTimeFromGPSweek(GPSWeek, GPSWeeks);
|
---|
239 | int daysec = int(fmod(GPSWeeks, 86400.0));
|
---|
240 | int dayOfYear = datTim.date().dayOfYear();
|
---|
241 | QString yy = datTim.toString("yy");
|
---|
242 | QString time = QString("%1:%2:%3").arg(yy)
|
---|
243 | .arg(dayOfYear, 3, 10, QLatin1Char('0'))
|
---|
244 | .arg(daysec , 5, 10, QLatin1Char('0'));
|
---|
245 |
|
---|
246 | if ((reopen(GPSWeek, GPSWeeks) == success) &&
|
---|
247 | (fmod(daysec, double(_sampl)) == 0.0)) {
|
---|
248 | _out << ' ' << staID.left(4).data() << ' ' << time.toStdString() << ' '
|
---|
249 | << noshowpos << setw(6) << setprecision(1) << trotot * 1000.0
|
---|
250 | << noshowpos << setw(6) << setprecision(1) << stdev * 1000.0 << endl;
|
---|
251 | _out.flush();
|
---|
252 | return success;
|
---|
253 | } else {
|
---|
254 | return failure;
|
---|
255 | }
|
---|
256 | }
|
---|
257 |
|
---|
258 | // Close File (write last lines)
|
---|
259 | ////////////////////////////////////////////////////////////////////////////
|
---|
260 | void bncSinexTro::closeFile() {
|
---|
261 | _out << "-TROP/SOLUTION" << endl;
|
---|
262 | _out << "%=ENDTROP" << endl;
|
---|
263 | bncoutf::closeFile();
|
---|
264 | }
|
---|
265 |
|
---|
266 |
|
---|
267 |
|
---|
268 |
|
---|