Changeset 4481 in ntrip
- Timestamp:
- Aug 3, 2012, 8:06:24 PM (12 years ago)
- Location:
- trunk/BNC/src
- Files:
-
- 6 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 -
trunk/BNC/src/bncrinex.h
r4406 r4481 30 30 31 31 #include "bncconst.h" 32 #include "rinex/rnxobsfile.h" 32 33 33 34 class t_obs; … … 66 67 void closeFile(); 67 68 t_irc downloadSkeleton(); 68 void writeObsTypes();69 69 70 70 QByteArray _statID; … … 72 72 QList<t_obs> _obs; 73 73 std::ofstream _out; 74 QStringList _headerLines;75 74 bool _headerWritten; 76 75 QDateTime _nextCloseEpoch; … … 87 86 QDate _skeletonDate; 88 87 int _rinexVers; 89 bool _reloadTable;90 bool _reloadDone;91 88 double _approxPos[3]; 92 89 int _samplingRate; … … 97 94 98 95 QMap<char, QVector<QString> > _rnxTypes; 96 97 t_rnxObsHeader _header; 99 98 }; 100 99 -
trunk/BNC/src/combination/bnccomb.cpp
r4183 r4481 37 37 const double sigObs = 0.05; 38 38 39 const int MAXPRN_GPS = 32;40 39 const int MAXPRN_GLONASS = 24; 41 40 -
trunk/BNC/src/rinex/reqcedit.cpp
r4364 r4481 180 180 txtMap["COMMENT"] = comment; 181 181 } 182 o utObsFile.writeHeader(&txtMap);182 obsFile->header().write(obsFile->stream(), &txtMap); 183 183 } 184 184 else { -
trunk/BNC/src/rinex/rnxobsfile.cpp
r4480 r4481 203 203 } 204 204 205 // Write Header 206 //////////////////////////////////////////////////////////////////////////// 207 void t_rnxObsHeader::write(QTextStream* stream, 208 const QMap<QString, QString>* txtMap) const { 209 210 bncApp* app = (bncApp*) qApp; 211 212 QString runBy = app->userName(); 213 QStringList comments; 214 215 if (txtMap) { 216 QMapIterator<QString, QString> it(*txtMap); 217 while (it.hasNext()) { 218 it.next(); 219 if (it.key() == "RUN BY") { 220 runBy = it.value(); 221 } 222 else if (it.key() == "COMMENT") { 223 comments = it.value().split("\\n", QString::SkipEmptyParts); 224 } 225 } 226 } 227 228 *stream << QString("%1 Observation data Mixed") 229 .arg(_version, 9, 'f', 2) 230 .leftJustified(60) 231 << "RINEX VERSION / TYPE\n"; 232 233 const QString fmtDate = (_version < 3.0) ? "dd-MMM-yy hh:mm" 234 : "yyyyMMdd hhmmss UTC"; 235 *stream << QString("%1%2%3") 236 .arg(app->pgmName(), -20) 237 .arg(runBy.trimmed().left(20), -20) 238 .arg(QDateTime::currentDateTime().toUTC().toString(fmtDate), -20) 239 .leftJustified(60) 240 << "PGM / RUN BY / DATE\n"; 241 242 QStringListIterator itCmnt(comments); 243 while (itCmnt.hasNext()) { 244 *stream << itCmnt.next().trimmed().left(60).leftJustified(60) << "COMMENT\n"; 245 } 246 247 *stream << QString("%1") 248 .arg(_markerName, -60) 249 .leftJustified(60) 250 << "MARKER NAME\n"; 251 252 if (!_markerNumber.isEmpty()) { 253 *stream << QString("%1") 254 .arg(_markerNumber, -20) 255 .leftJustified(60) 256 << "MARKER NUMBER\n"; 257 } 258 259 *stream << QString("%1%2") 260 .arg(_observer, -20) 261 .arg(_agency, -40) 262 .leftJustified(60) 263 << "OBSERVER / AGENCY\n"; 264 265 *stream << QString("%1%2%3") 266 .arg(_receiverNumber, -20) 267 .arg(_receiverType, -20) 268 .arg(_receiverVersion, -20) 269 .leftJustified(60) 270 << "REC # / TYPE / VERS\n"; 271 272 *stream << QString("%1%2") 273 .arg(_antennaNumber, -20) 274 .arg(_antennaName, -20) 275 .leftJustified(60) 276 << "ANT # / TYPE\n"; 277 278 *stream << QString("%1%2%3") 279 .arg(_xyz(1), 14, 'f', 4) 280 .arg(_xyz(2), 14, 'f', 4) 281 .arg(_xyz(3), 14, 'f', 4) 282 .leftJustified(60) 283 << "APPROX POSITION XYZ\n"; 284 285 *stream << QString("%1%2%3") 286 .arg(_antNEU(3), 14, 'f', 4) 287 .arg(_antNEU(2), 14, 'f', 4) 288 .arg(_antNEU(1), 14, 'f', 4) 289 .leftJustified(60) 290 << "ANTENNA: DELTA H/E/N\n"; 291 292 if (_version < 3.0) { 293 int defaultWlFact1 = _wlFactorsL1[1]; 294 int defaultWlFact2 = _wlFactorsL2[1]; // TODO check all prns 295 *stream << QString("%1%2") 296 .arg(defaultWlFact1, 6) 297 .arg(defaultWlFact2, 6) 298 .leftJustified(60) 299 << "WAVELENGTH FACT L1/2\n"; 300 } 301 302 *stream << obsTypesStrings().join(""); 303 304 *stream << QString("%1") 305 .arg(_interval, 10, 'f', 3) 306 .leftJustified(60) 307 << "INTERVAL\n"; 308 309 unsigned year, month, day, hour, min; 310 double sec; 311 _startTime.civil_date(year, month, day); 312 _startTime.civil_time(hour, min, sec); 313 *stream << QString("%1%2%3%4%5%6%7") 314 .arg(year, 6) 315 .arg(month, 6) 316 .arg(day, 6) 317 .arg(hour, 6) 318 .arg(min, 6) 319 .arg(sec, 13, 'f', 7) 320 .arg("GPS", 8) 321 .leftJustified(60) 322 << "TIME OF FIRST OBS\n"; 323 324 *stream << QString() 325 .leftJustified(60) 326 << "END OF HEADER\n"; 327 } 328 205 329 // Number of Observation Types (satellite-system specific) 206 330 //////////////////////////////////////////////////////////////////////////// … … 233 357 } 234 358 } 359 } 360 361 // Write Observation Types 362 //////////////////////////////////////////////////////////////////////////// 363 QStringList t_rnxObsHeader::obsTypesStrings() const { 364 365 QStringList strList; 366 367 if (_version < 3.0) { 368 QString hlp; 369 QTextStream(&hlp) << QString("%1").arg(_obsTypesV2.size(), 6); 370 for (int ii = 0; ii < _obsTypesV2.size(); ii++) { 371 QTextStream(&hlp) << QString("%1").arg(_obsTypesV2[ii], 6); 372 if ((ii+1) % 9 == 0 || ii == _obsTypesV2.size()-1) { 373 strList.append(hlp.leftJustified(60) + "# / TYPES OF OBSERV\n"); 374 hlp = QString().leftJustified(6); 375 } 376 } 377 } 378 else { 379 QMapIterator<char, QVector<QString> > it(_obsTypesV3); 380 while (it.hasNext()) { 381 it.next(); 382 char sys = it.key(); 383 const QVector<QString>& types = it.value(); 384 QString hlp; 385 QTextStream(&hlp) << QString("%1 %2").arg(sys).arg(types.size(), 3); 386 for (int ii = 0; ii < types.size(); ii++) { 387 QTextStream(&hlp) << QString(" %1").arg(types[ii], -3); 388 if ((ii+1) % 13 == 0 || ii == types.size()-1) { 389 strList.append(hlp.leftJustified(60) + "SYS / # / OBS TYPES\n"); 390 hlp = QString().leftJustified(6); 391 } 392 } 393 } 394 } 395 396 return strList; 235 397 } 236 398 … … 643 805 } 644 806 645 // Write Header646 ////////////////////////////////////////////////////////////////////////////647 void t_rnxObsFile::writeHeader(const QMap<QString, QString>* txtMap) {648 649 bncApp* app = (bncApp*) qApp;650 651 QString runBy = app->userName();652 QStringList comments;653 654 if (txtMap) {655 QMapIterator<QString, QString> it(*txtMap);656 while (it.hasNext()) {657 it.next();658 if (it.key() == "RUN BY") {659 runBy = it.value();660 }661 else if (it.key() == "COMMENT") {662 comments = it.value().split("\\n", QString::SkipEmptyParts);663 }664 }665 }666 667 *_stream << QString("%1 Observation data Mixed")668 .arg(_header._version, 9, 'f', 2)669 .leftJustified(60)670 << "RINEX VERSION / TYPE\n";671 672 const QString fmtDate = (version() < 3.0) ? "dd-MMM-yy hh:mm"673 : "yyyyMMdd hhmmss UTC";674 *_stream << QString("%1%2%3")675 .arg(app->pgmName(), -20)676 .arg(runBy.trimmed().left(20), -20)677 .arg(QDateTime::currentDateTime().toUTC().toString(fmtDate), -20)678 .leftJustified(60)679 << "PGM / RUN BY / DATE\n";680 681 QStringListIterator itCmnt(comments);682 while (itCmnt.hasNext()) {683 *_stream << itCmnt.next().trimmed().left(60).leftJustified(60) << "COMMENT\n";684 }685 686 *_stream << QString("%1")687 .arg(_header._markerName, -60)688 .leftJustified(60)689 << "MARKER NAME\n";690 691 if (!_header._markerNumber.isEmpty()) {692 *_stream << QString("%1")693 .arg(_header._markerNumber, -20)694 .leftJustified(60)695 << "MARKER NUMBER\n";696 }697 698 *_stream << QString("%1%2")699 .arg(_header._observer, -20)700 .arg(_header._agency, -40)701 .leftJustified(60)702 << "OBSERVER / AGENCY\n";703 704 *_stream << QString("%1%2%3")705 .arg(_header._receiverNumber, -20)706 .arg(_header._receiverType, -20)707 .arg(_header._receiverVersion, -20)708 .leftJustified(60)709 << "REC # / TYPE / VERS\n";710 711 *_stream << QString("%1%2")712 .arg(_header._antennaNumber, -20)713 .arg(_header._antennaName, -20)714 .leftJustified(60)715 << "ANT # / TYPE\n";716 717 *_stream << QString("%1%2%3")718 .arg(_header._xyz(1), 14, 'f', 4)719 .arg(_header._xyz(2), 14, 'f', 4)720 .arg(_header._xyz(3), 14, 'f', 4)721 .leftJustified(60)722 << "APPROX POSITION XYZ\n";723 724 *_stream << QString("%1%2%3")725 .arg(_header._antNEU(3), 14, 'f', 4)726 .arg(_header._antNEU(2), 14, 'f', 4)727 .arg(_header._antNEU(1), 14, 'f', 4)728 .leftJustified(60)729 << "ANTENNA: DELTA H/E/N\n";730 731 if (_header._version < 3.0) {732 int defaultWlFact1 = _header._wlFactorsL1[1];733 int defaultWlFact2 = _header._wlFactorsL2[1]; // TODO check all prns734 *_stream << QString("%1%2")735 .arg(defaultWlFact1, 6)736 .arg(defaultWlFact2, 6)737 .leftJustified(60)738 << "WAVELENGTH FACT L1/2\n";739 }740 741 *_stream << obsTypesStrings().join("");742 743 *_stream << QString("%1")744 .arg(_header._interval, 10, 'f', 3)745 .leftJustified(60)746 << "INTERVAL\n";747 748 unsigned year, month, day, hour, min;749 double sec;750 _header._startTime.civil_date(year, month, day);751 _header._startTime.civil_time(hour, min, sec);752 *_stream << QString("%1%2%3%4%5%6%7")753 .arg(year, 6)754 .arg(month, 6)755 .arg(day, 6)756 .arg(hour, 6)757 .arg(min, 6)758 .arg(sec, 13, 'f', 7)759 .arg("GPS", 8)760 .leftJustified(60)761 << "TIME OF FIRST OBS\n";762 763 *_stream << QString()764 .leftJustified(60)765 << "END OF HEADER\n";766 }767 768 // Write Observation Types769 ////////////////////////////////////////////////////////////////////////////770 QStringList t_rnxObsFile::obsTypesStrings() {771 772 QStringList strList;773 774 if (_header._version < 3.0) {775 QString hlp;776 QTextStream(&hlp) << QString("%1").arg(_header._obsTypesV2.size(), 6);777 for (int ii = 0; ii < _header._obsTypesV2.size(); ii++) {778 QTextStream(&hlp) << QString("%1").arg(_header._obsTypesV2[ii], 6);779 if ((ii+1) % 9 == 0 || ii == _header._obsTypesV2.size()-1) {780 strList.append(hlp.leftJustified(60) + "# / TYPES OF OBSERV\n");781 hlp = QString().leftJustified(6);782 }783 }784 }785 else {786 QMapIterator<char, QVector<QString> > it(_header._obsTypesV3);787 while (it.hasNext()) {788 it.next();789 char sys = it.key();790 const QVector<QString>& types = it.value();791 QString hlp;792 QTextStream(&hlp) << QString("%1 %2").arg(sys).arg(types.size(), 3);793 for (int ii = 0; ii < types.size(); ii++) {794 QTextStream(&hlp) << QString(" %1").arg(types[ii], -3);795 if ((ii+1) % 13 == 0 || ii == types.size()-1) {796 strList.append(hlp.leftJustified(60) + "SYS / # / OBS TYPES\n");797 hlp = QString().leftJustified(6);798 }799 }800 }801 }802 803 return strList;804 }805 806 807 // Write Data Epoch 807 808 //////////////////////////////////////////////////////////////////////////// … … 1068 1069 1069 1070 if (!same) { 1070 QStringList strLst = obsTypesStrings();1071 QStringList strLst = _header.obsTypesStrings(); 1071 1072 int numBlanks = _header._version < 3.0 ? 26 : 29; 1072 1073 *_stream << QString().leftJustified(numBlanks) -
trunk/BNC/src/rinex/rnxobsfile.h
r4480 r4481 46 46 int nTypes(char sys) const; 47 47 const QString& obsType(char sys, int index) const; 48 QStringList obsTypesStrings() const; 49 void write(QTextStream* stream, 50 const QMap<QString, QString>* txtMap = 0) const; 48 51 49 52 static const QString _emptyStr; … … 134 137 void setHeader(const t_rnxObsHeader& header, double version); 135 138 void checkNewHeader(const t_rnxObsHeader& header); 136 void writeHeader(const QMap<QString, QString>* txtMap = 0);137 QStringList obsTypesStrings();138 139 void writeEpoch(const t_rnxEpo* epo); 140 141 QTextStream* stream() {return _stream;} 139 142 140 143 private:
Note:
See TracChangeset
for help on using the changeset viewer.