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

Last change on this file since 2703 was 2703, checked in by mervart, 13 years ago
File size: 26.0 KB
RevLine 
[280]1// Part of BNC, a utility for retrieving decoding and
[464]2// converting GNSS data streams from NTRIP broadcasters.
[280]3//
[464]4// Copyright (C) 2007
[280]5// German Federal Agency for Cartography and Geodesy (BKG)
6// http://www.bkg.bund.de
[464]7// Czech Technical University Prague, Department of Geodesy
[280]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.
[73]24
25/* -------------------------------------------------------------------------
[93]26 * BKG NTRIP Client
[73]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
[292]41#include <stdlib.h>
[300]42#include <iostream>
[75]43#include <iomanip>
[221]44#include <math.h>
[2695]45#include <sstream>
[75]46
[300]47#include <QtCore>
48#include <QUrl>
49#include <QString>
50
[73]51#include "bncrinex.h"
[157]52#include "bncapp.h"
[82]53#include "bncutils.h"
[126]54#include "bncconst.h"
[298]55#include "bnctabledlg.h"
[301]56#include "bncgetthread.h"
[1858]57#include "bncnetqueryv2.h"
[1535]58#include "bncsettings.h"
[2012]59#include "bncversion.h"
[2492]60#include "rtcm3torinex.h"
[75]61
62using namespace std;
63
[73]64// Constructor
65////////////////////////////////////////////////////////////////////////////
[408]66bncRinex::bncRinex(const QByteArray& statID, const QUrl& mountPoint,
[366]67 const QByteArray& format, const QByteArray& latitude,
[1639]68 const QByteArray& longitude, const QByteArray& nmea,
69 const QByteArray& ntripVersion) {
[1387]70
[408]71 _statID = statID;
[336]72 _mountPoint = mountPoint;
[337]73 _format = format.left(6);
[366]74 _latitude = latitude;
75 _longitude = longitude;
76 _nmea = nmea;
[1639]77 _ntripVersion = ntripVersion;
[77]78 _headerWritten = false;
[369]79 _reconnectFlag = false;
[656]80 _reloadTable = false;
81 _reloadDone = false;
[132]82
[1535]83 bncSettings settings;
[132]84 _rnxScriptName = settings.value("rnxScript").toString();
85 expandEnvVar(_rnxScriptName);
[153]86
[2012]87 _pgmName = QString(BNCPGMNAME).leftJustified(20, ' ', true);
[319]88#ifdef WIN32
89 _userName = QString("${USERNAME}");
90#else
[158]91 _userName = QString("${USER}");
[319]92#endif
[157]93 expandEnvVar(_userName);
[158]94 _userName = _userName.leftJustified(20, ' ', true);
[539]95
96 if ( Qt::CheckState(settings.value("rnxV3").toInt()) == Qt::Checked) {
97 _rinexVers = 3;
98 }
99 else {
100 _rinexVers = 2;
101 }
[1044]102
103 _approxPos[0] = _approxPos[1] = _approxPos[2] = 0.0;
[73]104}
105
106// Destructor
107////////////////////////////////////////////////////////////////////////////
108bncRinex::~bncRinex() {
[622]109 QListIterator<p_obs> it(_obs);
[607]110 while (it.hasNext()) {
111 delete it.next();
112 }
[1535]113 bncSettings settings;
[698]114 if ((_rinexVers == 3) && ( Qt::CheckState(settings.value("rnxAppend").toInt()) != Qt::Checked) ) {
[843]115 _out << "> 4 1" << endl;
[698]116 _out << "END OF FILE" << endl;
117 }
[77]118 _out.close();
[73]119}
120
[420]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(),
[1376]129 table, _reloadTable);
[420]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(";");
[1495]136 if (tags.size() > 7) {
137 if (tags.at(1) == _mountPoint.path().mid(1).toAscii()) {
138 net = tags.at(7);
139 break;
140 }
[420]141 }
142 }
143 }
144 QString sklDir;
[1495]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 }
[420]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
[1858]166 bncNetQueryV2 query;
[1386]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() ) {
[1348]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");
[556]183 }
[1348]184 else {
185 _headerLines.append(" 2.11 OBSERVATION DATA"
186 " M (MIXED)"
187 " RINEX VERSION / TYPE");
[421]188 }
[1348]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");
[421]199 }
[1348]200 _headerLines.append("TIME OF FIRST OBS");
201 _headerLines.append( line );
202 break;
[421]203 }
[420]204 else {
[1348]205 _headerLines.append( line );
[420]206 }
207 }
[1386]208 line = in.readLine();
[420]209 }
[1386]210 }
211 else {
212 return failure;
[420]213 }
[1386]214
[420]215 }
216 return irc;
217}
218
[82]219// Read Skeleton Header File
220////////////////////////////////////////////////////////////////////////////
221void bncRinex::readSkeleton() {
222
[420]223 // Read the local file
224 // -------------------
[276]225 QFile skl(_sklName);
[82]226 if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) {
[422]227 _headerLines.clear();
[82]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 }
[298]236
[420]237 // Read downloaded file
238 // --------------------
[2376]239 else if ( _ntripVersion != "N" && _ntripVersion != "UN" &&
240 _ntripVersion != "S" ) {
[1154]241 QDate currDate = currentDateAndTimeGPS().date();
[420]242 if ( !_skeletonDate.isValid() || _skeletonDate != currDate ) {
243 if ( downloadSkeleton() == success) {
244 _skeletonDate = currDate;
[656]245 _reloadDone = false;
[298]246 }
[656]247 else {
248 if(!_reloadDone) {
249 _reloadTable = true;
250 if ( downloadSkeleton() == success) {
251 _skeletonDate = currDate;
252 }
253 _reloadTable = false;
254 _reloadDone = true;
255 }
256 }
[298]257 }
258 }
[82]259}
260
[647]261// Next File Epoch (static)
[82]262////////////////////////////////////////////////////////////////////////////
[647]263QString bncRinex::nextEpochStr(const QDateTime& datTim,
264 const QString& intStr, QDateTime* nextEpoch) {
[82]265
[647]266 QString epoStr;
[82]267
[129]268 QTime nextTime;
269 QDate nextDate;
270
[204]271 int indHlp = intStr.indexOf("min");
272
273 if ( indHlp != -1) {
274 int step = intStr.left(indHlp-1).toInt();
[127]275 char ch = 'A' + datTim.time().hour();
[647]276 epoStr = ch;
[204]277 if (datTim.time().minute() >= 60-step) {
[647]278 epoStr += QString("%1").arg(60-step, 2, 10, QChar('0'));
[199]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 {
[204]289 for (int limit = step; limit <= 60-step; limit += step) {
290 if (datTim.time().minute() < limit) {
[647]291 epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));
[204]292 nextTime.setHMS(datTim.time().hour(), limit, 0);
293 nextDate = datTim.date();
294 break;
295 }
[199]296 }
297 }
298 }
[127]299 else if (intStr == "1 hour") {
300 char ch = 'A' + datTim.time().hour();
[647]301 epoStr = ch;
[129]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 }
[127]310 }
311 else {
[647]312 epoStr = "0";
[129]313 nextTime.setHMS(0, 0, 0);
314 nextDate = datTim.date().addDays(1);
[127]315 }
[82]316
[647]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
[1535]328 bncSettings settings;
[647]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
[183]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
[276]356 QString sklExt = settings.value("rnxSkel").toString();
357 if (!sklExt.isEmpty()) {
358 _sklName = path + ID4 + distStr + "." + sklExt;
359 }
360
[183]361 path += ID4 +
[127]362 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
[276]363 hlpStr + distStr + datTim.toString(".yyO");
[82]364
365 _fName = path.toAscii();
366}
367
[77]368// Write RINEX Header
369////////////////////////////////////////////////////////////////////////////
[267]370void bncRinex::writeHeader(const QDateTime& datTim,
371 const QDateTime& datTimNom) {
[77]372
[1535]373 bncSettings settings;
[356]374
[77]375 // Open the Output File
376 // --------------------
[267]377 resolveFileName(datTimNom);
[260]378
379 // Append to existing file and return
380 // ----------------------------------
381 if ( QFile::exists(_fName) ) {
[369]382 if (_reconnectFlag ||
383 Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
[260]384 _out.open(_fName.data(), ios::app);
385 _out.setf(ios::showpoint | ios::fixed);
386 _headerWritten = true;
[369]387 _reconnectFlag = false;
[260]388 return;
389 }
390 }
391
[82]392 _out.open(_fName.data());
[85]393 _out.setf(ios::showpoint | ios::fixed);
[77]394
[82]395 // Copy Skeleton Header
396 // --------------------
[276]397 readSkeleton();
[82]398 if (_headerLines.size() > 0) {
399 QStringListIterator it(_headerLines);
400 while (it.hasNext()) {
401 QString line = it.next();
[157]402 if (line.indexOf("PGM / RUN BY / DATE") != -1) {
[552]403 if (_rinexVers == 3) {
[1154]404 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
[552]405 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
406 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
407 }
408 else {
[1154]409 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[552]410 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
411 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
412 }
[157]413 }
414 else if (line.indexOf("# / TYPES OF OBSERV") != -1) {
[545]415 if (_rinexVers == 3) {
[2703]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;
[545]422 }
423 else {
[2690]424 _out << " 8 C1 P1 L1 S1 C2 P2 L2 S2"
[545]425 " # / TYPES OF OBSERV" << endl;
426 }
[82]427 }
428 else if (line.indexOf("TIME OF FIRST OBS") != -1) {
[125]429 _out << datTim.toString(" yyyy MM dd"
430 " hh mm ss.zzz0000").toAscii().data();
[553]431 _out << " GPS TIME OF FIRST OBS" << endl;
[337]432 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
433 _mountPoint.path())).leftJustified(60, ' ', true);
[156]434 _out << hlp.toAscii().data() << "COMMENT" << endl;
[82]435 }
[689]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 }
[82]445 else {
446 _out << line.toAscii().data() << endl;
447 }
448 }
449 }
[78]450
[82]451 // Write Dummy Header
452 // ------------------
453 else {
454 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0;
455
[545]456 if (_rinexVers == 3) {
457 _out << " 3.00 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
[1154]458 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
[552]459 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
460 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
[545]461 }
462 else {
463 _out << " 2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
[1154]464 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
[552]465 _out << _pgmName.toAscii().data() << _userName.toAscii().data()
466 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
[545]467 }
[86]468 _out.setf(ios::left);
[82]469 _out << setw(60) << _statID.data() << "MARKER NAME" << endl;
[689]470 if (_rinexVers == 3) {
471 _out << setw(60) << "unknown" << "MARKER TYPE " << endl;
472 }
[354]473 _out << setw(60) << "unknown unknown" << "OBSERVER / AGENCY" << endl;
[82]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;
[86]480 _out.unsetf(ios::left);
[1044]481 _out << setw(14) << setprecision(4) << _approxPos[0]
482 << setw(14) << setprecision(4) << _approxPos[1]
483 << setw(14) << setprecision(4) << _approxPos[2]
[82]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;
[544]489 if (_rinexVers == 3) {
[2703]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;
[544]496 }
497 else {
498 _out << " 1 1 WAVELENGTH FACT L1/2" << endl;
[2690]499 _out << " 8 C1 P1 L1 S1 C2 P2 L2 S2 # / TYPES OF OBSERV" << endl;
[544]500 }
501 _out << datTim.toString(" yyyy MM dd"
[125]502 " hh mm ss.zzz0000").toAscii().data();
[553]503 _out << " GPS TIME OF FIRST OBS" << endl;
[552]504 QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
[337]505 _mountPoint.path())).leftJustified(60, ' ', true);
[156]506 _out << hlp.toAscii().data() << "COMMENT" << endl;
[366]507
[410]508 if (_nmea == "yes") {
509 hlp = ("NMEA LAT=" + _latitude + " " + "LONG=" + _longitude).leftJustified(60, ' ',true);
[366]510 _out << hlp.toAscii().data() << "COMMENT" << endl; }
511
[82]512 _out << " END OF HEADER" << endl;
513 }
[78]514
[77]515 _headerWritten = true;
516}
517
[73]518// Stores Observation into Internal Array
519////////////////////////////////////////////////////////////////////////////
[622]520void bncRinex::deepCopy(const p_obs obs) {
521 p_obs newObs = new t_obs();
[626]522 memcpy(&newObs->_o, &obs->_o, sizeof(t_obsInternal));
[74]523 _obs.push_back(newObs);
[73]524}
525
526// Write One Epoch into the RINEX File
527////////////////////////////////////////////////////////////////////////////
[160]528void bncRinex::dumpEpoch(long maxTime) {
[73]529
[160]530 // Select observations older than maxTime
531 // --------------------------------------
[622]532 QList<p_obs> dumpList;
533 QMutableListIterator<p_obs> mIt(_obs);
[160]534 while (mIt.hasNext()) {
[622]535 p_obs obs = mIt.next();
536 if (obs->_o.GPSWeek * 7*24*3600 + obs->_o.GPSWeeks < maxTime - 0.05) {
537 dumpList.push_back(obs);
[160]538 mIt.remove();
539 }
540 }
541
[75]542 // Easy Return
543 // -----------
[160]544 if (dumpList.isEmpty()) {
[75]545 return;
546 }
547
548 // Time of Epoch
549 // -------------
[622]550 p_obs fObs = *dumpList.begin();
551 QDateTime datTim = dateAndTimeFromGPSweek(fObs->_o.GPSWeek, fObs->_o.GPSWeeks);
552 QDateTime datTimNom = dateAndTimeFromGPSweek(fObs->_o.GPSWeek,
553 floor(fObs->_o.GPSWeeks+0.5));
[75]554
[130]555 // Close the file
556 // --------------
[267]557 if (_nextCloseEpoch.isValid() && datTimNom >= _nextCloseEpoch) {
[130]558 closeFile();
559 _headerWritten = false;
560 }
561
[78]562 // Write RINEX Header
563 // ------------------
564 if (!_headerWritten) {
[267]565 writeHeader(datTim, datTimNom);
[78]566 }
567
[622]568 double sec = double(datTim.time().second()) + fmod(fObs->_o.GPSWeeks,1.0);
[75]569
[1044]570 // Epoch header line: RINEX Version 3
571 // ----------------------------------
[540]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;
[74]576 }
[1044]577 // Epoch header line: RINEX Version 2
578 // ----------------------------------
[540]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();
[1044]583
[622]584 QListIterator<p_obs> it(dumpList); int iSat = 0;
[540]585 while (it.hasNext()) {
586 iSat++;
[622]587 p_obs obs = it.next();
588 _out << obs->_o.satSys << setw(2) << obs->_o.satNum;
[540]589 if (iSat == 12 && it.hasNext()) {
590 _out << endl << " ";
591 iSat = 0;
592 }
593 }
[77]594 _out << endl;
[1044]595 }
596
597 QListIterator<p_obs> it(dumpList);
598 while (it.hasNext()) {
599 p_obs obs = it.next();
600
601 // Cycle slips detection
602 // ---------------------
[2689]603 QString prn = QString("%1%2").arg(obs->_o.satSys)
604 .arg(obs->_o.satNum, 2, 10, QChar('0'));
[1044]605
606 char lli1 = ' ';
607 char lli2 = ' ';
[2688]608 char lli5 = ' ';
[1044]609 if ( obs->_o.slip_cnt_L1 >= 0 ) {
610 if ( _slip_cnt_L1.find(prn) != _slip_cnt_L1.end() &&
[2682]611 _slip_cnt_L1.find(prn).value() != obs->_o.slip_cnt_L1 ) {
612 lli1 = '1';
[1044]613 }
614 }
615
616 if ( obs->_o.slip_cnt_L2 >= 0 ) {
617 if ( _slip_cnt_L2.find(prn) != _slip_cnt_L2.end() &&
[2682]618 _slip_cnt_L2.find(prn).value() != obs->_o.slip_cnt_L2 ) {
619 lli2 = '1';
[1044]620 }
621 }
622
[2688]623 if ( obs->_o.slip_cnt_L5 >= 0 ) {
624 if ( _slip_cnt_L5.find(prn) != _slip_cnt_L5.end() &&
625 _slip_cnt_L5.find(prn).value() != obs->_o.slip_cnt_L5 ) {
626 lli5 = '1';
627 }
628 }
629
[1044]630 _slip_cnt_L1[prn] = obs->_o.slip_cnt_L1;
631 _slip_cnt_L2[prn] = obs->_o.slip_cnt_L2;
[2688]632 _slip_cnt_L5[prn] = obs->_o.slip_cnt_L5;
[1044]633
634 // RINEX Version 3
635 // ---------------
636 if (_rinexVers == 3) {
[2695]637 _out << rinexSatLine(obs->_o, lli1, lli2, lli5);
[2696]638 _out << endl;
[1044]639 }
640
641 // RINEX Version 2
642 // ---------------
643 else {
[2690]644 _out << setw(14) << setprecision(3) << obs->_o.C1 << ' ' << ' '
645 << setw(14) << setprecision(3) << obs->_o.P1 << ' ' << ' '
[2702]646 << setw(14) << setprecision(3) << obs->L1() << lli1 << ' '
647 << setw(14) << setprecision(3) << obs->S1() << ' ' << ' '
[2690]648 << setw(14) << setprecision(3) << obs->_o.C2 << ' ' << ' ' << endl
649 << setw(14) << setprecision(3) << obs->_o.P2 << ' ' << ' '
[2702]650 << setw(14) << setprecision(3) << obs->L2() << lli2 << ' '
651 << setw(16) << setprecision(3) << obs->S2() << endl;
[540]652 }
[1044]653
654 delete obs;
[75]655 }
656
[77]657 _out.flush();
[73]658}
659
[130]660// Close the Old RINEX File
661////////////////////////////////////////////////////////////////////////////
662void bncRinex::closeFile() {
[698]663 if (_rinexVers == 3) {
[843]664 _out << "> 4 1" << endl;
[698]665 _out << "END OF FILE" << endl;
666 }
[130]667 _out.close();
[132]668 if (!_rnxScriptName.isEmpty()) {
[1523]669 qApp->thread()->wait(100);
[435]670#ifdef WIN32
671 QProcess::startDetached(_rnxScriptName, QStringList() << _fName) ;
672#else
[475]673 QProcess::startDetached("nohup", QStringList() << _rnxScriptName << _fName) ;
[435]674#endif
[436]675
[132]676 }
[130]677}
[2695]678
679// One Line in RINEX v3 (static)
680////////////////////////////////////////////////////////////////////////////
681string bncRinex::rinexSatLine(const t_obsInternal& 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(' ')
[2702]689 << setw(14) << setprecision(3) << obs.C1 << ' ' << ' '
690 << setw(14) << setprecision(3) << obs.L1C << lli1 << ' '
[2703]691 << setw(14) << setprecision(3) << obs.D1C << ' ' << ' '
[2702]692 << setw(14) << setprecision(3) << obs.S1C << ' ' << ' '
[2703]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 << ' ' << ' '
[2702]701 << setw(14) << setprecision(3) << obs.C2 << ' ' << ' '
702 << setw(14) << setprecision(3) << obs.L2C << lli2 << ' '
[2703]703 << setw(14) << setprecision(3) << obs.D2C << ' ' << ' '
[2702]704 << setw(14) << setprecision(3) << obs.S2C << ' ' << ' '
705 << setw(14) << setprecision(3) << obs.C5 << ' ' << ' '
706 << setw(14) << setprecision(3) << obs.L5 << lli5 << ' '
[2703]707 << setw(14) << setprecision(3) << obs.D5 << ' ' << ' '
[2696]708 << setw(14) << setprecision(3) << obs.S5;
[2695]709 }
710 else if (obs.satSys == 'R') { // Glonass
711 str << obs.satSys
712 << setw(2) << setfill('0') << obs.satNum << setfill(' ')
[2702]713 << setw(14) << setprecision(3) << obs.C1 << ' ' << ' '
714 << setw(14) << setprecision(3) << obs.L1C << lli1 << ' '
[2703]715 << setw(14) << setprecision(3) << obs.D1C << ' ' << ' '
[2702]716 << setw(14) << setprecision(3) << obs.S1C << ' ' << ' '
[2703]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 << ' ' << ' '
[2702]726 << setw(14) << setprecision(3) << obs.L2C << lli2 << ' '
[2703]727 << setw(14) << setprecision(3) << obs.D2C << ' ' << ' '
[2702]728 << setw(14) << setprecision(3) << obs.S2C;
[2695]729 }
730 else if (obs.satSys == 'S') { // SBAS
731 str << obs.satSys
732 << setw(2) << setfill('0') << obs.satNum << setfill(' ')
[2702]733 << setw(14) << setprecision(3) << obs.C1 << ' ' << ' '
[2703]734 << setw(14) << setprecision(3) << obs.L1C << lli1 << ' '
735 << setw(14) << setprecision(3) << obs.D1C << ' ' << ' '
736 << setw(14) << setprecision(3) << obs.S1C << ' ' << ' '
[2702]737 << setw(14) << setprecision(3) << obs.P1 << ' ' << ' '
[2703]738 << setw(14) << setprecision(3) << obs.L1P << lli1 << ' '
739 << setw(14) << setprecision(3) << obs.D1P << ' ' << ' '
740 << setw(14) << setprecision(3) << obs.S1P;
[2695]741 }
742 else if (obs.satSys == 'E') { // Galileo
743 str << obs.satSys
744 << setw(2) << setfill('0') << obs.satNum << setfill(' ')
[2702]745 << setw(14) << setprecision(3) << obs.C1 << ' ' << ' '
746 << setw(14) << setprecision(3) << obs.L1C << lli1 << ' '
[2703]747 << setw(14) << setprecision(3) << obs.D1C << ' ' << ' '
[2702]748 << setw(14) << setprecision(3) << obs.S1C << ' ' << ' '
749 << setw(14) << setprecision(3) << obs.C5 << ' ' << ' '
750 << setw(14) << setprecision(3) << obs.L5 << lli5 << ' '
[2703]751 << setw(14) << setprecision(3) << obs.D5 << ' ' << ' '
[2696]752 << setw(14) << setprecision(3) << obs.S5;
[2695]753 }
754 return str.str();
755}
Note: See TracBrowser for help on using the repository browser.