Changeset 3718 in ntrip for trunk/BNC/rinex
- Timestamp:
- Feb 23, 2012, 6:43:00 PM (13 years ago)
- Location:
- trunk/BNC/rinex
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/rinex/rnxobsfile.cpp
r3716 r3718 47 47 using namespace std; 48 48 49 const string t_rnxObsFile::t_rnxObsHeader::_emptyStr;49 const QString t_rnxObsFile::t_rnxObsHeader::_emptyStr; 50 50 51 51 // Constructor … … 71 71 // Read Header 72 72 //////////////////////////////////////////////////////////////////////////// 73 t_irc t_rnxObsFile::t_rnxObsHeader::read( ifstream* stream, int maxLines) {73 t_irc t_rnxObsFile::t_rnxObsHeader::read(QTextStream* stream, int maxLines) { 74 74 int numLines = 0; 75 while ( stream->good() ) { 76 string line; 77 getline(*stream, line); ++numLines; 78 if (line.empty()) { 75 while ( stream->status() == QTextStream::Ok && !stream->atEnd() ) { 76 QString line = stream->readLine(); ++ numLines; 77 if (line.isEmpty()) { 79 78 continue; 80 79 } 81 if (line. find("END OF FILE") != string::npos) {80 if (line.indexOf("END OF FILE") != -1) { 82 81 break; 83 82 } 84 string value = line.substr(0,60); stripWhiteSpace(value);85 string key = line.substr(60); stripWhiteSpace(key);83 QString value = line.mid(0,60).trimmed(); 84 QString key = line.mid(60).trimmed(); 86 85 if (key == "END OF HEADER") { 87 86 break; 88 87 } 89 88 else if (key == "RINEX VERSION / TYPE") { 90 istringstream in(value);89 QTextStream in(value.toAscii(), QIODevice::ReadOnly); 91 90 in >> _version; 92 91 } … … 95 94 } 96 95 else if (key == "ANT # / TYPE") { 97 _antennaName = line. substr(20,20); stripWhiteSpace(_antennaName);96 _antennaName = line.mid(20,20).trimmed(); 98 97 } 99 98 else if (key == "INTERVAL") { 100 istringstream in(value);99 QTextStream in(value.toAscii(), QIODevice::ReadOnly); 101 100 in >> _interval; 102 101 } 103 102 else if (key == "WAVELENGTH FACT L1/2") { 104 istringstream in(value);103 QTextStream in(value.toAscii(), QIODevice::ReadOnly); 105 104 int wlFactL1 = 0; 106 105 int wlFactL2 = 0; … … 115 114 else { 116 115 for (int ii = 0; ii < numSat; ii++) { 117 string prn; in >> prn;116 QString prn; in >> prn; 118 117 if (prn[0] == 'G') { 119 118 int iPrn; … … 126 125 } 127 126 else if (key == "APPROX POSITION XYZ") { 128 istringstream in(value);127 QTextStream in(value.toAscii(), QIODevice::ReadOnly); 129 128 in >> _xyz[0] >> _xyz[1] >> _xyz[2]; 130 129 } 131 130 else if (key == "ANTENNA: DELTA H/E/N") { 132 istringstream in(value);131 QTextStream in(value.toAscii(), QIODevice::ReadOnly); 133 132 in >> _antNEU[2] >> _antNEU[1] >> _antNEU[0]; 134 133 } 135 134 else if (key == "ANTENNA: DELTA X/Y/Z") { 136 istringstream in(value);135 QTextStream in(value.toAscii(), QIODevice::ReadOnly); 137 136 in >> _antXYZ[0] >> _antXYZ[1] >> _antXYZ[2]; 138 137 } 139 138 else if (key == "ANTENNA: B.SIGHT XYZ") { 140 istringstream in(value);139 QTextStream in(value.toAscii(), QIODevice::ReadOnly); 141 140 in >> _antBSG[0] >> _antBSG[1] >> _antBSG[2]; 142 141 } 143 142 else if (key == "# / TYPES OF OBSERV") { 144 istringstream in(value);143 QTextStream in(value.toAscii(), QIODevice::ReadOnly); 145 144 int nTypes; 146 145 in >> nTypes; 147 146 _obsTypesV2.clear(); 148 147 for (int ii = 0; ii < nTypes; ii++) { 149 string hlp;148 QString hlp; 150 149 in >> hlp; 151 150 _obsTypesV2.push_back(hlp); … … 153 152 } 154 153 else if (key == "SYS / # / OBS TYPES") { 155 istringstream* in = new istringstream(value);154 QTextStream* in = new QTextStream(value.toAscii(), QIODevice::ReadOnly); 156 155 char sys; 157 156 int nTypes; … … 160 159 for (int ii = 0; ii < nTypes; ii++) { 161 160 if (ii > 0 && ii % 13 == 0) { 162 getline(*stream, line);++numLines;161 line = stream->readLine(); ++numLines; 163 162 delete in; 164 in = new istringstream(line);165 } 166 string hlp;163 in = new QTextStream(line.toAscii(), QIODevice::ReadOnly); 164 } 165 QString hlp; 167 166 *in >> hlp; 168 167 _obsTypesV3[sys].push_back(hlp); … … 185 184 } 186 185 else { 187 map<char, vector< string> >::const_iterator it = _obsTypesV3.find(sys);186 map<char, vector<QString> >::const_iterator it = _obsTypesV3.find(sys); 188 187 if (it != _obsTypesV3.end()) { 189 188 return it->second.size(); … … 197 196 // Observation Type (satellite-system specific) 198 197 //////////////////////////////////////////////////////////////////////////// 199 const string& t_rnxObsFile::t_rnxObsHeader::obsType(char sys, int index) const {198 const QString& t_rnxObsFile::t_rnxObsHeader::obsType(char sys, int index) const { 200 199 if (_version < 3.0) { 201 200 return _obsTypesV2.at(index); 202 201 } 203 202 else { 204 map<char, vector< string> >::const_iterator it = _obsTypesV3.find(sys);203 map<char, vector<QString> >::const_iterator it = _obsTypesV3.find(sys); 205 204 if (it != _obsTypesV3.end()) { 206 205 return it->second.at(index); … … 214 213 // Constructor 215 214 //////////////////////////////////////////////////////////////////////////// 216 t_rnxObsFile::t_rnxObsFile(const string& fileName) {215 t_rnxObsFile::t_rnxObsFile(const QString& fileName) { 217 216 _stream = 0; 218 217 _flgPowerFail = false; … … 222 221 // Open 223 222 //////////////////////////////////////////////////////////////////////////// 224 void t_rnxObsFile::open(const string& fileName) { 225 _stream = new ifstream(expandEnvVar(fileName).c_str()); 223 void t_rnxObsFile::open(const QString& fileName) { 224 225 _fileName = fileName; expandEnvVar(_fileName); 226 _file = new QFile(_fileName); 227 _file->open(QIODevice::ReadOnly | QIODevice::Text); 228 _stream = new QTextStream(); 229 _stream->setDevice(_file); 230 226 231 _header.read(_stream); 227 232 … … 233 238 const t_rnxEpo* rnxEpo = nextEpoch(); 234 239 if (!rnxEpo) { 235 throw string("t_rnxObsFile: not enough epochs");240 throw QString("t_rnxObsFile: not enough epochs"); 236 241 } 237 242 if (iEpo > 0) { … … 259 264 void t_rnxObsFile::close() { 260 265 delete _stream; _stream = 0; 266 delete _file; _file = 0; 261 267 } 262 268 263 269 // Handle Special Epoch Flag 264 270 //////////////////////////////////////////////////////////////////////////// 265 void t_rnxObsFile::handleEpochFlag(int flag, const string& line) {271 void t_rnxObsFile::handleEpochFlag(int flag, const QString& line) { 266 272 267 273 // Power Failure … … 293 299 // -------------- 294 300 else { 295 throw string("t_rnxObsFile: unhandled flag\n" + line);301 throw QString("t_rnxObsFile: unhandled flag\n" + line); 296 302 } 297 303 } … … 315 321 const t_rnxObsFile::t_rnxEpo* t_rnxObsFile::nextEpochV3() { 316 322 317 while ( _stream->good() ) { 318 319 string line; 320 321 getline(*_stream, line); 322 323 if (line.empty()) { 323 while ( _stream->->status() == QTextStream::Ok && !_stream->atEnd() ) { 324 325 QString line = _stream->readLine(); 326 327 if (line.isEmpty()) { 324 328 continue; 325 329 } … … 332 336 } 333 337 334 istringstream in(line.substr(1));338 QTextStream in(line.mid(1).toAscii(), QIODevice::ReadOnly); 335 339 336 340 // Epoch Time … … 351 355 // ------------ 352 356 for (int iSat = 0; iSat < numSat; iSat++) { 353 getline(*_stream, line);357 line = _stream->readLine(); 354 358 _currEpo.rnxSat[iSat].satSys = line[0]; 355 359 readInt(line, 1, 2, _currEpo.rnxSat[iSat].satNum); … … 386 390 const t_rnxObsFile::t_rnxEpo* t_rnxObsFile::nextEpochV2() { 387 391 388 while ( _stream->good() ) { 389 390 string line; 391 392 getline(*_stream, line); 393 394 if (line.empty()) { 392 while ( _stream->->status() == QTextStream::Ok && !_stream->atEnd() ) { 393 394 QString line = _stream->readLine(); 395 396 if (line.isEmpty()) { 395 397 continue; 396 398 } … … 403 405 } 404 406 405 istringstream in(line);407 QTextStream in(line.toAscii(), QIODevice::ReadOnly); 406 408 407 409 // Epoch Time … … 430 432 for (int iSat = 0; iSat < numSat; iSat++) { 431 433 if (iSat > 0 && iSat % 12 == 0) { 432 getline(*_stream, line);434 line = _stream->readLine(); 433 435 pos = 32; 434 436 } … … 443 445 // ------------------------ 444 446 for (int iSat = 0; iSat < numSat; iSat++) { 445 getline(*_stream, line);447 line = _stream->readLine(); 446 448 pos = 0; 447 449 for (int iType = 0; iType < _header.nTypes(_currEpo.rnxSat[iSat].satSys); iType++) { 448 450 if (iType > 0 && iType % 5 == 0) { 449 getline(*_stream, line);451 line = _stream->readLine(); 450 452 pos = 0; 451 453 } -
trunk/BNC/rinex/rnxobsfile.h
r3717 r3718 26 26 #define RNXOBSFILE_H 27 27 28 #include <Q String>28 #include <QtCore> 29 29 30 30 #include <fstream> … … 92 92 ~t_rnxObsHeader(); 93 93 94 t_irc read( std::ifstream* stream, int maxLines = 0);94 t_irc read(QTextStream* stream, int maxLines = 0); 95 95 int nTypes(char sys) const; 96 96 const QString& obsType(char sys, int index) const; … … 115 115 void handleEpochFlag(int flag, const QString& line); 116 116 117 QFile* _file; 117 118 QString _fileName; 119 QTextStream* _stream; 118 120 t_rnxObsHeader _header; 119 std::ifstream* _stream;120 121 t_rnxEpo _currEpo; 121 122 bool _flgPowerFail;
Note:
See TracChangeset
for help on using the changeset viewer.