source: ntrip/branches/BNC_2.13.beta/src/bncsinextro.cpp@ 10212

Last change on this file since 10212 was 10083, checked in by stuerze, 18 months ago

blq filename is added 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: 14.1 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;
35
36 _antex = 0;
37}
38
39// Destructor
40////////////////////////////////////////////////////////////////////////////
41bncSinexTro::~bncSinexTro() {
42 closeFile();
43 if (_antex)
44 delete _antex;
45}
46
47// Write Header
48////////////////////////////////////////////////////////////////////////////
49void 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(),1,QLatin1Char(' '));
84 QString corr = "";
85 if (settings.value("PPP/dataSource").toString() == "Real-Time Streams") {
86 corr = settings.value("PPP/corrMount").toString();
87 }
88 else if (settings.value("PPP/dataSource").toString() == "RINEX Files") {
89 corr = settings.value("PPP/corrFile").toString();
90 }
91
92 QString signalPriorities = QString::fromStdString(_opt->_signalPriorities);
93 if (!signalPriorities.size()) {
94 signalPriorities = "G:12&CWPSLX R:12&CP E:1&CBX E:5&QIX C:26&IQX";
95 }
96 QStringList priorList = signalPriorities.split(" ", QString::SkipEmptyParts);
97 QStringList frqStrList;
98 for (unsigned iFreq = 1; iFreq < t_frequency::max; iFreq++) {
99 t_frequency::type frqType = static_cast<t_frequency::type>(iFreq);
100 char frqSys = t_frequency::toString(frqType)[0];
101 char frqNum = t_frequency::toString(frqType)[1];
102 QStringList hlp;
103 for (int ii = 0; ii < priorList.size(); ii++) {
104 if (priorList[ii].indexOf(":") != -1) {
105 hlp = priorList[ii].split(":", QString::SkipEmptyParts);
106 if (hlp.size() == 2 && hlp[0].length() == 1 && hlp[0][0] == frqSys) {
107 hlp = hlp[1].split("&", QString::SkipEmptyParts);
108 }
109 if (hlp.size() == 2 && hlp[0].indexOf(frqNum) != -1) {
110 frqStrList.append(QString("%1%2").arg(frqSys).arg(frqNum));
111 }
112 }
113 }
114 }
115
116 _out << "%=TRO 2.00 " << ac.toStdString() << " "
117 << creationTime.toStdString() << " " << ac.toStdString() << " "
118 << startTime.toStdString() << " " << endTime.toStdString() << " P "
119 << epo.toStdString() << " 0 " << " T " << endl;
120
121 _out << "+FILE/REFERENCE" << endl;
122 _out << " DESCRIPTION " << "BNC generated SINEX TRO file" << endl;
123 _out << " OUTPUT " << "Total Troposphere Zenith Path Delay Product" << endl;
124 _out << " SOFTWARE " << BNCPGMNAME << endl;
125 _out << " INPUT " << "Observations: " << _opt->_roverName.substr(0,9)
126 << ", SSR corrections: " << corr.toStdString() << endl;
127 _out << "-FILE/REFERENCE" << endl << endl;
128
129 double recEll[3];
130 int lonD, lonM, latD, latM;
131 double lonS, latS;
132 xyz2ell(_opt->_xyzAprRover.data(), recEll);
133 deg2DMS(recEll[0] * 180.0 / M_PI, latD, latM, latS);
134 deg2DMS(recEll[1] * 180.0 / M_PI, lonD, lonM, lonS);
135 QString country;
136 QListIterator<QString> it(settings.value("mountPoints").toStringList());
137 while (it.hasNext()) {
138 QStringList hlp = it.next().split(" ");
139 if (hlp.size() < 7)
140 continue;
141 if (hlp.join(" ").indexOf(QString::fromStdString(_opt->_roverName), 0) != -1) {
142 country = hlp[2];
143 }
144 }
145 _out << "+SITE/ID" << endl;
146 _out << "*CODE PT DOMES____ T _STATION DESCRIPTION__ APPROX_LON_ APPROX_LAT_ _APP_H_" << endl;
147 _out << " " << _opt->_roverName.substr(0,9) << " A P "
148 << country.toStdString() << " "
149 << QString(" %1").arg(lonD, 3, 10, QLatin1Char(' ')).toStdString()
150 << QString(" %1").arg(lonM, 2, 10, QLatin1Char(' ')).toStdString()
151 << QString(" %1").arg(lonS, 4, 'f', 1, QLatin1Char(' ')).toStdString()
152 << QString(" %1").arg(latD, 3, 10, QLatin1Char(' ')).toStdString()
153 << QString(" %1").arg(latM, 2, 10, QLatin1Char(' ')).toStdString()
154 << QString(" %1").arg(latS, 4, 'f', 1, QLatin1Char(' ')).toStdString()
155 << QString(" %1").arg(recEll[2], 7, 'f', 1, QLatin1Char(' ')).toStdString()
156 << endl;
157 _out << "-SITE/ID" << endl << endl;
158
159 if (!_opt->_recNameRover.empty()) {
160 _out << "+SITE/RECEIVER" << endl;
161 _out << "*SITE PT SOLN T DATA_START__ DATA_END____ DESCRIPTION_________ S/N__ FIRMWARE___" << endl;
162 _out << " " << _opt->_roverName.substr(0,9) << " A " << sol.toStdString() << " P "
163 << startTime.toStdString() << " " << endTime.toStdString()
164 << QString(" %1").arg(_opt->_recNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
165 << " -----" << " -----------" << endl;
166 _out << "-SITE/RECEIVER" << endl << endl;
167 }
168
169 _out << "+SITE/ANTENNA" << endl;
170 _out << "*SITE PT SOLN T DATA_START__ DATA_END____ DESCRIPTION_________ S/N__" << endl;
171 _out << " " << _opt->_roverName.substr(0,9) << " A " << sol.toStdString() << " P "
172 << startTime.toStdString() << " " << endTime.toStdString() << " "
173 << _opt->_antNameRover << " -----" << endl;
174 _out << "-SITE/ANTENNA" << endl << endl;
175
176 if (!_opt->_antexFileName.empty()) {
177 _antex = new bncAntex(_opt->_antexFileName.c_str());
178 if (_opt->_LCsGPS.size()) {
179 _out << "+SITE/GPS_PHASE_CENTER" << endl;
180 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
181 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
182 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
183 << " -----";
184 for (int i = 0; i < frqStrList.size(); ++i) {
185 if (frqStrList.at(i).contains('G')) {//cout << frqStrList.at(i).toStdString() << endl;
186 _out << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::toInt(frqStrList.at(i).toStdString())).toStdString();
187 }
188 }
189 _out << " ---------" << endl;
190 _out << "-SITE/GPS_PHASE_CENTER" << endl << endl;
191 }
192 if (_opt->_LCsGLONASS.size()) {
193 _out << "+SITE/GLONASS_PHASE_CENTER" << endl;
194 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
195 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
196 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
197 << " -----";
198 for (int i = 0; i < frqStrList.size(); ++i) {
199 if (frqStrList.at(i).contains('R')) {//cout << frqStrList.at(i).toStdString() << endl;
200 _out << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::toInt(frqStrList.at(i).toStdString())).toStdString();
201 }
202 }
203 _out << " ---------" << endl;
204 _out << "-SITE/GLONASS_PHASE_CENTER" << endl << endl;
205 }
206 if (_opt->_LCsGalileo.size()) {
207 _out << "+SITE/GALILEO_PHASE_CENTER" << endl;
208 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
209 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
210 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
211 << " -----";
212 for (int i = 0; i < frqStrList.size(); ++i) {
213 if (frqStrList.at(i).contains('E')) {//cout << frqStrList.at(i).toStdString() << endl;
214 _out << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::toInt(frqStrList.at(i).toStdString())).toStdString();
215 }
216 }
217 _out << " ---------" << endl;
218 _out << "-SITE/GALILEO_PHASE_CENTER" << endl << endl;
219 }
220 if (_opt->_LCsBDS.size()) {
221 _out << "+SITE/BEIDOU_PHASE_CENTER" << endl;
222 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
223 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
224 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
225 << " -----";
226 for (int i = 0; i < frqStrList.size(); ++i) {
227 if (frqStrList.at(i).contains('C')) {//cout << frqStrList.at(i).toStdString() << endl;
228 _out << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::toInt(frqStrList.at(i).toStdString())).toStdString();
229 }
230 }
231 _out << " ---------" << endl;
232 _out << "-SITE/BEIDOU_PHASE_CENTER" << endl << endl;
233 }
234 delete _antex;
235 _antex = 0;
236 }
237
238 _out << "+SITE/ECCENTRICITY" << endl;
239 _out << "* UP______ NORTH___ EAST____" << endl;
240 _out << "*SITE PT SOLN T DATA_START__ DATA_END____ AXE ARP->BENCHMARK(M)_________" << endl;
241 _out << " " << _opt->_roverName.substr(0,9) << " A " << sol.toStdString() << " P "
242 << startTime.toStdString() << " " << endTime.toStdString() << " UNE"
243 << QString("%1").arg(_opt->_neuEccRover(3), 9, 'f', 4, QLatin1Char(' ')).toStdString()
244 << QString("%1").arg(_opt->_neuEccRover(1), 9, 'f', 4, QLatin1Char(' ')).toStdString()
245 << QString("%1").arg(_opt->_neuEccRover(2), 9, 'f', 4, QLatin1Char(' ')).toStdString() << endl;
246 _out << "-SITE/ECCENTRICITY" << endl << endl;
247
248 _out << "+TROP/COORDINATES" << endl;
249 _out << "*SITE PT SOLN T STA_X_______ STA_Y_______ STA_Z_______ SYSTEM REMARK" << endl;
250 _out << " " << _opt->_roverName.substr(0,9) << " A " << sol.toStdString() << " P"
251 << QString(" %1").arg(_opt->_xyzAprRover(1), 12, 'f', 3, QLatin1Char(' ')).toStdString()
252 << QString(" %1").arg(_opt->_xyzAprRover(2), 12, 'f', 3, QLatin1Char(' ')).toStdString()
253 << QString(" %1").arg(_opt->_xyzAprRover(3), 12, 'f', 3, QLatin1Char(' ')).toStdString()
254 << " IGS20 " << ac.toStdString() << endl;
255 _out << "-TROP/COORDINATES"<< endl << endl;
256
257 QString blqFileName = QString::fromStdString(_opt->_blqFileName);
258 QString blqFileBaseName;
259 QString blqFileExtension;
260 if (! blqFileName.isEmpty()) {
261 QFileInfo fileInfo(blqFileName);
262 blqFileBaseName = fileInfo.baseName();
263 blqFileExtension = fileInfo.completeSuffix();
264 if (!blqFileExtension.isEmpty()) {
265 blqFileExtension = "." + blqFileExtension;
266 }
267 }
268 _out << "+TROP/DESCRIPTION" << endl;
269 _out << "*KEYWORD______________________ VALUE(S)______________" << endl;
270 _out << " SAMPLING INTERVAL "
271 << setw(4) << _sampl << endl;
272 _out << " SAMPLING TROP "
273 << setw(4) << _sampl << endl;
274 _out << " ELEVATION CUTOFF ANGLE "
275 << setw(4) << int(_opt->_minEle * 180.0/M_PI) << endl;
276 _out << " OCEAN TIDE LOADING MODEL " << blqFileBaseName.toStdString() + blqFileExtension.toStdString() << endl;
277 _out << " TROP MAPPING FUNCTION " << "Saastamoinen" << endl;
278 _out << " SOLUTION_FIELDS_1 " << "TROTOT STDEV" << endl;
279 _out << "-TROP/DESCRIPTION"<< endl << endl;
280
281 _out << "+TROP/SOLUTION" << endl;
282 _out << "*SITE EPOCH_______ TROTOT STDEV" << endl;
283}
284
285// Write One Epoch
286////////////////////////////////////////////////////////////////////////////
287t_irc bncSinexTro::write(QByteArray staID, int GPSWeek, double GPSWeeks,
288 double trotot, double stdev) {
289
290 QDateTime datTim = dateAndTimeFromGPSweek(GPSWeek, GPSWeeks);
291 int daysec = int(fmod(GPSWeeks, 86400.0));
292 int dayOfYear = datTim.date().dayOfYear();
293 QString yy = datTim.toString("yy");
294 QString time = QString("%1:%2:%3").arg(yy)
295 .arg(dayOfYear, 3, 10, QLatin1Char('0'))
296 .arg(daysec , 5, 10, QLatin1Char('0'));
297
298 if ((reopen(GPSWeek, GPSWeeks) == success) &&
299 (fmod(daysec, double(_sampl)) == 0.0)) {
300 _out << ' ' << staID.left(9).data() << ' ' << time.toStdString() << ' '
301 << noshowpos << setw(6) << setprecision(1) << trotot * 1000.0
302 << noshowpos << setw(6) << setprecision(1) << stdev * 1000.0 << endl;
303 _out.flush();
304 return success;
305 } else {
306 return failure;
307 }
308}
309
310// Close File (write last lines)
311////////////////////////////////////////////////////////////////////////////
312void bncSinexTro::closeFile() {
313 _out << "-TROP/SOLUTION" << endl;
314 _out << "%=ENDTROP" << endl;
315 bncoutf::closeFile();
316}
317
318
319
320
Note: See TracBrowser for help on using the repository browser.