Changeset 4481 in ntrip for trunk/BNC/src/rinex/rnxobsfile.cpp
- Timestamp:
- Aug 3, 2012, 8:06:24 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note:
See TracChangeset
for help on using the changeset viewer.