source: ntrip/trunk/BNC/bncrinex.cpp@ 2710

Last change on this file since 2710 was 2710, checked in by mervart, 13 years ago
File size: 26.0 KB
Line 
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 "bncnetqueryv2.h"
58#include "bncsettings.h"
59#include "bncversion.h"
60#include "rtcm3torinex.h"
61
62using namespace std;
63
64// Constructor
65////////////////////////////////////////////////////////////////////////////
66bncRinex::bncRinex(const QByteArray& statID, const QUrl& mountPoint,
67 const QByteArray& format, const QByteArray& latitude,
68 const QByteArray& longitude, const QByteArray& nmea,
69 const QByteArray& ntripVersion) {
70
71 _statID = statID;
72 _mountPoint = mountPoint;
73 _format = format.left(6);
74 _latitude = latitude;
75 _longitude = longitude;
76 _nmea = nmea;
77 _ntripVersion = ntripVersion;
78 _headerWritten = false;
79 _reconnectFlag = false;
80 _reloadTable = false;
81 _reloadDone = false;
82
83 bncSettings settings;
84 _rnxScriptName = settings.value("rnxScript").toString();
85 expandEnvVar(_rnxScriptName);
86
87 _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
88#ifdef WIN32
89 _userName = QString("${USERNAME}");
90#else
91 _userName = QString("${USER}");
92#endif
93 expandEnvVar(_userName);
94 _userName = _userName.leftJustified(20, ' ', true);
95
96 if ( Qt::CheckState(settings.value("rnxV3").toInt()) == Qt::Checked) {
97 _rinexVers = 3;
98 }
99 else {
100 _rinexVers = 2;
101 }
102
103 _approxPos[0] = _approxPos[1] = _approxPos[2] = 0.0;
104}
105
106// Destructor
107////////////////////////////////////////////////////////////////////////////
108bncRinex::~bncRinex() {
109 QListIterator<t_obs*> it(_obs);
110 while (it.hasNext()) {
111 delete it.next();
112 }
113 bncSettings settings;
114 if ((_rinexVers == 3) && ( Qt::CheckState(settings.value("rnxAppend").toInt()) != Qt::Checked) ) {
115 _out << "> 4 1" << endl;
116 _out << "END OF FILE" << endl;
117 }
118 _out.close();
119}
120
121// Download Skeleton Header File
122////////////////////////////////////////////////////////////////////////////
123t_irc bncRinex::downloadSkeleton() {
124
125 t_irc irc = failure;
126
127 QStringList table;
128 bncTableDlg::getFullTable(_mountPoint.host(), _mountPoint.port(),
129 table, _reloadTable);
130 QString net;
131 QStringListIterator it(table);
132 while (it.hasNext()) {
133 QString line = it.next();
134 if (line.indexOf("STR") == 0) {
135 QStringList tags = line.split(";");
136 if (tags.size() > 7) {
137 if (tags.at(1) == _mountPoint.path().mid(1).toAscii()) {
138 net = tags.at(7);
139 break;
140 }
141 }
142 }
143 }
144 QString sklDir;
145 if (!net.isEmpty()) {
146 it.toFront();
147 while (it.hasNext()) {
148 QString line = it.next();
149 if (line.indexOf("NET") == 0) {
150 QStringList tags = line.split(";");
151 if (tags.size() > 6) {
152 if (tags.at(1) == net) {
153 sklDir = tags.at(6).trimmed();
154 break;
155 }
156 }
157 }
158 }
159 }
160 if (!sklDir.isEmpty() && sklDir != "none") {
161 QUrl url(sklDir + "/" + _mountPoint.path().mid(1,4).toLower() + ".skl");
162 if (url.port() == -1) {
163 url.setPort(80);
164 }
165
166 bncNetQueryV2 query;
167 QByteArray outData;
168 query.waitForRequestResult(url, outData);
169 if (query.status() == bncNetQuery::finished) {
170 _headerLines.clear();
171 bool firstLineRead = false;
172 QTextStream in(outData);
173 QString line = in.readLine();
174 while ( !line.isNull() ) {
175 if (line.indexOf("MARKER NAME") != -1) {
176 irc = success;
177 }
178 if (line.indexOf("RINEX VERSION") != -1) {
179 if (_rinexVers == 3) {
180 _headerLines.append(" 3.00 OBSERVATION DATA"
181 " M (MIXED)"
182 " RINEX VERSION / TYPE");
183 }
184 else {
185 _headerLines.append(" 2.11 OBSERVATION DATA"
186 " M (MIXED)"
187 " RINEX VERSION / TYPE");
188 }
189 _headerLines.append("PGM / RUN BY / DATE");
190 firstLineRead = true;
191 }
192 else if (firstLineRead) {
193 if (line.indexOf("END OF HEADER") != -1) {
194 _headerLines.append("# / TYPES OF OBSERV");
195 if (_rinexVers == 2) {
196 _headerLines.append(
197 QString(" 1 1").leftJustified(60, ' ', true) +
198 "WAVELENGTH FACT L1/2");
199 }
200 _headerLines.append("TIME OF FIRST OBS");
201 _headerLines.append( line );
202 break;
203 }
204 else {
205 _headerLines.append( line );
206 }
207 }
208 line = in.readLine();
209 }
210 }
211 else {
212 return failure;
213 }
214
215 }
216 return irc;
217}
218
219// Read Skeleton Header File
220////////////////////////////////////////////////////////////////////////////
221void bncRinex::readSkeleton() {
222
223 // Read the local file
224 // -------------------
225 QFile skl(_sklName);
226 if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) {
227 _headerLines.clear();
228 QTextStream in(&skl);
229 while ( !in.atEnd() ) {
230 _headerLines.append( in.readLine() );
231 if (_headerLines.last().indexOf("END OF HEADER") != -1) {
232 break;
233 }
234 }
235 }
236
237 // Read downloaded file
238 // --------------------
239 else if ( _ntripVersion != "N" && _ntripVersion != "UN" &&
240 _ntripVersion != "S" ) {
241 QDate currDate = currentDateAndTimeGPS().date();
242 if ( !_skeletonDate.isValid() || _skeletonDate != currDate ) {
243 if ( downloadSkeleton() == success) {
244 _skeletonDate = currDate;
245 _reloadDone = false;
246 }
247 else {
248 if(!_reloadDone) {
249 _reloadTable = true;
250 if ( downloadSkeleton() == success) {
251 _skeletonDate = currDate;
252 }
253 _reloadTable = false;
254 _reloadDone = true;
255 }
256 }
257 }
258 }
259}
260
261// Next File Epoch (static)
262////////////////////////////////////////////////////////////////////////////
263QString bncRinex::nextEpochStr(const QDateTime& datTim,
264 const QString& intStr, QDateTime* nextEpoch) {
265
266 QString epoStr;
267
268 QTime nextTime;
269 QDate nextDate;
270
271 int indHlp = intStr.indexOf("min");
272
273 if ( indHlp != -1) {
274 int step = intStr.left(indHlp-1).toInt();
275 char ch = 'A' + datTim.time().hour();
276 epoStr = ch;
277 if (datTim.time().minute() >= 60-step) {
278 epoStr += QString("%1").arg(60-step, 2, 10, QChar('0'));
279 if (datTim.time().hour() < 23) {
280 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
281 nextDate = datTim.date();
282 }
283 else {
284 nextTime.setHMS(0, 0, 0);
285 nextDate = datTim.date().addDays(1);
286 }
287 }
288 else {
289 for (int limit = step; limit <= 60-step; limit += step) {
290 if (datTim.time().minute() < limit) {
291 epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));
292 nextTime.setHMS(datTim.time().hour(), limit, 0);
293 nextDate = datTim.date();
294 break;
295 }
296 }
297 }
298 }
299 else if (intStr == "1 hour") {
300 char ch = 'A' + datTim.time().hour();
301 epoStr = ch;
302 if (datTim.time().hour() < 23) {
303 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
304 nextDate = datTim.date();
305 }
306 else {
307 nextTime.setHMS(0, 0, 0);
308 nextDate = datTim.date().addDays(1);
309 }
310 }
311 else {
312 epoStr = "0";
313 nextTime.setHMS(0, 0, 0);
314 nextDate = datTim.date().addDays(1);
315 }
316
317 if (nextEpoch) {
318 *nextEpoch = QDateTime(nextDate, nextTime);
319 }
320
321 return epoStr;
322}
323
324// File Name according to RINEX Standards
325////////////////////////////////////////////////////////////////////////////
326void bncRinex::resolveFileName(const QDateTime& datTim) {
327
328 bncSettings settings;
329 QString path = settings.value("rnxPath").toString();
330 expandEnvVar(path);
331
332 if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
333 path += QDir::separator();
334 }
335
336 QString hlpStr = nextEpochStr(datTim, settings.value("rnxIntr").toString(),
337 &_nextCloseEpoch);
338
339 QString ID4 = _statID.left(4);
340
341 // Check name conflict
342 // -------------------
343 QString distStr;
344 int num = 0;
345 QListIterator<QString> it(settings.value("mountPoints").toStringList());
346 while (it.hasNext()) {
347 QString mp = it.next();
348 if (mp.indexOf(ID4) != -1) {
349 ++num;
350 }
351 }
352 if (num > 1) {
353 distStr = "_" + _statID.mid(4);
354 }
355
356 QString sklExt = settings.value("rnxSkel").toString();
357 if (!sklExt.isEmpty()) {
358 _sklName = path + ID4 + distStr + "." + sklExt;
359 }
360
361 path += ID4 +
362 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
363 hlpStr + distStr + datTim.toString(".yyO");
364
365 _fName = path.toAscii();
366}
367
368// Write RINEX Header
369////////////////////////////////////////////////////////////////////////////
370void bncRinex::writeHeader(const QDateTime& datTim,
371 const QDateTime& datTimNom) {
372
373 bncSettings settings;
374
375 // Open the Output File
376 // --------------------
377 resolveFileName(datTimNom);
378
379 // Append to existing file and return
380 // ----------------------------------
381 if ( QFile::exists(_fName) ) {
382 if (_reconnectFlag ||
383 Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
384 _out.open(_fName.data(), ios::app);
385 _out.setf(ios::showpoint | ios::fixed);
386 _headerWritten = true;
387 _reconnectFlag = false;
388 return;
389 }
390 }
391
392 _out.open(_fName.data());
393 _out.setf(ios::showpoint | ios::fixed);
394
395 // Copy Skeleton Header
396 // --------------------
397 readSkeleton();
398 if (_headerLines.size() > 0) {
399 QStringListIterator it(_headerLines);
400 while (it.hasNext()) {
401 QString line = it.next();
402 if (line.indexOf("PGM / RUN BY / DATE") != -1) {
403 if (_rinexVers == 3) {
404 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
405 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
406 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
407 }
408 else {
409 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
410 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
411 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
412 }
413 }
414 else if (line.indexOf("# / TYPES OF OBSERV") != -1) {
415 if (_rinexVers == 3) {
416 _out << "G 20 C1C L1C D1C S1C C1W L1W D1W S1W C2P L2P D2P S2P C2X SYS / # / OBS TYPES" << endl;
417 _out << " L2X D2X S2X C5 L5 D5 S5 SYS / # / OBS TYPES" << endl;
418 _out << "R 16 C1C L1C D1C S1C C1P L1P D1P S1P C2P L2P D2P S2P C2C SYS / # / OBS TYPES" << endl;
419 _out << " L2C D2C S2C SYS / # / OBS TYPES" << endl;
420 _out << "S 8 C1C L1C D1C S1C C1W L1W D1W S1W SYS / # / OBS TYPES" << endl;
421 _out << "E 8 C1 L1 D1 S1 C5 L5 D5 S5 SYS / # / OBS TYPES" << endl;
422 }
423 else {
424 _out << " 8 C1 P1 L1 S1 C2 P2 L2 S2"
425 " # / TYPES OF OBSERV" << endl;
426 }
427 }
428 else if (line.indexOf("TIME OF FIRST OBS") != -1) {
429 _out << datTim.toString(" yyyy MM dd"
430 " hh mm ss.zzz0000").toAscii().data();
431 _out << " GPS TIME OF FIRST OBS" << endl;
432 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
433 _mountPoint.path())).leftJustified(60, ' ', true);
434 _out << hlp.toAscii().data() << "COMMENT" << endl;
435 }
436 else if (line.indexOf("MARKER NAME") != -1) {
437 if (_rinexVers == 3) {
438 _out << line.toAscii().data() << endl;
439 _out << setw(71) << "GEODETIC MARKER TYPE" << endl;
440 }
441 else {
442 _out << line.toAscii().data() << endl;
443 }
444 }
445 else {
446 _out << line.toAscii().data() << endl;
447 }
448 }
449 }
450
451 // Write Dummy Header
452 // ------------------
453 else {
454 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0;
455
456 if (_rinexVers == 3) {
457 _out << " 3.00 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
458 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
459 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
460 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
461 }
462 else {
463 _out << " 2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
464 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
465 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
466 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
467 }
468 _out.setf(ios::left);
469 _out << setw(60) << _statID.data() << "MARKER NAME" << endl;
470 if (_rinexVers == 3) {
471 _out << setw(60) << "unknown" << "MARKER TYPE " << endl;
472 }
473 _out << setw(60) << "unknown unknown" << "OBSERVER / AGENCY" << endl;
474 _out << setw(20) << "unknown"
475 << setw(20) << "unknown"
476 << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl;
477 _out << setw(20) << "unknown"
478 << setw(20) << "unknown"
479 << setw(20) << " " << "ANT # / TYPE" << endl;
480 _out.unsetf(ios::left);
481 _out << setw(14) << setprecision(4) << _approxPos[0]
482 << setw(14) << setprecision(4) << _approxPos[1]
483 << setw(14) << setprecision(4) << _approxPos[2]
484 << " " << "APPROX POSITION XYZ" << endl;
485 _out << setw(14) << setprecision(4) << antennaNEU[0]
486 << setw(14) << setprecision(4) << antennaNEU[1]
487 << setw(14) << setprecision(4) << antennaNEU[2]
488 << " " << "ANTENNA: DELTA H/E/N" << endl;
489 if (_rinexVers == 3) {
490 _out << "G 20 C1C L1C D1C S1C C1W L1W D1W S1W C2P L2P D2P S2P C2X SYS / # / OBS TYPES" << endl;
491 _out << " L2X D2X S2X C5 L5 D5 S5 SYS / # / OBS TYPES" << endl;
492 _out << "R 16 C1C L1C D1C S1C C1P L1P D1P S1P C2P L2P D2P S2P C2C SYS / # / OBS TYPES" << endl;
493 _out << " L2C D2C S2C SYS / # / OBS TYPES" << endl;
494 _out << "S 8 C1C L1C D1C S1C C1W L1W D1W S1W SYS / # / OBS TYPES" << endl;
495 _out << "E 8 C1 L1 D1 S1 C5 L5 D5 S5 SYS / # / OBS TYPES" << endl;
496 }
497 else {
498 _out << " 1 1 WAVELENGTH FACT L1/2" << endl;
499 _out << " 8 C1 P1 L1 S1 C2 P2 L2 S2 # / TYPES OF OBSERV" << endl;
500 }
501 _out << datTim.toString(" yyyy MM dd"
502 " hh mm ss.zzz0000").toAscii().data();
503 _out << " GPS TIME OF FIRST OBS" << endl;
504 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
505 _mountPoint.path())).leftJustified(60, ' ', true);
506 _out << hlp.toAscii().data() << "COMMENT" << endl;
507
508 if (_nmea == "yes") {
509 hlp = ("NMEA LAT=" + _latitude + " " + "LONG=" + _longitude).leftJustified(60, ' ',true);
510 _out << hlp.toAscii().data() << "COMMENT" << endl; }
511
512 _out << " END OF HEADER" << endl;
513 }
514
515 _headerWritten = true;
516}
517
518// Stores Observation into Internal Array
519////////////////////////////////////////////////////////////////////////////
520void bncRinex::deepCopy(const t_obs* obs) {
521 t_obs* newObs = new t_obs();
522 memcpy(newObs, obs, sizeof(t_obs));
523 _obs.push_back(newObs);
524}
525
526// Write One Epoch into the RINEX File
527////////////////////////////////////////////////////////////////////////////
528void bncRinex::dumpEpoch(long maxTime) {
529
530 // Select observations older than maxTime
531 // --------------------------------------
532 QList<t_obs*> dumpList;
533 QMutableListIterator<t_obs*> mIt(_obs);
534 while (mIt.hasNext()) {
535 t_obs* obs = mIt.next();
536 if (obs->GPSWeek * 7*24*3600 + obs->GPSWeeks < maxTime - 0.05) {
537 dumpList.push_back(obs);
538 mIt.remove();
539 }
540 }
541
542 // Easy Return
543 // -----------
544 if (dumpList.isEmpty()) {
545 return;
546 }
547
548 // Time of Epoch
549 // -------------
550 t_obs* fObs = *dumpList.begin();
551 QDateTime datTim = dateAndTimeFromGPSweek(fObs->GPSWeek, fObs->GPSWeeks);
552 QDateTime datTimNom = dateAndTimeFromGPSweek(fObs->GPSWeek,
553 floor(fObs->GPSWeeks+0.5));
554
555 // Close the file
556 // --------------
557 if (_nextCloseEpoch.isValid() && datTimNom >= _nextCloseEpoch) {
558 closeFile();
559 _headerWritten = false;
560 }
561
562 // Write RINEX Header
563 // ------------------
564 if (!_headerWritten) {
565 writeHeader(datTim, datTimNom);
566 }
567
568 double sec = double(datTim.time().second()) + fmod(fObs->GPSWeeks,1.0);
569
570 // Epoch header line: RINEX Version 3
571 // ----------------------------------
572 if (_rinexVers == 3) {
573 _out << datTim.toString("> yyyy MM dd hh mm ").toAscii().data()
574 << setw(10) << setprecision(7) << sec
575 << " " << 0 << setw(3) << dumpList.size() << endl;
576 }
577 // Epoch header line: RINEX Version 2
578 // ----------------------------------
579 else {
580 _out << datTim.toString(" yy MM dd hh mm ").toAscii().data()
581 << setw(10) << setprecision(7) << sec
582 << " " << 0 << setw(3) << dumpList.size();
583
584 QListIterator<t_obs*> it(dumpList); int iSat = 0;
585 while (it.hasNext()) {
586 iSat++;
587 t_obs* obs = it.next();
588 _out << obs->satSys << setw(2) << obs->satNum;
589 if (iSat == 12 && it.hasNext()) {
590 _out << endl << " ";
591 iSat = 0;
592 }
593 }
594 _out << endl;
595 }
596
597 QListIterator<t_obs*> it(dumpList);
598 while (it.hasNext()) {
599 t_obs* obs = it.next();
600
601 // Cycle slips detection
602 // ---------------------
603 QString prn = QString("%1%2").arg(obs->satSys)
604 .arg(obs->satNum, 2, 10, QChar('0'));
605
606 char lli1 = ' ';
607 char lli2 = ' ';
608 char lli5 = ' ';
609 if ( obs->slip_cnt_L1 >= 0 ) {
610 if ( _slip_cnt_L1.find(prn) != _slip_cnt_L1.end() &&
611 _slip_cnt_L1.find(prn).value() != obs->slip_cnt_L1 ) {
612 lli1 = '1';
613 }
614 }
615
616 if ( obs->slip_cnt_L2 >= 0 ) {
617 if ( _slip_cnt_L2.find(prn) != _slip_cnt_L2.end() &&
618 _slip_cnt_L2.find(prn).value() != obs->slip_cnt_L2 ) {
619 lli2 = '1';
620 }
621 }
622
623 if ( obs->slip_cnt_L5 >= 0 ) {
624 if ( _slip_cnt_L5.find(prn) != _slip_cnt_L5.end() &&
625 _slip_cnt_L5.find(prn).value() != obs->slip_cnt_L5 ) {
626 lli5 = '1';
627 }
628 }
629
630 _slip_cnt_L1[prn] = obs->slip_cnt_L1;
631 _slip_cnt_L2[prn] = obs->slip_cnt_L2;
632 _slip_cnt_L5[prn] = obs->slip_cnt_L5;
633
634 // RINEX Version 3
635 // ---------------
636 if (_rinexVers == 3) {
637 _out << rinexSatLine(obs, lli1, lli2, lli5);
638 _out << endl;
639 }
640
641 // RINEX Version 2
642 // ---------------
643 else {
644 _out << setw(14) << setprecision(3) << obs->C1 << ' ' << ' '
645 << setw(14) << setprecision(3) << obs->P1 << ' ' << ' '
646 << setw(14) << setprecision(3) << obs->L1() << lli1 << ' '
647 << setw(14) << setprecision(3) << obs->S1() << ' ' << ' '
648 << setw(14) << setprecision(3) << obs->C2 << ' ' << ' ' << endl
649 << setw(14) << setprecision(3) << obs->P2 << ' ' << ' '
650 << setw(14) << setprecision(3) << obs->L2() << lli2 << ' '
651 << setw(16) << setprecision(3) << obs->S2() << endl;
652 }
653
654 delete obs;
655 }
656
657 _out.flush();
658}
659
660// Close the Old RINEX File
661////////////////////////////////////////////////////////////////////////////
662void bncRinex::closeFile() {
663 if (_rinexVers == 3) {
664 _out << "> 4 1" << endl;
665 _out << "END OF FILE" << endl;
666 }
667 _out.close();
668 if (!_rnxScriptName.isEmpty()) {
669 qApp->thread()->wait(100);
670#ifdef WIN32
671 QProcess::startDetached(_rnxScriptName, QStringList() << _fName) ;
672#else
673 QProcess::startDetached("nohup", QStringList() << _rnxScriptName << _fName) ;
674#endif
675
676 }
677}
678
679// One Line in RINEX v3 (static)
680////////////////////////////////////////////////////////////////////////////
681string bncRinex::rinexSatLine(const t_obs* obs,
682 char lli1, char lli2, char lli5) {
683 ostringstream str;
684 str.setf(ios::showpoint | ios::fixed);
685
686 if (obs->satSys == 'G') { // GPS
687 str << obs->satSys
688 << setw(2) << setfill('0') << obs->satNum << setfill(' ')
689 << setw(14) << setprecision(3) << obs->C1 << ' ' << ' '
690 << setw(14) << setprecision(3) << obs->L1C << lli1 << ' '
691 << setw(14) << setprecision(3) << obs->D1C << ' ' << ' '
692 << setw(14) << setprecision(3) << obs->S1C << ' ' << ' '
693 << setw(14) << setprecision(3) << obs->P1 << ' ' << ' '
694 << setw(14) << setprecision(3) << obs->L1P << lli1 << ' '
695 << setw(14) << setprecision(3) << obs->D1P << ' ' << ' '
696 << setw(14) << setprecision(3) << obs->S1P << ' ' << ' '
697 << setw(14) << setprecision(3) << obs->P2 << ' ' << ' '
698 << setw(14) << setprecision(3) << obs->L2P << lli2 << ' '
699 << setw(14) << setprecision(3) << obs->D2P << ' ' << ' '
700 << setw(14) << setprecision(3) << obs->S2P << ' ' << ' '
701 << setw(14) << setprecision(3) << obs->C2 << ' ' << ' '
702 << setw(14) << setprecision(3) << obs->L2C << lli2 << ' '
703 << setw(14) << setprecision(3) << obs->D2C << ' ' << ' '
704 << setw(14) << setprecision(3) << obs->S2C << ' ' << ' '
705 << setw(14) << setprecision(3) << obs->C5 << ' ' << ' '
706 << setw(14) << setprecision(3) << obs->L5 << lli5 << ' '
707 << setw(14) << setprecision(3) << obs->D5 << ' ' << ' '
708 << setw(14) << setprecision(3) << obs->S5;
709 }
710 else if (obs->satSys == 'R') { // Glonass
711 str << obs->satSys
712 << setw(2) << setfill('0') << obs->satNum << setfill(' ')
713 << setw(14) << setprecision(3) << obs->C1 << ' ' << ' '
714 << setw(14) << setprecision(3) << obs->L1C << lli1 << ' '
715 << setw(14) << setprecision(3) << obs->D1C << ' ' << ' '
716 << setw(14) << setprecision(3) << obs->S1C << ' ' << ' '
717 << setw(14) << setprecision(3) << obs->P1 << ' ' << ' '
718 << setw(14) << setprecision(3) << obs->L1P << lli1 << ' '
719 << setw(14) << setprecision(3) << obs->D1P << ' ' << ' '
720 << setw(14) << setprecision(3) << obs->S1P << ' ' << ' '
721 << setw(14) << setprecision(3) << obs->P2 << ' ' << ' '
722 << setw(14) << setprecision(3) << obs->L2P << lli2 << ' '
723 << setw(14) << setprecision(3) << obs->D2P << ' ' << ' '
724 << setw(14) << setprecision(3) << obs->S2P << ' ' << ' '
725 << setw(14) << setprecision(3) << obs->C2 << ' ' << ' '
726 << setw(14) << setprecision(3) << obs->L2C << lli2 << ' '
727 << setw(14) << setprecision(3) << obs->D2C << ' ' << ' '
728 << setw(14) << setprecision(3) << obs->S2C;
729 }
730 else if (obs->satSys == 'S') { // SBAS
731 str << obs->satSys
732 << setw(2) << setfill('0') << obs->satNum << setfill(' ')
733 << setw(14) << setprecision(3) << obs->C1 << ' ' << ' '
734 << setw(14) << setprecision(3) << obs->L1C << lli1 << ' '
735 << setw(14) << setprecision(3) << obs->D1C << ' ' << ' '
736 << setw(14) << setprecision(3) << obs->S1C << ' ' << ' '
737 << setw(14) << setprecision(3) << obs->P1 << ' ' << ' '
738 << setw(14) << setprecision(3) << obs->L1P << lli1 << ' '
739 << setw(14) << setprecision(3) << obs->D1P << ' ' << ' '
740 << setw(14) << setprecision(3) << obs->S1P;
741 }
742 else if (obs->satSys == 'E') { // Galileo
743 str << obs->satSys
744 << setw(2) << setfill('0') << obs->satNum << setfill(' ')
745 << setw(14) << setprecision(3) << obs->C1 << ' ' << ' '
746 << setw(14) << setprecision(3) << obs->L1C << lli1 << ' '
747 << setw(14) << setprecision(3) << obs->D1C << ' ' << ' '
748 << setw(14) << setprecision(3) << obs->S1C << ' ' << ' '
749 << setw(14) << setprecision(3) << obs->C5 << ' ' << ' '
750 << setw(14) << setprecision(3) << obs->L5 << lli5 << ' '
751 << setw(14) << setprecision(3) << obs->D5 << ' ' << ' '
752 << setw(14) << setprecision(3) << obs->S5;
753 }
754 return str.str();
755}
Note: See TracBrowser for help on using the repository browser.