[280] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters,
|
---|
| 3 | // written by Leos Mervart.
|
---|
| 4 | //
|
---|
| 5 | // Copyright (C) 2006
|
---|
| 6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 7 | // http://www.bkg.bund.de
|
---|
| 8 | // Czech Technical University Prague, Department of Advanced Geodesy
|
---|
| 9 | // http://www.fsv.cvut.cz
|
---|
| 10 | //
|
---|
| 11 | // Email: euref-ip@bkg.bund.de
|
---|
| 12 | //
|
---|
| 13 | // This program is free software; you can redistribute it and/or
|
---|
| 14 | // modify it under the terms of the GNU General Public License
|
---|
| 15 | // as published by the Free Software Foundation, version 2.
|
---|
| 16 | //
|
---|
| 17 | // This program is distributed in the hope that it will be useful,
|
---|
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | // GNU General Public License for more details.
|
---|
| 21 | //
|
---|
| 22 | // You should have received a copy of the GNU General Public License
|
---|
| 23 | // along with this program; if not, write to the Free Software
|
---|
| 24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
[73] | 25 |
|
---|
| 26 | /* -------------------------------------------------------------------------
|
---|
[93] | 27 | * BKG NTRIP Client
|
---|
[73] | 28 | * -------------------------------------------------------------------------
|
---|
| 29 | *
|
---|
| 30 | * Class: bncRinex
|
---|
| 31 | *
|
---|
| 32 | * Purpose: writes RINEX files
|
---|
| 33 | *
|
---|
| 34 | * Author: L. Mervart
|
---|
| 35 | *
|
---|
| 36 | * Created: 27-Aug-2006
|
---|
| 37 | *
|
---|
| 38 | * Changes:
|
---|
| 39 | *
|
---|
| 40 | * -----------------------------------------------------------------------*/
|
---|
| 41 |
|
---|
[292] | 42 | #include <stdlib.h>
|
---|
[300] | 43 | #include <iostream>
|
---|
[75] | 44 | #include <iomanip>
|
---|
[221] | 45 | #include <math.h>
|
---|
[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"
|
---|
[223] | 57 | #include "RTCM3/rtcm3torinex.h"
|
---|
[75] | 58 |
|
---|
| 59 | using namespace std;
|
---|
| 60 |
|
---|
[73] | 61 | // Constructor
|
---|
| 62 | ////////////////////////////////////////////////////////////////////////////
|
---|
[408] | 63 | bncRinex::bncRinex(const QByteArray& statID, const QUrl& mountPoint,
|
---|
[366] | 64 | const QByteArray& format, const QByteArray& latitude,
|
---|
| 65 | const QByteArray& longitude, const QByteArray& nmea) {
|
---|
[408] | 66 | _statID = statID;
|
---|
[336] | 67 | _mountPoint = mountPoint;
|
---|
[337] | 68 | _format = format.left(6);
|
---|
[366] | 69 | _latitude = latitude;
|
---|
| 70 | _longitude = longitude;
|
---|
| 71 | _nmea = nmea;
|
---|
[77] | 72 | _headerWritten = false;
|
---|
[369] | 73 | _reconnectFlag = false;
|
---|
[132] | 74 |
|
---|
| 75 | QSettings settings;
|
---|
| 76 | _rnxScriptName = settings.value("rnxScript").toString();
|
---|
| 77 | expandEnvVar(_rnxScriptName);
|
---|
[153] | 78 |
|
---|
[157] | 79 | _pgmName = ((bncApp*)qApp)->bncVersion().leftJustified(20, ' ', true);
|
---|
[319] | 80 | #ifdef WIN32
|
---|
| 81 | _userName = QString("${USERNAME}");
|
---|
| 82 | #else
|
---|
[158] | 83 | _userName = QString("${USER}");
|
---|
[319] | 84 | #endif
|
---|
[157] | 85 | expandEnvVar(_userName);
|
---|
[158] | 86 | _userName = _userName.leftJustified(20, ' ', true);
|
---|
[73] | 87 | }
|
---|
| 88 |
|
---|
| 89 | // Destructor
|
---|
| 90 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 91 | bncRinex::~bncRinex() {
|
---|
[77] | 92 | _out.close();
|
---|
[73] | 93 | }
|
---|
| 94 |
|
---|
[420] | 95 | // Download Skeleton Header File
|
---|
| 96 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 97 | t_irc bncRinex::downloadSkeleton() {
|
---|
| 98 |
|
---|
| 99 | t_irc irc = failure;
|
---|
| 100 |
|
---|
| 101 | QStringList table;
|
---|
| 102 | bncTableDlg::getFullTable(_mountPoint.host(), _mountPoint.port(),
|
---|
| 103 | table, false);
|
---|
| 104 | QString net;
|
---|
| 105 | QStringListIterator it(table);
|
---|
| 106 | while (it.hasNext()) {
|
---|
| 107 | QString line = it.next();
|
---|
| 108 | if (line.indexOf("STR") == 0) {
|
---|
| 109 | QStringList tags = line.split(";");
|
---|
| 110 | if (tags.at(1) == _mountPoint.path().mid(1).toAscii()) {
|
---|
| 111 | net = tags.at(7);
|
---|
| 112 | break;
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 | QString sklDir;
|
---|
| 117 | it.toFront();
|
---|
| 118 | while (it.hasNext()) {
|
---|
| 119 | QString line = it.next();
|
---|
| 120 | if (line.indexOf("NET") == 0) {
|
---|
| 121 | QStringList tags = line.split(";");
|
---|
| 122 | if (tags.at(1) == net) {
|
---|
| 123 | sklDir = tags.at(6).trimmed();
|
---|
| 124 | break;
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 | if (!sklDir.isEmpty() && sklDir != "none") {
|
---|
| 129 | QUrl url(sklDir + "/" + _mountPoint.path().mid(1,4).toLower() + ".skl");
|
---|
| 130 | if (url.port() == -1) {
|
---|
| 131 | url.setPort(80);
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | const int timeOut = 10*1000;
|
---|
| 135 | QString msg;
|
---|
| 136 | QByteArray _latitude;
|
---|
| 137 | QByteArray _longitude;
|
---|
| 138 | QByteArray _nmea;
|
---|
| 139 | QTcpSocket* socket = bncGetThread::request(url, _latitude, _longitude, _nmea, timeOut, msg);
|
---|
| 140 |
|
---|
| 141 | if (socket) {
|
---|
[421] | 142 | _headerLines.clear();
|
---|
| 143 | bool firstLineRead = false;
|
---|
[420] | 144 | while (true) {
|
---|
| 145 | if (socket->canReadLine()) {
|
---|
| 146 | irc = success;
|
---|
[421] | 147 | QString line = socket->readLine();
|
---|
| 148 | line.chop(1);
|
---|
| 149 | if (line.indexOf("RINEX VERSION") != -1) {
|
---|
| 150 | _headerLines.append(" 2.11 OBSERVATION DATA"
|
---|
| 151 | " M (MIXED)"
|
---|
| 152 | " RINEX VERSION / TYPE");
|
---|
| 153 | _headerLines.append("PGM / RUN BY / DATE");
|
---|
| 154 | firstLineRead = true;
|
---|
| 155 | }
|
---|
| 156 | else if (firstLineRead) {
|
---|
| 157 | if (line.indexOf("END OF HEADER") != -1) {
|
---|
| 158 | _headerLines.append("# / TYPES OF OBSERV");
|
---|
| 159 | _headerLines.append(
|
---|
| 160 | QString(" 1 1").leftJustified(60, ' ', true) +
|
---|
| 161 | "WAVELENGTH FACT L1/2");
|
---|
| 162 | _headerLines.append("TIME OF FIRST OBS");
|
---|
| 163 | _headerLines.append( line );
|
---|
| 164 | break;
|
---|
| 165 | }
|
---|
| 166 | else {
|
---|
| 167 | _headerLines.append( line );
|
---|
| 168 | }
|
---|
| 169 | }
|
---|
[420] | 170 | }
|
---|
| 171 | else {
|
---|
| 172 | socket->waitForReadyRead(timeOut);
|
---|
| 173 | if (socket->bytesAvailable() > 0) {
|
---|
| 174 | continue;
|
---|
| 175 | }
|
---|
| 176 | else {
|
---|
| 177 | break;
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
| 181 | delete socket;
|
---|
| 182 | }
|
---|
| 183 | }
|
---|
| 184 | return irc;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
[82] | 187 | // Read Skeleton Header File
|
---|
| 188 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 189 | void bncRinex::readSkeleton() {
|
---|
| 190 |
|
---|
[420] | 191 | // Read the local file
|
---|
| 192 | // -------------------
|
---|
[276] | 193 | QFile skl(_sklName);
|
---|
[82] | 194 | if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) {
|
---|
[422] | 195 | _headerLines.clear();
|
---|
[82] | 196 | QTextStream in(&skl);
|
---|
| 197 | while ( !in.atEnd() ) {
|
---|
| 198 | _headerLines.append( in.readLine() );
|
---|
| 199 | if (_headerLines.last().indexOf("END OF HEADER") != -1) {
|
---|
| 200 | break;
|
---|
| 201 | }
|
---|
| 202 | }
|
---|
| 203 | }
|
---|
[298] | 204 |
|
---|
[420] | 205 | // Read downloaded file
|
---|
| 206 | // --------------------
|
---|
[298] | 207 | else {
|
---|
[420] | 208 | QDate currDate = QDate::currentDate();
|
---|
| 209 | if ( !_skeletonDate.isValid() || _skeletonDate != currDate ) {
|
---|
[422] | 210 | _headerLines.clear();
|
---|
[420] | 211 | if ( downloadSkeleton() == success) {
|
---|
| 212 | _skeletonDate = currDate;
|
---|
[298] | 213 | }
|
---|
| 214 | }
|
---|
| 215 | }
|
---|
[82] | 216 | }
|
---|
| 217 |
|
---|
| 218 | // File Name according to RINEX Standards
|
---|
| 219 | ////////////////////////////////////////////////////////////////////////////
|
---|
[125] | 220 | void bncRinex::resolveFileName(const QDateTime& datTim) {
|
---|
[82] | 221 |
|
---|
| 222 | QSettings settings;
|
---|
| 223 | QString path = settings.value("rnxPath").toString();
|
---|
| 224 | expandEnvVar(path);
|
---|
| 225 |
|
---|
[391] | 226 | if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {
|
---|
[82] | 227 | path += QDir::separator();
|
---|
| 228 | }
|
---|
| 229 |
|
---|
[127] | 230 | QString intStr = settings.value("rnxIntr").toString();
|
---|
| 231 | QString hlpStr;
|
---|
[129] | 232 |
|
---|
| 233 | QTime nextTime;
|
---|
| 234 | QDate nextDate;
|
---|
| 235 |
|
---|
[204] | 236 | int indHlp = intStr.indexOf("min");
|
---|
| 237 |
|
---|
| 238 | if ( indHlp != -1) {
|
---|
| 239 | int step = intStr.left(indHlp-1).toInt();
|
---|
[127] | 240 | char ch = 'A' + datTim.time().hour();
|
---|
| 241 | hlpStr = ch;
|
---|
[204] | 242 | if (datTim.time().minute() >= 60-step) {
|
---|
| 243 | hlpStr += QString("%1").arg(60-step, 2, 10, QChar('0'));
|
---|
[199] | 244 | if (datTim.time().hour() < 23) {
|
---|
| 245 | nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
|
---|
| 246 | nextDate = datTim.date();
|
---|
| 247 | }
|
---|
| 248 | else {
|
---|
| 249 | nextTime.setHMS(0, 0, 0);
|
---|
| 250 | nextDate = datTim.date().addDays(1);
|
---|
| 251 | }
|
---|
| 252 | }
|
---|
| 253 | else {
|
---|
[204] | 254 | for (int limit = step; limit <= 60-step; limit += step) {
|
---|
| 255 | if (datTim.time().minute() < limit) {
|
---|
| 256 | hlpStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));
|
---|
| 257 | nextTime.setHMS(datTim.time().hour(), limit, 0);
|
---|
| 258 | nextDate = datTim.date();
|
---|
| 259 | break;
|
---|
| 260 | }
|
---|
[199] | 261 | }
|
---|
| 262 | }
|
---|
| 263 | }
|
---|
[127] | 264 | else if (intStr == "1 hour") {
|
---|
| 265 | char ch = 'A' + datTim.time().hour();
|
---|
| 266 | hlpStr = ch;
|
---|
[129] | 267 | if (datTim.time().hour() < 23) {
|
---|
| 268 | nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);
|
---|
| 269 | nextDate = datTim.date();
|
---|
| 270 | }
|
---|
| 271 | else {
|
---|
| 272 | nextTime.setHMS(0, 0, 0);
|
---|
| 273 | nextDate = datTim.date().addDays(1);
|
---|
| 274 | }
|
---|
[127] | 275 | }
|
---|
| 276 | else {
|
---|
| 277 | hlpStr = "0";
|
---|
[129] | 278 | nextTime.setHMS(0, 0, 0);
|
---|
| 279 | nextDate = datTim.date().addDays(1);
|
---|
[127] | 280 | }
|
---|
[267] | 281 | _nextCloseEpoch = QDateTime(nextDate, nextTime);
|
---|
[82] | 282 |
|
---|
[183] | 283 | QString ID4 = _statID.left(4);
|
---|
| 284 |
|
---|
| 285 | // Check name conflict
|
---|
| 286 | // -------------------
|
---|
| 287 | QString distStr;
|
---|
| 288 | int num = 0;
|
---|
| 289 | QListIterator<QString> it(settings.value("mountPoints").toStringList());
|
---|
| 290 | while (it.hasNext()) {
|
---|
| 291 | QString mp = it.next();
|
---|
| 292 | if (mp.indexOf(ID4) != -1) {
|
---|
| 293 | ++num;
|
---|
| 294 | }
|
---|
| 295 | }
|
---|
| 296 | if (num > 1) {
|
---|
| 297 | distStr = "_" + _statID.mid(4);
|
---|
| 298 | }
|
---|
| 299 |
|
---|
[276] | 300 | QString sklExt = settings.value("rnxSkel").toString();
|
---|
| 301 | if (!sklExt.isEmpty()) {
|
---|
| 302 | _sklName = path + ID4 + distStr + "." + sklExt;
|
---|
| 303 | }
|
---|
| 304 |
|
---|
[183] | 305 | path += ID4 +
|
---|
[127] | 306 | QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +
|
---|
[276] | 307 | hlpStr + distStr + datTim.toString(".yyO");
|
---|
[82] | 308 |
|
---|
| 309 | _fName = path.toAscii();
|
---|
| 310 | }
|
---|
| 311 |
|
---|
[77] | 312 | // Write RINEX Header
|
---|
| 313 | ////////////////////////////////////////////////////////////////////////////
|
---|
[267] | 314 | void bncRinex::writeHeader(const QDateTime& datTim,
|
---|
| 315 | const QDateTime& datTimNom) {
|
---|
[77] | 316 |
|
---|
[356] | 317 | QSettings settings;
|
---|
| 318 |
|
---|
[77] | 319 | // Open the Output File
|
---|
| 320 | // --------------------
|
---|
[267] | 321 | resolveFileName(datTimNom);
|
---|
[260] | 322 |
|
---|
| 323 | // Append to existing file and return
|
---|
| 324 | // ----------------------------------
|
---|
| 325 | if ( QFile::exists(_fName) ) {
|
---|
[369] | 326 | if (_reconnectFlag ||
|
---|
| 327 | Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
|
---|
[260] | 328 | _out.open(_fName.data(), ios::app);
|
---|
| 329 | _out.setf(ios::showpoint | ios::fixed);
|
---|
| 330 | _headerWritten = true;
|
---|
[369] | 331 | _reconnectFlag = false;
|
---|
[260] | 332 | return;
|
---|
| 333 | }
|
---|
| 334 | }
|
---|
| 335 |
|
---|
[82] | 336 | _out.open(_fName.data());
|
---|
[85] | 337 | _out.setf(ios::showpoint | ios::fixed);
|
---|
[77] | 338 |
|
---|
[82] | 339 | // Copy Skeleton Header
|
---|
| 340 | // --------------------
|
---|
[276] | 341 | readSkeleton();
|
---|
[82] | 342 | if (_headerLines.size() > 0) {
|
---|
| 343 | QStringListIterator it(_headerLines);
|
---|
| 344 | while (it.hasNext()) {
|
---|
| 345 | QString line = it.next();
|
---|
[157] | 346 | if (line.indexOf("PGM / RUN BY / DATE") != -1) {
|
---|
[159] | 347 | QString hlp = QDate::currentDate().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[157] | 348 | _out << _pgmName.toAscii().data() << _userName.toAscii().data()
|
---|
| 349 | << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
|
---|
| 350 | }
|
---|
| 351 | else if (line.indexOf("# / TYPES OF OBSERV") != -1) {
|
---|
[367] | 352 | _out << " 8 C1 C2 P1 P2 L1 L2 S1 S2"
|
---|
| 353 | " # / TYPES OF OBSERV" << endl;
|
---|
[82] | 354 | }
|
---|
| 355 | else if (line.indexOf("TIME OF FIRST OBS") != -1) {
|
---|
[125] | 356 | _out << datTim.toString(" yyyy MM dd"
|
---|
| 357 | " hh mm ss.zzz0000").toAscii().data();
|
---|
| 358 | _out << " TIME OF FIRST OBS" << endl;
|
---|
[337] | 359 | QString hlp = (_format + QString(" %1").arg(_mountPoint.host() +
|
---|
| 360 | _mountPoint.path())).leftJustified(60, ' ', true);
|
---|
[156] | 361 | _out << hlp.toAscii().data() << "COMMENT" << endl;
|
---|
[82] | 362 | }
|
---|
| 363 | else {
|
---|
| 364 | _out << line.toAscii().data() << endl;
|
---|
| 365 | }
|
---|
| 366 | }
|
---|
| 367 | }
|
---|
[78] | 368 |
|
---|
[82] | 369 | // Write Dummy Header
|
---|
| 370 | // ------------------
|
---|
| 371 | else {
|
---|
| 372 | double approxPos[3]; approxPos[0] = approxPos[1] = approxPos[2] = 0.0;
|
---|
| 373 | double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0;
|
---|
| 374 |
|
---|
[366] | 375 | _out << " 2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl;
|
---|
[159] | 376 | QString hlp = QDate::currentDate().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
|
---|
[157] | 377 | _out << _pgmName.toAscii().data() << _userName.toAscii().data()
|
---|
| 378 | << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl;
|
---|
[86] | 379 | _out.setf(ios::left);
|
---|
[82] | 380 | _out << setw(60) << _statID.data() << "MARKER NAME" << endl;
|
---|
[354] | 381 | _out << setw(60) << "unknown unknown" << "OBSERVER / AGENCY" << endl;
|
---|
[82] | 382 | _out << setw(20) << "unknown"
|
---|
| 383 | << setw(20) << "unknown"
|
---|
| 384 | << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl;
|
---|
| 385 | _out << setw(20) << "unknown"
|
---|
| 386 | << setw(20) << "unknown"
|
---|
| 387 | << setw(20) << " " << "ANT # / TYPE" << endl;
|
---|
[86] | 388 | _out.unsetf(ios::left);
|
---|
[82] | 389 | _out << setw(14) << setprecision(4) << approxPos[0]
|
---|
| 390 | << setw(14) << setprecision(4) << approxPos[1]
|
---|
| 391 | << setw(14) << setprecision(4) << approxPos[2]
|
---|
| 392 | << " " << "APPROX POSITION XYZ" << endl;
|
---|
| 393 | _out << setw(14) << setprecision(4) << antennaNEU[0]
|
---|
| 394 | << setw(14) << setprecision(4) << antennaNEU[1]
|
---|
| 395 | << setw(14) << setprecision(4) << antennaNEU[2]
|
---|
| 396 | << " " << "ANTENNA: DELTA H/E/N" << endl;
|
---|
| 397 | _out << " 1 1 WAVELENGTH FACT L1/2" << endl;
|
---|
[367] | 398 | _out << " 8 C1 C2 P1 P2 L1 L2 S1 S2 # / TYPES OF OBSERV" << endl;
|
---|
[125] | 399 | _out << datTim.toString(" yyyy MM dd"
|
---|
| 400 | " hh mm ss.zzz0000").toAscii().data();
|
---|
| 401 | _out << " " << "TIME OF FIRST OBS" << endl;
|
---|
[337] | 402 | hlp = (_format + QString(" %1").arg(_mountPoint.host() +
|
---|
| 403 | _mountPoint.path())).leftJustified(60, ' ', true);
|
---|
[156] | 404 | _out << hlp.toAscii().data() << "COMMENT" << endl;
|
---|
[366] | 405 |
|
---|
[410] | 406 | if (_nmea == "yes") {
|
---|
| 407 | hlp = ("NMEA LAT=" + _latitude + " " + "LONG=" + _longitude).leftJustified(60, ' ',true);
|
---|
[366] | 408 | _out << hlp.toAscii().data() << "COMMENT" << endl; }
|
---|
| 409 |
|
---|
[82] | 410 | _out << " END OF HEADER" << endl;
|
---|
| 411 | }
|
---|
[78] | 412 |
|
---|
[77] | 413 | _headerWritten = true;
|
---|
| 414 | }
|
---|
| 415 |
|
---|
[73] | 416 | // Stores Observation into Internal Array
|
---|
| 417 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 418 | void bncRinex::deepCopy(const Observation* obs) {
|
---|
[74] | 419 | Observation* newObs = new Observation();
|
---|
| 420 | memcpy(newObs, obs, sizeof(*obs));
|
---|
| 421 | _obs.push_back(newObs);
|
---|
[73] | 422 | }
|
---|
| 423 |
|
---|
| 424 | // Write One Epoch into the RINEX File
|
---|
| 425 | ////////////////////////////////////////////////////////////////////////////
|
---|
[160] | 426 | void bncRinex::dumpEpoch(long maxTime) {
|
---|
[73] | 427 |
|
---|
[160] | 428 | // Select observations older than maxTime
|
---|
| 429 | // --------------------------------------
|
---|
| 430 | QList<Observation*> dumpList;
|
---|
| 431 | QMutableListIterator<Observation*> mIt(_obs);
|
---|
| 432 | while (mIt.hasNext()) {
|
---|
| 433 | Observation* ob = mIt.next();
|
---|
[238] | 434 | if (ob->GPSWeek * 7*24*3600 + ob->GPSWeeks < maxTime - 0.05) {
|
---|
[160] | 435 | dumpList.push_back(ob);
|
---|
| 436 | mIt.remove();
|
---|
| 437 | }
|
---|
| 438 | }
|
---|
| 439 |
|
---|
[75] | 440 | // Easy Return
|
---|
| 441 | // -----------
|
---|
[160] | 442 | if (dumpList.isEmpty()) {
|
---|
[75] | 443 | return;
|
---|
| 444 | }
|
---|
| 445 |
|
---|
| 446 | // Time of Epoch
|
---|
| 447 | // -------------
|
---|
[222] | 448 | Observation* fObs = *dumpList.begin();
|
---|
[267] | 449 | QDateTime datTim = dateAndTimeFromGPSweek(fObs->GPSWeek, fObs->GPSWeeks);
|
---|
| 450 | QDateTime datTimNom = dateAndTimeFromGPSweek(fObs->GPSWeek,
|
---|
| 451 | floor(fObs->GPSWeeks+0.5));
|
---|
[75] | 452 |
|
---|
[130] | 453 | // Close the file
|
---|
| 454 | // --------------
|
---|
[267] | 455 | if (_nextCloseEpoch.isValid() && datTimNom >= _nextCloseEpoch) {
|
---|
[130] | 456 | closeFile();
|
---|
| 457 | _headerWritten = false;
|
---|
| 458 | }
|
---|
| 459 |
|
---|
[78] | 460 | // Write RINEX Header
|
---|
| 461 | // ------------------
|
---|
| 462 | if (!_headerWritten) {
|
---|
[267] | 463 | writeHeader(datTim, datTimNom);
|
---|
[78] | 464 | }
|
---|
| 465 |
|
---|
[353] | 466 | double sec = double(datTim.time().second()) + fmod(fObs->GPSWeeks,1.0);
|
---|
| 467 | _out << datTim.toString(" yy MM dd hh mm ").toAscii().data()
|
---|
| 468 | << setw(10) << setprecision(7) << sec
|
---|
[160] | 469 | << " " << 0 << setw(3) << dumpList.size();
|
---|
[75] | 470 |
|
---|
[160] | 471 | QListIterator<Observation*> it(dumpList); int iSat = 0;
|
---|
[74] | 472 | while (it.hasNext()) {
|
---|
[75] | 473 | iSat++;
|
---|
| 474 | Observation* ob = it.next();
|
---|
[341] | 475 | _out << ob->satSys << setw(2) << ob->satNum;
|
---|
[75] | 476 | if (iSat == 12 && it.hasNext()) {
|
---|
[77] | 477 | _out << endl << " ";
|
---|
[75] | 478 | iSat = 0;
|
---|
| 479 | }
|
---|
[74] | 480 | }
|
---|
[77] | 481 | _out << endl;
|
---|
[75] | 482 |
|
---|
| 483 | it.toFront();
|
---|
| 484 | while (it.hasNext()) {
|
---|
| 485 | Observation* ob = it.next();
|
---|
[77] | 486 |
|
---|
| 487 | char lli = ' ';
|
---|
| 488 | char snr = ' ';
|
---|
| 489 | _out << setw(14) << setprecision(3) << ob->C1 << lli << snr;
|
---|
[366] | 490 | _out << setw(14) << setprecision(3) << ob->C2 << lli << snr;
|
---|
[225] | 491 | _out << setw(14) << setprecision(3) << ob->P1 << lli << snr;
|
---|
[77] | 492 | _out << setw(14) << setprecision(3) << ob->P2 << lli << snr;
|
---|
[324] | 493 | _out << setw(14) << setprecision(3) << ob->L1 << lli
|
---|
[366] | 494 | << setw(1) << ob->SNR1 << endl;
|
---|
[324] | 495 | _out << setw(14) << setprecision(3) << ob->L2 << lli
|
---|
| 496 | << setw(1) << ob->SNR2;
|
---|
[367] | 497 | _out << setw(14) << setprecision(3) << ob->S1 ;
|
---|
| 498 | _out << setw(16) << setprecision(3) << ob->S2 ;
|
---|
[77] | 499 | _out << endl;
|
---|
| 500 |
|
---|
[75] | 501 | delete ob;
|
---|
| 502 | }
|
---|
| 503 |
|
---|
[77] | 504 | _out.flush();
|
---|
[73] | 505 | }
|
---|
| 506 |
|
---|
[130] | 507 | // Close the Old RINEX File
|
---|
| 508 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 509 | void bncRinex::closeFile() {
|
---|
| 510 | _out.close();
|
---|
[132] | 511 | if (!_rnxScriptName.isEmpty()) {
|
---|
[417] | 512 | QProcess* cmd = new QProcess();
|
---|
| 513 | cmd->start(_rnxScriptName, QStringList() << _fName << "&");
|
---|
| 514 | cmd->waitForFinished(-1);
|
---|
| 515 | delete cmd;
|
---|
[411] | 516 | /// system( QString(_rnxScriptName + " " + _fName + " &").toAscii().data() );
|
---|
[132] | 517 | }
|
---|
[130] | 518 | }
|
---|