source: ntrip/trunk/BNC/src/bncsinextro.cpp@ 7848

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

minor format changes regarding PCO info in sinex tro header

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