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

Last change on this file since 7788 was 7788, checked in by stuerze, 8 years ago

minor format changes 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.7 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 << endl;
161 _out << "-SITE/GPS_PHASE_CENTER" << endl << endl;
162 }
163 if (_opt->_LCsGLONASS.size()) {
164 _out << "+SITE/GLONASS_PHASE_CENTER" << endl;
165 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
166 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
167 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
168 << " "
169 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::R1).toStdString()
170 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::R2).toStdString()
171 << endl;
172 _out << "-SITE/GLONASS_PHASE_CENTER" << endl << endl;
173 }
174 if (_opt->_LCsGalileo.size()) {
175 _out << "+SITE/GALILEO_PHASE_CENTER" << endl;
176 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
177 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
178 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
179 << " "
180 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::E1).toStdString()
181 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::E5).toStdString()
182 << endl;
183 _out << "-SITE/GALILEO_PHASE_CENTER" << endl << endl;
184 }
185 if (_opt->_LCsBDS.size()) {
186 _out << "+SITE/BEIDOU_PHASE_CENTER" << endl;
187 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
188 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
189 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
190 << " "
191 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::C2).toStdString()
192 << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::C7).toStdString()
193 << endl;
194 _out << "-SITE/BEIDOU_PHASE_CENTER" << endl << endl;
195 }
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 << " ITRF08 " << 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////////////////////////////////////////////////////////////////////////////
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.