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

Last change on this file since 10127 was 10127, checked in by stuerze, 14 months ago
  • Property svn:keywords set to Author Date Id Rev URL;svn:eol-style=native
  • Property svn:mime-type set to text/plain
File size: 15.2 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 solId = settings.value("PPP/snxtroSolId").toString();
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 _out << "*-------------------------------------------------------------------------------" << endl;
121 _out << "+FILE/REFERENCE" << endl;
122 _out << "*INFO_TYPE_________ INFO________________________________________________________" << endl;
123 _out << " DESCRIPTION " << "BNC generated SINEX TRO file" << endl;
124 _out << " OUTPUT " << "Total Troposphere Zenith Path Delay Product" << endl;
125 _out << " SOFTWARE " << BNCPGMNAME << endl;
126 _out << " INPUT " << "OBS: " << _opt->_roverName.substr(0,9) << ", SSR: " << corr.toStdString() << endl;
127 _out << " VERSON NUMBER " << QString("%1").arg(solId, 10, QLatin1Char(' ')).toStdString() << endl;
128 _out << "-FILE/REFERENCE" << endl;
129 _out << "*-------------------------------------------------------------------------------" << endl;
130
131
132 QString blqFileName = QString::fromStdString(_opt->_blqFileName);
133 QString blqFileBaseName;
134 QString blqFileExtension;
135 if (! blqFileName.isEmpty()) {
136 QFileInfo fileInfo(blqFileName);
137 blqFileBaseName = fileInfo.baseName();
138 blqFileExtension = fileInfo.completeSuffix();
139 if (!blqFileExtension.isEmpty()) {
140 blqFileExtension = "." + blqFileExtension;
141 }
142 }
143 _out << "+TROP/DESCRIPTION" << endl;
144 _out << "*KEYWORD______________________ VALUE(S)______________" << endl;
145 _out << " SAMPLING INTERVAL "
146 << setw(4) << _sampl << endl;
147 _out << " SAMPLING TROP "
148 << setw(4) << _sampl << endl;
149 _out << " ELEVATION CUTOFF ANGLE "
150 << setw(4) << int(_opt->_minEle * 180.0/M_PI) << endl;
151 if (! blqFileName.isEmpty()) {
152 _out << " OCEAN TIDE LOADING MODEL " << blqFileBaseName.toStdString() + blqFileExtension.toStdString() << endl;
153 }
154 _out << " TROP MAPPING FUNCTION " << "Saastamoinen" << endl;
155 _out << " SOLUTION_FIELDS_1 " << "TROTOT STDEV" << endl;
156 _out << "-TROP/DESCRIPTION"<< endl;
157 _out << "*-------------------------------------------------------------------------------" << endl;
158
159 double recEll[3];
160 int lonD, lonM, latD, latM;
161 double lonS, latS;
162 xyz2ell(_opt->_xyzAprRover.data(), recEll);
163 deg2DMS(recEll[0] * 180.0 / M_PI, latD, latM, latS);
164 deg2DMS(recEll[1] * 180.0 / M_PI, lonD, lonM, lonS);
165 QString country;
166 QListIterator<QString> it(settings.value("mountPoints").toStringList());
167 while (it.hasNext()) {
168 QStringList hlp = it.next().split(" ");
169 if (hlp.size() < 7)
170 continue;
171 if (hlp.join(" ").indexOf(QString::fromStdString(_opt->_roverName), 0) != -1) {
172 country = hlp[2];
173 }
174 }
175 _out << "+SITE/ID" << endl;
176 _out << "*STATION__ PT __DOMES__ T _STATION_DESCRIPTION__ _LONGITUDE _LATITUDE_ _HGT_ELI_" << endl;
177 _out << " " << _opt->_roverName.substr(0,9) << " A P "
178 << country.toStdString() << " "
179 << QString(" %1").arg(recEll[0]* 180.0 / M_PI,10, 'f', 6, QLatin1Char(' ')).toStdString()
180 << QString(" %1").arg(recEll[1]* 180.0 / M_PI,10, 'f', 6, QLatin1Char(' ')).toStdString()
181 << QString(" %1").arg(recEll[2], 9, 'f', 3, QLatin1Char(' ')).toStdString()
182 << endl;
183 _out << "-SITE/ID" << endl;
184 _out << "*-------------------------------------------------------------------------------" << endl;
185
186 _out << "+TROP/COORDINATES" << endl;
187 _out << "*SITE PT SOLN T STA_X_______ STA_Y_______ STA_Z_______ SYSTEM REMARK" << endl;
188 _out << " " << _opt->_roverName.substr(0,9) << " A "
189 << solId.toStdString() << " P"
190 << QString(" %1").arg(_opt->_xyzAprRover(1), 12, 'f', 3, QLatin1Char(' ')).toStdString()
191 << QString(" %1").arg(_opt->_xyzAprRover(2), 12, 'f', 3, QLatin1Char(' ')).toStdString()
192 << QString(" %1").arg(_opt->_xyzAprRover(3), 12, 'f', 3, QLatin1Char(' ')).toStdString()
193 << " IGS20 " << ac.toStdString() << endl;
194 _out << "-TROP/COORDINATES"<< endl;
195 _out << "*-------------------------------------------------------------------------------" << endl;
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,9) << " A "
202 << solId.toStdString() << " P "
203 << startTime.toStdString() << " " << endTime.toStdString() << " UNE"
204 << QString("%1").arg(_opt->_neuEccRover(3), 9, 'f', 4, QLatin1Char(' ')).toStdString()
205 << QString("%1").arg(_opt->_neuEccRover(1), 9, 'f', 4, QLatin1Char(' ')).toStdString()
206 << QString("%1").arg(_opt->_neuEccRover(2), 9, 'f', 4, QLatin1Char(' ')).toStdString() << endl;
207 _out << "-SITE/ECCENTRICITY" << endl;
208 _out << "*-------------------------------------------------------------------------------" << endl;
209
210 if (!_opt->_recNameRover.empty()) {
211 _out << "+SITE/RECEIVER" << endl;
212 _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ DESCRIPTION_________ S/N_________________ FIRMW______" << endl;
213 _out << " " << _opt->_roverName.substr(0,9) << " A " << solId.toStdString() << " P "
214 << startTime.toStdString() << " " << endTime.toStdString()
215 << QString(" %1").arg(_opt->_recNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
216 << " -----" << " -----------" << endl;
217 _out << "-SITE/RECEIVER" << endl;
218 _out << "*-------------------------------------------------------------------------------" << endl;
219 }
220
221 _out << "+SITE/ANTENNA" << endl;
222 _out << "*STATION__ PT SOLN T __DATA_START__ __DATA_END____ DESCRIPTION_________ S/N_________________ PCV_MODEL_" << endl;
223 _out << " " << _opt->_roverName.substr(0,9) << " A " << solId.toStdString() << " P "
224 << startTime.toStdString() << " " << endTime.toStdString() << " "
225 << _opt->_antNameRover << " -----" << endl;
226 _out << "-SITE/ANTENNA" << endl;
227 _out << "*-------------------------------------------------------------------------------" << endl;
228
229 if (!_opt->_antexFileName.empty()) {
230 _antex = new bncAntex(_opt->_antexFileName.c_str());
231 if (_opt->_LCsGPS.size()) {
232 _out << "+SITE/GPS_PHASE_CENTER" << endl;
233 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
234 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
235 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
236 << " -----";
237 for (int i = 0; i < frqStrList.size(); ++i) {
238 if (frqStrList.at(i).contains('G')) {//cout << frqStrList.at(i).toStdString() << endl;
239 _out << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::toInt(frqStrList.at(i).toStdString())).toStdString();
240 }
241 }
242 _out << " ---------" << endl;
243 _out << "-SITE/GPS_PHASE_CENTER" << endl;
244 _out << "*-------------------------------------------------------------------------------" << endl;
245 }
246 if (_opt->_LCsGLONASS.size()) {
247 _out << "+SITE/GLONASS_PHASE_CENTER" << endl;
248 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
249 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
250 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
251 << " -----";
252 for (int i = 0; i < frqStrList.size(); ++i) {
253 if (frqStrList.at(i).contains('R')) {//cout << frqStrList.at(i).toStdString() << endl;
254 _out << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::toInt(frqStrList.at(i).toStdString())).toStdString();
255 }
256 }
257 _out << " ---------" << endl;
258 _out << "-SITE/GLONASS_PHASE_CENTER" << endl;
259 _out << "*-------------------------------------------------------------------------------" << endl;
260 }
261 if (_opt->_LCsGalileo.size()) {
262 _out << "+SITE/GALILEO_PHASE_CENTER" << endl;
263 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
264 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
265 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
266 << " -----";
267 for (int i = 0; i < frqStrList.size(); ++i) {
268 if (frqStrList.at(i).contains('E')) {//cout << frqStrList.at(i).toStdString() << endl;
269 _out << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::toInt(frqStrList.at(i).toStdString())).toStdString();
270 }
271 }
272 _out << " ---------" << endl;
273 _out << "-SITE/GALILEO_PHASE_CENTER" << endl;
274 _out << "*-------------------------------------------------------------------------------" << endl;
275 }
276 if (_opt->_LCsBDS.size()) {
277 _out << "+SITE/BEIDOU_PHASE_CENTER" << endl;
278 _out << "* UP____ NORTH_ EAST__ UP____ NORTH_ EAST__" << endl;
279 _out << "*DESCRIPTION_________ S/N__ L1->ARP(m)__________ L2->ARP(m)__________ AZ_EL____" << endl;
280 _out << QString(" %1").arg(_opt->_antNameRover.c_str(), 20,QLatin1Char(' ')).toStdString()
281 << " -----";
282 for (int i = 0; i < frqStrList.size(); ++i) {
283 if (frqStrList.at(i).contains('C')) {//cout << frqStrList.at(i).toStdString() << endl;
284 _out << _antex->pcoSinexString(_opt->_antNameRover, t_frequency::toInt(frqStrList.at(i).toStdString())).toStdString();
285 }
286 }
287 _out << " ---------" << endl;
288 _out << "-SITE/BEIDOU_PHASE_CENTER" << endl;
289 _out << "*-------------------------------------------------------------------------------" << endl;
290 }
291 delete _antex;
292 _antex = 0;
293 }
294
295 _out << "+TROP/SOLUTION" << endl;
296 _out << "*STATION__ ____EPOCH_____ TROTOT STDDEV " << endl;
297}
298
299// Write One Epoch
300////////////////////////////////////////////////////////////////////////////
301t_irc bncSinexTro::write(QByteArray staID, int GPSWeek, double GPSWeeks,
302 double trotot, double stdev) {
303
304 QDateTime datTim = dateAndTimeFromGPSweek(GPSWeek, GPSWeeks);
305 int daysec = int(fmod(GPSWeeks, 86400.0));
306 int dayOfYear = datTim.date().dayOfYear();
307 QString yy = datTim.toString("yy");
308 QString time = QString("%1:%2:%3").arg(yy)
309 .arg(dayOfYear, 3, 10, QLatin1Char('0'))
310 .arg(daysec , 5, 10, QLatin1Char('0'));
311
312 if ((reopen(GPSWeek, GPSWeeks) == success) &&
313 (fmod(daysec, double(_sampl)) == 0.0)) {
314 _out << ' ' << staID.left(9).data() << ' ' << time.toStdString() << ' '
315 << noshowpos << setw(6) << setprecision(1) << trotot * 1000.0
316 << noshowpos << setw(6) << setprecision(1) << stdev * 1000.0 << endl;
317 _out.flush();
318 return success;
319 } else {
320 return failure;
321 }
322}
323
324// Close File (write last lines)
325////////////////////////////////////////////////////////////////////////////
326void bncSinexTro::closeFile() {
327 _out << "-TROP/SOLUTION" << endl;
328 _out << "%=ENDTROP" << endl;
329 bncoutf::closeFile();
330}
331
332
333
334
Note: See TracBrowser for help on using the repository browser.