1 | // Part of BNC, a utility for retrieving decoding and
|
---|
2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2007
|
---|
5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
6 | // http://www.bkg.bund.de
|
---|
7 | // Czech Technical University Prague, Department of Geodesy
|
---|
8 | // http://www.fsv.cvut.cz
|
---|
9 | //
|
---|
10 | // Email: euref-ip@bkg.bund.de
|
---|
11 | //
|
---|
12 | // This program is free software; you can redistribute it and/or
|
---|
13 | // modify it under the terms of the GNU General Public License
|
---|
14 | // as published by the Free Software Foundation, version 2.
|
---|
15 | //
|
---|
16 | // This program is distributed in the hope that it will be useful,
|
---|
17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | // GNU General Public License for more details.
|
---|
20 | //
|
---|
21 | // You should have received a copy of the GNU General Public License
|
---|
22 | // along with this program; if not, write to the Free Software
|
---|
23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
24 |
|
---|
25 | /* -------------------------------------------------------------------------
|
---|
26 | * BKG NTRIP Client
|
---|
27 | * -------------------------------------------------------------------------
|
---|
28 | *
|
---|
29 | * Class: bncRinex
|
---|
30 | *
|
---|
31 | * Purpose: writes RINEX files
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 27-Aug-2006
|
---|
36 | *
|
---|
37 | * Changes:
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include <stdlib.h>
|
---|
42 | #include <iostream>
|
---|
43 | #include <iomanip>
|
---|
44 | #include <math.h>
|
---|
45 | #include <sstream>
|
---|
46 |
|
---|
47 | #include <QtCore>
|
---|
48 | #include <QUrl>
|
---|
49 | #include <QString>
|
---|
50 |
|
---|
51 | #include "bncrinex.h"
|
---|
52 | #include "bncapp.h"
|
---|
53 | #include "bncutils.h"
|
---|
54 | #include "bncconst.h"
|
---|
55 | #include "bnctabledlg.h"
|
---|
56 | #include "bncgetthread.h"
|
---|
57 | #include "bncnetqueryv1.h"
|
---|
58 | #include "bncnetqueryv2.h"
|
---|
59 | #include "bncsettings.h"
|
---|
60 | #include "bncversion.h"
|
---|
61 | #include "rtcm3torinex.h"
|
---|
62 |
|
---|
63 | using namespace std;
|
---|
64 |
|
---|
65 | // Constructor
|
---|
66 | ////////////////////////////////////////////////////////////////////////////
|
---|
67 | bncRinex::bncRinex(const QByteArray& statID, const QUrl& mountPoint,
|
---|
68 | const QByteArray& latitude, const QByteArray& longitude,
|
---|
69 | const QByteArray& nmea, const QByteArray& ntripVersion) {
|
---|
70 |
|
---|
71 | _statID = statID;
|
---|
72 | _mountPoint = mountPoint;
|
---|
73 | _latitude = latitude;
|
---|
74 | _longitude = longitude;
|
---|
75 | _nmea = nmea;
|
---|
76 | _ntripVersion = ntripVersion;
|
---|
77 | _headerWritten = false;
|
---|
78 | _reconnectFlag = false;
|
---|
79 |
|
---|
80 | bncSettings settings;
|
---|
81 | _rnxScriptName = settings.value("rnxScript").toString();
|
---|
82 | expandEnvVar(_rnxScriptName);
|
---|
83 |
|
---|
84 | _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
|
---|
85 | #ifdef WIN32
|
---|
86 | _userName = QString("${USERNAME}");
|
---|
87 | #else
|
---|
88 | _userName = QString("${USER}");
|
---|
89 | #endif
|
---|
90 | expandEnvVar(_userName);
|
---|
91 | _userName = _userName.leftJustified(20, ' ', true);
|
---|
92 |
|
---|
93 | _samplingRate = settings.value("rnxSampl").toInt();
|
---|
94 |
|
---|
95 | // Initialize RINEX v3 Types
|
---|
96 | // -------------------------
|
---|
97 | _header._obsTypesV3['G'] << "C1C" << "L1C" << "D1C" << "S1C"
|
---|
98 | << "C1P" << "L1P" << "D1P" << "S1P"
|
---|
99 | << "C2C" << "L2C" << "D2C" << "S2C"
|
---|
100 | << "C2P" << "L2P" << "D2P" << "S2P"
|
---|
101 | << "C5" << "D5" << "L5" << "S5";
|
---|
102 |
|
---|
103 | _header._obsTypesV3['R'] << "C1C" << "L1C" << "D1C" << "S1C"
|
---|
104 | << "C1P" << "L1P" << "D1P" << "S1P"
|
---|
105 | << "C2C" << "L2C" << "D2C" << "S2C"
|
---|
106 | << "C2P" << "L2P" << "D2P" << "S2P";
|
---|
107 |
|
---|
108 | _header._obsTypesV3['E'] << "C1" << "L1" << "D1" << "S1"
|
---|
109 | << "C5" << "L5" << "D5" << "S5"
|
---|
110 | << "C6" << "L6" << "D6" << "S6"
|
---|
111 | << "C7" << "L7" << "D7" << "S7"
|
---|
112 | << "C8" << "L8" << "D8" << "S8";
|
---|
113 |
|
---|
114 | _header._obsTypesV3['J'] << "C1" << "L1" << "D1" << "S1"
|
---|
115 | << "C2" << "L2" << "D2" << "S2"
|
---|
116 | << "C5" << "L5" << "D5" << "S5"
|
---|
117 | << "C6" << "D6" << "L6" << "S6";
|
---|
118 |
|
---|
119 | _header._obsTypesV3['S'] << "C1" << "L1" << "D1" << "S1"
|
---|
120 | << "C5" << "L5" << "D5" << "S5";
|
---|
121 |
|
---|
122 | _header._obsTypesV3['C'] << "C2" << "L2" << "D2" << "S2"
|
---|
123 | << "C6" << "L6" << "D6" << "S6"
|
---|
124 | << "C7" << "L7" << "D7" << "S7";
|
---|
125 | }
|
---|
126 |
|
---|
127 | // Destructor
|
---|
128 | ////////////////////////////////////////////////////////////////////////////
|
---|
129 | bncRinex::~bncRinex() {
|
---|
130 | bncSettings settings;
|
---|
131 | if ((_header._version >= 3.0) && ( Qt::CheckState(settings.value("rnxAppend").toInt()) != Qt::Checked) ) {
|
---|
132 | _out << "> 4 1" << endl;
|
---|
133 | _out << "END OF FILE" << endl;
|
---|
134 | }
|
---|
135 | _out.close();
|
---|
136 | }
|
---|
137 |
|
---|
138 | // Download Skeleton Header File
|
---|
139 | ////////////////////////////////////////////////////////////////////////////
|
---|
140 | t_irc bncRinex::downloadSkeleton() {
|
---|
141 |
|
---|
142 | t_irc irc = failure;
|
---|
143 |
|
---|
144 | QStringList table;
|
---|
145 | bncTableDlg::getFullTable(_ntripVersion, _mountPoint.host(),
|
---|
146 | _mountPoint.port(), table, true);
|
---|
147 | QString net;
|
---|
148 | QStringListIterator it(table);
|
---|
149 | while (it.hasNext()) {
|
---|
150 | QString line = it.next();
|
---|
151 | if (line.indexOf("STR") == 0) {
|
---|
152 | QStringList tags = line.split(";");
|
---|
153 | if (tags.size() > 7) {
|
---|
154 | if (tags.at(1) == _mountPoint.path().mid(1).toAscii()) {
|
---|
155 | net = tags.at(7);
|
---|
156 | break;
|
---|
157 | }
|
---|
158 | }
|
---|
159 | }
|
---|
160 | }
|
---|
161 | QString sklDir;
|
---|
162 | if (!net.isEmpty()) {
|
---|
163 | it.toFront();
|
---|
164 | while (it.hasNext()) {
|
---|
165 | QString line = it.next();
|
---|
166 | if (line.indexOf("NET") == 0) {
|
---|
167 | QStringList tags = line.split(";");
|
---|
168 | if (tags.size() > 6) {
|
---|
169 | if (tags.at(1) == net) {
|
---|
170 | sklDir = tags.at(6).trimmed();
|
---|
171 | break;
|
---|
172 | }
|
---|
173 | }
|
---|
174 | }
|
---|
175 | }
|
---|
176 | }
|
---|
177 | if (!sklDir.isEmpty() && sklDir != "none") {
|
---|
178 | QUrl url(sklDir + "/" + _mountPoint.path().mid(1,4).toLower() + ".skl");
|
---|
179 | if (url.port() == -1) {
|
---|
180 | url.setPort(80);
|
---|
181 | }
|
---|
182 |
|
---|
183 | bncNetQuery* query;
|
---|
184 | if (_ntripVersion == "2s") {
|
---|
185 | query = new bncNetQueryV2(true);
|
---|
186 | }
|
---|
187 | else if (_ntripVersion == "2") {
|
---|
188 | query = new bncNetQueryV2(false);
|
---|
189 | }
|
---|
190 | else {
|
---|
191 | query = new bncNetQueryV1;
|
---|
192 | }
|
---|
193 |
|
---|
194 | QByteArray outData;
|
---|
195 | query->waitForRequestResult(url, outData);
|
---|
196 | if (query->status() == bncNetQuery::finished) {
|
---|
197 | irc = success;
|
---|
198 | QTextStream in(outData);
|
---|
199 | _header.read(&in);
|
---|
200 | }
|
---|
201 |
|
---|
202 | delete query;
|
---|
203 | }
|
---|
204 |
|
---|
205 | return irc;
|
---|
206 | }
|
---|
207 |
|
---|
208 | // Read Skeleton Header File
|
---|
209 | ////////////////////////////////////////////////////////////////////////////
|
---|
210 | void bncRinex::readSkeleton() {
|
---|
211 |
|
---|
212 | // Read the local file
|
---|
213 | // -------------------
|
---|
214 | QFile skl(_sklName);
|
---|
215 | if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) {
|
---|
216 | QTextStream in(&skl);
|
---|
217 | _header.read(&in);
|
---|
218 | }
|
---|
219 |
|
---|
220 | // Read downloaded file
|
---|
221 | // --------------------
|
---|
222 | else if ( _ntripVersion != "N" && _ntripVersion != "UN" &&
|
---|
223 | _ntripVersion != "S" ) {
|
---|
224 | QDate currDate = currentDateAndTimeGPS().date();
|
---|
225 | if ( !_skeletonDate.isValid() || _skeletonDate != currDate ) {
|
---|
226 | downloadSkeleton();
|
---|
227 | _skeletonDate = currDate;
|
---|
228 | }
|
---|
229 | }
|
---|
230 |
|
---|
231 | bncSettings settings;
|
---|
232 | if ( Qt::CheckState(settings.value("rnxV3").toInt()) == Qt::Checked) {
|
---|
233 | _header._version = 3.01;
|
---|
234 | }
|
---|
235 | else {
|
---|
236 | _header._version = 2.12;
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 | // Next File Epoch (static)
|
---|
241 | ////////////////////////////////////////////////////////////////////////////
|
---|
242 | QString bncRinex::nextEpochStr(const QDateTime& datTim,
|
---|
243 | const QString& intStr, QDateTime* nextEpoch) {
|
---|
244 |
|
---|
245 | QString epoStr;
|
---|
246 |
|
---|
247 | QTime nextTime;
|
---|
248 | QDate nextDate;
|
---|
249 |
|
---|
250 | int indHlp = intStr.indexOf("min");
|
---|
251 |
|
---|
252 | if ( indHlp != -1) {
|
---|
253 | int step = intStr.left(indHlp-1).toInt();
|
---|
254 | char ch = 'A' + datTim.time().hour();
|
---|
255 | epoStr = ch;
|
---|
256 | if (datTim.time().minute() >= 60-step) {
|
---|
257 | epoStr += QString("%1").arg(60-step, 2, 10, QChar('0'));
|
---|
258 | if (datTim.time().hour() < 23) {
|
---|
259 | nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
|
---|
260 | nextDate = datTim.date();
|
---|
261 | }
|
---|
262 | else {
|
---|
263 | nextTime.setHMS(0, 0, 0);
|
---|
264 | nextDate = datTim.date().addDays(1);
|
---|
265 | }
|
---|
266 | }
|
---|
267 | else {
|
---|
268 | for (int limit = step; limit <= 60-step; limit += step) {
|
---|
269 | if (datTim.time().minute() < limit) {
|
---|
270 | epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));
|
---|
271 | nextTime.setHMS(datTim.time().hour(), limit, 0);
|
---|
272 | nextDate = datTim.date();
|
---|
273 | break;
|
---|
274 | }
|
---|
275 | }
|
---|
276 | }
|
---|
277 | }
|
---|
278 | else if (intStr == "1 hour") {
|
---|
279 | char ch = 'A' + datTim.time().hour();
|
---|
280 | epoStr = ch;
|
---|
281 | if (datTim.time().hour() < 23) {
|
---|
282 | nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
|
---|
283 | nextDate = datTim.date();
|
---|
284 | }
|
---|
285 | else {
|
---|
286 | nextTime.setHMS(0, 0, 0);
|
---|
287 | nextDate = datTim.date().addDays(1);
|
---|
288 | }
|
---|
289 | }
|
---|
290 | else {
|
---|
291 | epoStr = "0";
|
---|
292 | nextTime.setHMS(0, 0, 0);
|
---|
293 | nextDate = datTim.date().addDays(1);
|
---|
294 | }
|
---|
295 |
|
---|
296 | if (nextEpoch) {
|
---|
297 | *nextEpoch = QDateTime(nextDate, nextTime);
|
---|
298 | }
|
---|
299 |
|
---|
300 | return epoStr;
|
---|
301 | }
|
---|
302 |
|
---|
303 | // File Name according to RINEX Standards
|
---|
304 | ////////////////////////////////////////////////////////////////////////////
|
---|
305 | void bncRinex::resolveFileName(const QDateTime& datTim) {
|
---|
306 |
|
---|
307 | bncSettings settings;
|
---|
308 | QString path = settings.value("rnxPath").toString();
|
---|
309 | expandEnvVar(path);
|
---|
310 |
|
---|
311 | if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
|
---|
312 | path += QDir::separator();
|
---|
313 | }
|
---|
314 |
|
---|
315 | QString hlpStr = nextEpochStr(datTim, settings.value("rnxIntr").toString(),
|
---|
316 | &_nextCloseEpoch);
|
---|
317 |
|
---|
318 | QString ID4 = _statID.left(4);
|
---|
319 |
|
---|
320 | // Check name conflict
|
---|
321 | // -------------------
|
---|
322 | QString distStr;
|
---|
323 | int num = 0;
|
---|
324 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
325 | while (it.hasNext()) {
|
---|
326 | QString mp = it.next();
|
---|
327 | if (mp.indexOf(ID4) != -1) {
|
---|
328 | ++num;
|
---|
329 | }
|
---|
330 | }
|
---|
331 | if (num > 1) {
|
---|
332 | distStr = "_" + _statID.mid(4);
|
---|
333 | }
|
---|
334 |
|
---|
335 | QString sklExt = settings.value("rnxSkel").toString();
|
---|
336 | if (!sklExt.isEmpty()) {
|
---|
337 | _sklName = path + ID4 + distStr + "." + sklExt;
|
---|
338 | }
|
---|
339 |
|
---|
340 | path += ID4 +
|
---|
341 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
|
---|
342 | hlpStr + distStr + datTim.toString(".yyO");
|
---|
343 |
|
---|
344 | _fName = path.toAscii();
|
---|
345 | }
|
---|
346 |
|
---|
347 | // Write RINEX Header
|
---|
348 | ////////////////////////////////////////////////////////////////////////////
|
---|
349 | void bncRinex::writeHeader(const QByteArray& format, const QDateTime& datTim,
|
---|
350 | const QDateTime& datTimNom) {
|
---|
351 |
|
---|
352 | bncSettings settings;
|
---|
353 |
|
---|
354 | // Open the Output File
|
---|
355 | // --------------------
|
---|
356 | resolveFileName(datTimNom);
|
---|
357 |
|
---|
358 | // Append to existing file and return
|
---|
359 | // ----------------------------------
|
---|
360 | if ( QFile::exists(_fName) ) {
|
---|
361 | if (_reconnectFlag ||
|
---|
362 | Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
363 | _out.open(_fName.data(), ios::app);
|
---|
364 | _out.setf(ios::showpoint | ios::fixed);
|
---|
365 | _headerWritten = true;
|
---|
366 | _reconnectFlag = false;
|
---|
367 | return;
|
---|
368 | }
|
---|
369 | }
|
---|
370 |
|
---|
371 | _out.open(_fName.data());
|
---|
372 | _out.setf(ios::showpoint | ios::fixed);
|
---|
373 |
|
---|
374 | // Copy Skeleton Header
|
---|
375 | // --------------------
|
---|
376 | readSkeleton();
|
---|
377 |
|
---|
378 | QByteArray headerLines;
|
---|
379 | QTextStream outHlp(&headerLines);
|
---|
380 | _header.write(&outHlp);
|
---|
381 | outHlp.flush();
|
---|
382 | _out << headerLines.data();
|
---|
383 |
|
---|
384 | _headerWritten = true;
|
---|
385 | }
|
---|
386 |
|
---|
387 | // Stores Observation into Internal Array
|
---|
388 | ////////////////////////////////////////////////////////////////////////////
|
---|
389 | void bncRinex::deepCopy(t_obs obs) {
|
---|
390 | _obs.push_back(obs);
|
---|
391 | }
|
---|
392 |
|
---|
393 | // Write One Epoch into the RINEX File
|
---|
394 | ////////////////////////////////////////////////////////////////////////////
|
---|
395 | void bncRinex::dumpEpoch(const QByteArray& format, long maxTime) {
|
---|
396 |
|
---|
397 | // Select observations older than maxTime
|
---|
398 | // --------------------------------------
|
---|
399 | QList<t_obs> dumpList;
|
---|
400 | QMutableListIterator<t_obs> mIt(_obs);
|
---|
401 | while (mIt.hasNext()) {
|
---|
402 | t_obs obs = mIt.next();
|
---|
403 | if (obs.GPSWeek * 7*24*3600 + obs.GPSWeeks < maxTime - 0.05) {
|
---|
404 | dumpList.push_back(obs);
|
---|
405 | mIt.remove();
|
---|
406 | }
|
---|
407 | }
|
---|
408 |
|
---|
409 | // Easy Return
|
---|
410 | // -----------
|
---|
411 | if (dumpList.isEmpty()) {
|
---|
412 | return;
|
---|
413 | }
|
---|
414 |
|
---|
415 | // Time of Epoch
|
---|
416 | // -------------
|
---|
417 | const t_obs& fObs = dumpList.first();
|
---|
418 | QDateTime datTim = dateAndTimeFromGPSweek(fObs.GPSWeek, fObs.GPSWeeks);
|
---|
419 | QDateTime datTimNom = dateAndTimeFromGPSweek(fObs.GPSWeek,
|
---|
420 | floor(fObs.GPSWeeks+0.5));
|
---|
421 |
|
---|
422 | // Close the file
|
---|
423 | // --------------
|
---|
424 | if (_nextCloseEpoch.isValid() && datTimNom >= _nextCloseEpoch) {
|
---|
425 | closeFile();
|
---|
426 | _headerWritten = false;
|
---|
427 | }
|
---|
428 |
|
---|
429 | // Write RINEX Header
|
---|
430 | // ------------------
|
---|
431 | if (!_headerWritten) {
|
---|
432 | writeHeader(format, datTim, datTimNom);
|
---|
433 | }
|
---|
434 |
|
---|
435 | double sec = double(datTim.time().second()) + fmod(fObs.GPSWeeks,1.0);
|
---|
436 |
|
---|
437 | // Epoch header line: RINEX Version 3
|
---|
438 | // ----------------------------------
|
---|
439 | if (_header._version >= 3.0) {
|
---|
440 | _out << datTim.toString("> yyyy MM dd hh mm ").toAscii().data()
|
---|
441 | << setw(10) << setprecision(7) << sec
|
---|
442 | << " " << 0 << setw(3) << dumpList.size() << endl;
|
---|
443 | }
|
---|
444 | // Epoch header line: RINEX Version 2
|
---|
445 | // ----------------------------------
|
---|
446 | else {
|
---|
447 | _out << datTim.toString(" yy MM dd hh mm ").toAscii().data()
|
---|
448 | << setw(10) << setprecision(7) << sec
|
---|
449 | << " " << 0 << setw(3) << dumpList.size();
|
---|
450 |
|
---|
451 | QListIterator<t_obs> it(dumpList); int iSat = 0;
|
---|
452 | while (it.hasNext()) {
|
---|
453 | iSat++;
|
---|
454 | const t_obs& obs = it.next();
|
---|
455 | _out << obs.satSys << setw(2) << obs.satNum;
|
---|
456 | if (iSat == 12 && it.hasNext()) {
|
---|
457 | _out << endl << " ";
|
---|
458 | iSat = 0;
|
---|
459 | }
|
---|
460 | }
|
---|
461 | _out << endl;
|
---|
462 | }
|
---|
463 |
|
---|
464 | QListIterator<t_obs> it(dumpList);
|
---|
465 | while (it.hasNext()) {
|
---|
466 | const t_obs& obs = it.next();
|
---|
467 |
|
---|
468 | // Cycle slips detection
|
---|
469 | // ---------------------
|
---|
470 | QString prn = QString("%1%2").arg(obs.satSys)
|
---|
471 | .arg(obs.satNum, 2, 10, QChar('0'));
|
---|
472 |
|
---|
473 | char lli1 = ' ';
|
---|
474 | char lli2 = ' ';
|
---|
475 | char lli5 = ' ';
|
---|
476 | if ( obs.slip_cnt_L1 >= 0 ) {
|
---|
477 | if ( _slip_cnt_L1.find(prn) != _slip_cnt_L1.end() &&
|
---|
478 | _slip_cnt_L1.find(prn).value() != obs.slip_cnt_L1 ) {
|
---|
479 | lli1 = '1';
|
---|
480 | }
|
---|
481 | }
|
---|
482 |
|
---|
483 | if ( obs.slip_cnt_L2 >= 0 ) {
|
---|
484 | if ( _slip_cnt_L2.find(prn) != _slip_cnt_L2.end() &&
|
---|
485 | _slip_cnt_L2.find(prn).value() != obs.slip_cnt_L2 ) {
|
---|
486 | lli2 = '1';
|
---|
487 | }
|
---|
488 | }
|
---|
489 |
|
---|
490 | if ( obs.slip_cnt_L5 >= 0 ) {
|
---|
491 | if ( _slip_cnt_L5.find(prn) != _slip_cnt_L5.end() &&
|
---|
492 | _slip_cnt_L5.find(prn).value() != obs.slip_cnt_L5 ) {
|
---|
493 | lli5 = '1';
|
---|
494 | }
|
---|
495 | }
|
---|
496 |
|
---|
497 | _slip_cnt_L1[prn] = obs.slip_cnt_L1;
|
---|
498 | _slip_cnt_L2[prn] = obs.slip_cnt_L2;
|
---|
499 | _slip_cnt_L5[prn] = obs.slip_cnt_L5;
|
---|
500 |
|
---|
501 | // RINEX Version 3
|
---|
502 | // ---------------
|
---|
503 | if (_header._version >= 3.0) {
|
---|
504 | _out << rinexSatLine(obs, lli1, lli2, lli5);
|
---|
505 | _out << endl;
|
---|
506 | }
|
---|
507 |
|
---|
508 | // RINEX Version 2
|
---|
509 | // ---------------
|
---|
510 | else {
|
---|
511 | _out << setw(14) << setprecision(3) << obs.measdata("C1", _header._version) << ' ' << ' '
|
---|
512 | << setw(14) << setprecision(3) << obs.measdata("P1", _header._version) << ' ' << ' '
|
---|
513 | << setw(14) << setprecision(3) << obs.measdata("L1", _header._version) << lli1 << ' '
|
---|
514 | << setw(14) << setprecision(3) << obs.measdata("S1", _header._version) << ' ' << ' '
|
---|
515 | << setw(14) << setprecision(3) << obs.measdata("C2", _header._version) << ' ' << ' ' << endl
|
---|
516 | << setw(14) << setprecision(3) << obs.measdata("P2", _header._version) << ' ' << ' '
|
---|
517 | << setw(14) << setprecision(3) << obs.measdata("L2", _header._version) << lli2 << ' '
|
---|
518 | << setw(14) << setprecision(3) << obs.measdata("S2", _header._version) << endl;
|
---|
519 | }
|
---|
520 | }
|
---|
521 |
|
---|
522 | _out.flush();
|
---|
523 | }
|
---|
524 |
|
---|
525 | // Close the Old RINEX File
|
---|
526 | ////////////////////////////////////////////////////////////////////////////
|
---|
527 | void bncRinex::closeFile() {
|
---|
528 | if (_header._version == 3) {
|
---|
529 | _out << "> 4 1" << endl;
|
---|
530 | _out << "END OF FILE" << endl;
|
---|
531 | }
|
---|
532 | _out.close();
|
---|
533 | if (!_rnxScriptName.isEmpty()) {
|
---|
534 | qApp->thread()->wait(100);
|
---|
535 | #ifdef WIN32
|
---|
536 | QProcess::startDetached(_rnxScriptName, QStringList() << _fName) ;
|
---|
537 | #else
|
---|
538 | QProcess::startDetached("nohup", QStringList() << _rnxScriptName << _fName) ;
|
---|
539 | #endif
|
---|
540 |
|
---|
541 | }
|
---|
542 | }
|
---|
543 |
|
---|
544 | // One Line in RINEX v3
|
---|
545 | ////////////////////////////////////////////////////////////////////////////
|
---|
546 | string bncRinex::rinexSatLine(const t_obs& obs, char lli1, char lli2,
|
---|
547 | char lli5) {
|
---|
548 | ostringstream str;
|
---|
549 | str.setf(ios::showpoint | ios::fixed);
|
---|
550 |
|
---|
551 | str << obs.satSys
|
---|
552 | << setw(2) << setfill('0') << obs.satNum << setfill(' ');
|
---|
553 |
|
---|
554 | const QVector<QString>& types = _header._obsTypesV3[obs.satSys];
|
---|
555 | for (int ii = 0; ii < types.size(); ii++) {
|
---|
556 | double value = obs.measdata(types[ii], _header._version);
|
---|
557 | str << setw(14) << setprecision(3) << value;
|
---|
558 | if (value != 0.0 && types[ii].indexOf("L1") == 0) {
|
---|
559 | str << lli1 << ' ';
|
---|
560 | }
|
---|
561 | else if (value != 0.0 && types[ii].indexOf("L2") == 0) {
|
---|
562 | str << lli2 << ' ';
|
---|
563 | }
|
---|
564 | else if (value != 0.0 && types[ii].indexOf("L5") == 0) {
|
---|
565 | str << lli5 << ' ';
|
---|
566 | }
|
---|
567 | else {
|
---|
568 | str << " ";
|
---|
569 | }
|
---|
570 | }
|
---|
571 |
|
---|
572 | return str.str();
|
---|
573 | }
|
---|
574 |
|
---|
575 | //
|
---|
576 | ////////////////////////////////////////////////////////////////////////////
|
---|
577 | string bncRinex::obsToStr(double val, int width, int precision) {
|
---|
578 | if (val != 0.0) {
|
---|
579 | ostringstream str;
|
---|
580 | str.setf(ios::showpoint | ios::fixed);
|
---|
581 | str << setw(width) << setprecision(precision) << val;
|
---|
582 | return str.str();
|
---|
583 | }
|
---|
584 | else {
|
---|
585 | return "0.0";
|
---|
586 | }
|
---|
587 | }
|
---|
588 |
|
---|
589 | // One Line in ASCII (Internal) Format
|
---|
590 | ////////////////////////////////////////////////////////////////////////////
|
---|
591 | string bncRinex::asciiSatLine(const t_obs& obs) {
|
---|
592 |
|
---|
593 | ostringstream str;
|
---|
594 | str.setf(ios::showpoint | ios::fixed);
|
---|
595 |
|
---|
596 | str << obs.satSys << setw(2) << setfill('0') << obs.satNum << setfill(' ');
|
---|
597 |
|
---|
598 | if (obs.satSys == 'R') { // Glonass
|
---|
599 | str << ' ' << setw(2) << obs.slotNum;
|
---|
600 | }
|
---|
601 | else {
|
---|
602 | str << " ";
|
---|
603 | }
|
---|
604 |
|
---|
605 | float rnxVers = 3.0;
|
---|
606 |
|
---|
607 | if (obs.satSys == 'G') { // GPS
|
---|
608 | str << " 1C "
|
---|
609 | << obsToStr(obs.measdata("C1C", rnxVers)) << ' '
|
---|
610 | << obsToStr(obs.measdata("L1C", rnxVers)) << ' '
|
---|
611 | << obsToStr(obs.measdata("D1C", rnxVers)) << ' '
|
---|
612 | << obsToStr(obs.measdata("S1C", rnxVers), 8, 3) << ' '
|
---|
613 | << setw(2) << obs.slip_cnt_L1;
|
---|
614 | str << " 1P "
|
---|
615 | << obsToStr(obs.measdata("C1P", rnxVers)) << ' '
|
---|
616 | << obsToStr(obs.measdata("L1P", rnxVers)) << ' '
|
---|
617 | << obsToStr(obs.measdata("D1P", rnxVers)) << ' '
|
---|
618 | << obsToStr(obs.measdata("S1P", rnxVers), 8, 3) << ' '
|
---|
619 | << setw(2) << obs.slip_cnt_L1;
|
---|
620 | str << " 2P "
|
---|
621 | << obsToStr(obs.measdata("C2P", rnxVers)) << ' '
|
---|
622 | << obsToStr(obs.measdata("L2P", rnxVers)) << ' '
|
---|
623 | << obsToStr(obs.measdata("D2P", rnxVers)) << ' '
|
---|
624 | << obsToStr(obs.measdata("S2P", rnxVers), 8, 3) << ' '
|
---|
625 | << setw(2) << obs.slip_cnt_L2;
|
---|
626 | str << " 5C "
|
---|
627 | << obsToStr(obs.measdata("C5", rnxVers)) << ' '
|
---|
628 | << obsToStr(obs.measdata("L5", rnxVers)) << ' '
|
---|
629 | << obsToStr(obs.measdata("D5", rnxVers)) << ' '
|
---|
630 | << obsToStr(obs.measdata("S5", rnxVers), 8, 3) << ' '
|
---|
631 | << setw(2) << obs.slip_cnt_L5;
|
---|
632 | }
|
---|
633 | else if (obs.satSys == 'R') { // Glonass
|
---|
634 | str << " 1C "
|
---|
635 | << obsToStr(obs.measdata("C1C", rnxVers)) << ' '
|
---|
636 | << obsToStr(obs.measdata("L1C", rnxVers)) << ' '
|
---|
637 | << obsToStr(obs.measdata("D1C", rnxVers)) << ' '
|
---|
638 | << obsToStr(obs.measdata("S1C", rnxVers), 8, 3) << ' '
|
---|
639 | << setw(2) << obs.slip_cnt_L1;
|
---|
640 | str << " 1P "
|
---|
641 | << obsToStr(obs.measdata("C1P", rnxVers)) << ' '
|
---|
642 | << obsToStr(obs.measdata("L1P", rnxVers)) << ' '
|
---|
643 | << obsToStr(obs.measdata("D1P", rnxVers)) << ' '
|
---|
644 | << obsToStr(obs.measdata("S1P", rnxVers), 8, 3) << ' '
|
---|
645 | << setw(2) << obs.slip_cnt_L1;
|
---|
646 | str << " 2P "
|
---|
647 | << obsToStr(obs.measdata("C2P", rnxVers)) << ' '
|
---|
648 | << obsToStr(obs.measdata("L2P", rnxVers)) << ' '
|
---|
649 | << obsToStr(obs.measdata("D2P", rnxVers)) << ' '
|
---|
650 | << obsToStr(obs.measdata("S2P", rnxVers), 8, 3) << ' '
|
---|
651 | << setw(2) << obs.slip_cnt_L2;
|
---|
652 | str << " 2C "
|
---|
653 | << obsToStr(obs.measdata("C2C", rnxVers)) << ' '
|
---|
654 | << obsToStr(obs.measdata("L2C", rnxVers)) << ' '
|
---|
655 | << obsToStr(obs.measdata("D2C", rnxVers)) << ' '
|
---|
656 | << obsToStr(obs.measdata("S2C", rnxVers), 8, 3) << ' '
|
---|
657 | << setw(2) << obs.slip_cnt_L2;
|
---|
658 | }
|
---|
659 | else if (obs.satSys == 'E') { // Galileo
|
---|
660 | str << " 1C "
|
---|
661 | << obsToStr(obs.measdata("C1", rnxVers)) << ' '
|
---|
662 | << obsToStr(obs.measdata("L1", rnxVers)) << ' '
|
---|
663 | << obsToStr(obs.measdata("D1", rnxVers)) << ' '
|
---|
664 | << obsToStr(obs.measdata("S1", rnxVers), 8, 3) << ' '
|
---|
665 | << setw(2) << obs.slip_cnt_L1;
|
---|
666 |
|
---|
667 | str << " 5C "
|
---|
668 | << obsToStr(obs.measdata("C5", rnxVers)) << ' '
|
---|
669 | << obsToStr(obs.measdata("L5", rnxVers)) << ' '
|
---|
670 | << obsToStr(obs.measdata("D5", rnxVers)) << ' '
|
---|
671 | << obsToStr(obs.measdata("S5", rnxVers), 8, 3) << ' '
|
---|
672 | << setw(2) << obs.slip_cnt_L5;
|
---|
673 | }
|
---|
674 | return str.str();
|
---|
675 | }
|
---|