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

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

additional changes to allow 10 Hz observation data processing

  • 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
RevLine 
[6653]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) {
[7521]32
[6653]33 _opt = opt;
[8403]34 _sampl = sampl;
[7521]35
[7862]36 _antex = 0;
[6653]37}
38
39// Destructor
40////////////////////////////////////////////////////////////////////////////
41bncSinexTro::~bncSinexTro() {
42 closeFile();
[7521]43 if (_antex)
44 delete _antex;
[6653]45}
46
47// Write Header
48////////////////////////////////////////////////////////////////////////////
49void bncSinexTro::writeHeader(const QDateTime& datTim) {
50 int GPSWeek;
51 double GPSWeeks;
[7521]52 bncSettings settings;
[6653]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;
[7521]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 }
[7767]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'));
[7788]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(' '));
[7764]84 QString corr = settings.value("PPP/corrMount").toString();
[7767]85
[7764]86 _out << "%=TRO 2.00 " << ac.toStdString() << " "
[7767]87 << creationTime.toStdString() << " " << ac.toStdString() << " "
88 << startTime.toStdString() << " " << endTime.toStdString() << " P "
89 << epo.toStdString() << " 0 " << " T " << endl;
[6653]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;
[7764]94 _out << " SOFTWARE " << BNCPGMNAME << endl;
[7766]95 _out << " INPUT " << "Ntrip streams, additional Orbit and Clock information from "
[7764]96 << corr.toStdString() <<endl;
[6653]97 _out << "-FILE/REFERENCE" << endl << endl;
98
[7764]99 double recEll[3];
100 int lonD, lonM, latD, latM;
101 double lonS, latS;
102 xyz2ell(_opt->_xyzAprRover.data(), recEll);
[7788]103 deg2DMS(recEll[0] * 180.0 / M_PI, latD, latM, latS);
104 deg2DMS(recEll[1] * 180.0 / M_PI, lonD, lonM, lonS);
[7764]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 }
[7521]115 _out << "+SITE/ID" << endl;
[7769]116 _out << "*CODE PT DOMES____ T _STATION DESCRIPTION__ APPROX_LON_ APPROX_LAT_ _APP_H_" << endl;
[7764]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;
[7521]127 _out << "-SITE/ID" << endl << endl;
128
[7523]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;
[7764]132 _out << " " << _opt->_roverName.substr(0,4) << " A " << sol.toStdString() << " P "
[7788]133 << startTime.toStdString() << " " << endTime.toStdString()
[8134]134 << QString(" %1").arg(_opt->_recNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
[7788]135 << " -----" << " -----------" << endl;
[7523]136 _out << "-SITE/RECEIVER" << endl << endl;
137 }
[7521]138
139 _out << "+SITE/ANTENNA" << endl;
140 _out << "*SITE PT SOLN T DATA_START__ DATA_END____ DESCRIPTION_________ S/N__" << endl;
[7764]141 _out << " " << _opt->_roverName.substr(0,4) << " A " << sol.toStdString() << " P "
[7788]142 << startTime.toStdString() << " " << endTime.toStdString() << " "
143 << _opt->_antNameRover << " -----" << endl;
[7521]144 _out << "-SITE/ANTENNA" << endl << endl;
145
[7862]146 if (!_opt->_antexFileName.empty()) {
147 _antex = new bncAntex(_opt->_antexFileName.c_str());
[7521]148 if (_opt->_LCsGPS.size()) {
149 _out << "+SITE/GPS_PHASE_CENTER" << endl;
[7766]150 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
151 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
[7521]152 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
[7789]153 << " -----"
[7521]154 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::G1).toStdString()
155 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::G2).toStdString()
[7848]156 << " ---------"
[7521]157 << endl;
158 _out << "-SITE/GPS_PHASE_CENTER" << endl << endl;
159 }
160 if (_opt->_LCsGLONASS.size()) {
161 _out << "+SITE/GLONASS_PHASE_CENTER" << endl;
[7766]162 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
163 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
[7521]164 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
[7789]165 << " -----"
[7521]166 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::R1).toStdString()
167 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::R2).toStdString()
[7848]168 << " ---------"
[7521]169 << endl;
170 _out << "-SITE/GLONASS_PHASE_CENTER" << endl << endl;
171 }
172 if (_opt->_LCsGalileo.size()) {
173 _out << "+SITE/GALILEO_PHASE_CENTER" << endl;
[7766]174 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
175 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
[7521]176 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
[7789]177 << " -----"
[7521]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;
[7766]185 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
186 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
[7521]187 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
[7789]188 << " -----"
[7521]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 }
[7862]194 delete _antex;
195 _antex = 0;
[7521]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;
[7764]201 _out << " " << _opt->_roverName.substr(0,4) << " A " << sol.toStdString() << " P "
[7766]202 << startTime.toStdString() << " " << endTime.toStdString() << " UNE"
[7521]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;
[7770]206 _out << "-SITE/ECCENTRICITY" << endl << endl;
[7521]207
208 _out << "+TROP/COORDINATES" << endl;
[7766]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()
[8110]214 << " ITRF14 " << ac.toStdString() << endl;
[7521]215 _out << "-TROP/COORDINATES"<< endl << endl;
216
[6653]217 _out << "+TROP/DESCRIPTION" << endl;
218 _out << "*KEYWORD______________________ VALUE(S)______________" << endl;
[6658]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;
[6653]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////////////////////////////////////////////////////////////////////////////
235t_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////////////////////////////////////////////////////////////////////////////
260void bncSinexTro::closeFile() {
261 _out << "-TROP/SOLUTION" << endl;
262 _out << "%=ENDTROP" << endl;
263 bncoutf::closeFile();
264}
265
266
267
268
Note: See TracBrowser for help on using the repository browser.