Changeset 4481 in ntrip for trunk/BNC/src/bncrinex.cpp
- Timestamp:
- Aug 3, 2012, 8:06:24 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bncrinex.cpp
r4479 r4481 77 77 _headerWritten = false; 78 78 _reconnectFlag = false; 79 _reloadTable = false;80 _reloadDone = false;81 79 82 80 bncSettings settings; … … 155 153 QStringList table; 156 154 bncTableDlg::getFullTable(_ntripVersion, _mountPoint.host(), 157 _mountPoint.port(), table, _reloadTable);155 _mountPoint.port(), table, true); 158 156 QString net; 159 157 QStringListIterator it(table); … … 206 204 query->waitForRequestResult(url, outData); 207 205 if (query->status() == bncNetQuery::finished) { 208 _headerLines.clear(); 209 bool firstLineRead = false; 206 irc = success; 210 207 QTextStream in(outData); 211 QString line = in.readLine(); 212 while ( !line.isNull() ) { 213 if (line.indexOf("MARKER NAME") != -1) { 214 irc = success; 215 } 216 if (line.indexOf("RINEX VERSION") != -1) { 217 if (_rinexVers == 3) { 218 _headerLines.append(" 3.00 OBSERVATION DATA" 219 " M (MIXED)" 220 " RINEX VERSION / TYPE"); 221 } 222 else { 223 _headerLines.append(" 2.11 OBSERVATION DATA" 224 " M (MIXED)" 225 " RINEX VERSION / TYPE"); 226 } 227 _headerLines.append("PGM / RUN BY / DATE"); 228 firstLineRead = true; 229 } 230 else if (firstLineRead) { 231 if (line.indexOf("END OF HEADER") != -1) { 232 _headerLines.append("# / TYPES OF OBSERV"); 233 if (_rinexVers == 2) { 234 _headerLines.append( 235 QString(" 1 1").leftJustified(60, ' ', true) + 236 "WAVELENGTH FACT L1/2"); 237 } 238 _headerLines.append("TIME OF FIRST OBS"); 239 _headerLines.append( line ); 240 break; 241 } 242 else { 243 _headerLines.append( line ); 244 } 245 } 246 line = in.readLine(); 247 } 248 } 249 else { 250 delete query; 251 return failure; 252 } 208 _header.read(&in); 209 } 210 253 211 delete query; 254 212 } … … 265 223 QFile skl(_sklName); 266 224 if ( skl.exists() && skl.open(QIODevice::ReadOnly) ) { 267 _headerLines.clear();268 225 QTextStream in(&skl); 269 while ( !in.atEnd() ) { 270 _headerLines.append( in.readLine() ); 271 if (_headerLines.last().indexOf("END OF HEADER") != -1) { 272 break; 273 } 274 } 226 _header.read(&in); 275 227 } 276 228 … … 281 233 QDate currDate = currentDateAndTimeGPS().date(); 282 234 if ( !_skeletonDate.isValid() || _skeletonDate != currDate ) { 283 if ( downloadSkeleton() == success) { 284 _skeletonDate = currDate; 285 _reloadDone = false; 286 } 287 else { 288 if(!_reloadDone) { 289 _reloadTable = true; 290 if ( downloadSkeleton() == success) { 291 _skeletonDate = currDate; 292 } 293 _reloadTable = false; 294 _reloadDone = true; 295 } 296 } 235 downloadSkeleton(); 236 _skeletonDate = currDate; 297 237 } 298 238 } … … 436 376 // -------------------- 437 377 readSkeleton(); 438 if (_headerLines.size() > 0) { 439 bool typesOfObservationsWritten = false; 440 QStringListIterator it(_headerLines); 441 while (it.hasNext()) { 442 QString line = it.next(); 443 if (line.indexOf("PGM / RUN BY / DATE") != -1) { 444 if (_rinexVers == 3) { 445 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true); 446 _out << _pgmName.toAscii().data() << _userName.toAscii().data() 447 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl; 448 } 449 else { 450 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true); 451 _out << _pgmName.toAscii().data() << _userName.toAscii().data() 452 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl; 453 } 454 } 455 else if ( !typesOfObservationsWritten && 456 (line.indexOf("# / TYPES OF OBSERV") != -1 || 457 line.indexOf("SYS / # / OBS TYPES") != -1) ) { 458 typesOfObservationsWritten = true; 459 writeObsTypes(); 460 } 461 else if (line.indexOf("TIME OF FIRST OBS") != -1) { 462 _out << datTim.toString(" yyyy MM dd" 463 " hh mm ss.zzz0000").toAscii().data(); 464 _out << " GPS TIME OF FIRST OBS" << endl; 465 QString hlp = (format.left(6) + QString(" %1").arg(_mountPoint.host() + 466 _mountPoint.path())).leftJustified(60, ' ', true); 467 _out << hlp.toAscii().data() << "COMMENT" << endl; 468 } 469 else if (line.indexOf("MARKER NAME") != -1) { 470 if (_rinexVers == 3) { 471 _out << line.toAscii().data() << endl; 472 _out << setw(71) << "GEODETIC MARKER TYPE" << endl; 473 } 474 else { 475 _out << line.toAscii().data() << endl; 476 } 477 } 478 else if (line.indexOf("END OF HEADER") != -1) { 479 if (!typesOfObservationsWritten) { 480 writeObsTypes(); 481 } 482 _out << line.toAscii().data() << endl; 483 break; 484 } 485 else { 486 _out << line.toAscii().data() << endl; 487 } 488 } 489 } 490 491 // Write Dummy Header 492 // ------------------ 493 else { 494 double antennaNEU[3]; antennaNEU[0] = antennaNEU[1] = antennaNEU[2] = 0.0; 495 496 if (_rinexVers == 3) { 497 _out << " 3.00 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl; 498 QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true); 499 _out << _pgmName.toAscii().data() << _userName.toAscii().data() 500 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl; 501 } 502 else { 503 _out << " 2.11 OBSERVATION DATA M (MIXED) RINEX VERSION / TYPE" << endl; 504 QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true); 505 _out << _pgmName.toAscii().data() << _userName.toAscii().data() 506 << hlp.toAscii().data() << "PGM / RUN BY / DATE" << endl; 507 } 508 _out.setf(ios::left); 509 _out << setw(60) << _statID.data() << "MARKER NAME" << endl; 510 if (_rinexVers == 3) { 511 _out << setw(60) << "unknown" << "MARKER TYPE " << endl; 512 } 513 _out << setw(60) << "unknown unknown" << "OBSERVER / AGENCY" << endl; 514 _out << setw(20) << "unknown" 515 << setw(20) << "unknown" 516 << setw(20) << "unknown" << "REC # / TYPE / VERS" << endl; 517 _out << setw(20) << "unknown" 518 << setw(20) << "unknown" 519 << setw(20) << " " << "ANT # / TYPE" << endl; 520 _out.unsetf(ios::left); 521 _out << setw(14) << setprecision(4) << _approxPos[0] 522 << setw(14) << setprecision(4) << _approxPos[1] 523 << setw(14) << setprecision(4) << _approxPos[2] 524 << " " << "APPROX POSITION XYZ" << endl; 525 _out << setw(14) << setprecision(4) << antennaNEU[0] 526 << setw(14) << setprecision(4) << antennaNEU[1] 527 << setw(14) << setprecision(4) << antennaNEU[2] 528 << " " << "ANTENNA: DELTA H/E/N" << endl; 529 530 writeObsTypes(); 531 532 _out << datTim.toString(" yyyy MM dd" 533 " hh mm ss.zzz0000").toAscii().data(); 534 _out << " GPS TIME OF FIRST OBS" << endl; 535 QString hlp = (format.left(6) + QString(" %1").arg(_mountPoint.host() + 536 _mountPoint.path())).leftJustified(60, ' ', true); 537 _out << hlp.toAscii().data() << "COMMENT" << endl; 538 539 if (_nmea == "yes") { 540 hlp = ("NMEA LAT=" + _latitude + " " + "LONG=" + _longitude).leftJustified(60, ' ',true); 541 _out << hlp.toAscii().data() << "COMMENT" << endl; } 542 543 _out << " END OF HEADER" << endl; 544 } 378 379 QByteArray headerLines; 380 QTextStream outHlp(&headerLines); 381 _header.write(&outHlp); 382 outHlp.flush(); 383 _out << headerLines.data(); 545 384 546 385 _headerWritten = true; 547 }548 549 //550 ////////////////////////////////////////////////////////////////////////////551 void bncRinex::writeObsTypes() {552 if (_rinexVers == 3) {553 QMapIterator<char, QVector<QString> > it(_rnxTypes);554 while (it.hasNext()) {555 it.next();556 char sys = it.key();557 const QVector<QString>& types = it.value();558 QString hlp;559 QTextStream(&hlp) << QString("%1 %2").arg(sys).arg(types.size(), 3);560 for (int ii = 0; ii < types.size(); ii++) {561 QTextStream(&hlp) << QString(" %1").arg(types[ii], -3);562 if ((ii+1) % 13 == 0 || ii == types.size()-1) {563 _out << QString(hlp.leftJustified(60) + "SYS / # / OBS TYPES\n").toAscii().data();564 hlp = QString().leftJustified(6);565 }566 }567 }568 }569 else {570 _out << " 1 1 WAVELENGTH FACT L1/2" << endl;571 _out << " 8 C1 P1 L1 S1 C2 P2 L2 S2 # / TYPES OF OBSERV" << endl;572 }573 386 } 574 387
Note:
See TracChangeset
for help on using the changeset viewer.