Changeset 3718 in ntrip for trunk/BNC/rinex


Ignore:
Timestamp:
Feb 23, 2012, 6:43:00 PM (13 years ago)
Author:
mervart
Message:
 
Location:
trunk/BNC/rinex
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/rinex/rnxobsfile.cpp

    r3716 r3718  
    4747using namespace std;
    4848
    49 const string t_rnxObsFile::t_rnxObsHeader::_emptyStr;
     49const QString t_rnxObsFile::t_rnxObsHeader::_emptyStr;
    5050
    5151// Constructor
     
    7171// Read Header
    7272////////////////////////////////////////////////////////////////////////////
    73 t_irc t_rnxObsFile::t_rnxObsHeader::read(ifstream* stream, int maxLines) {
     73t_irc t_rnxObsFile::t_rnxObsHeader::read(QTextStream* stream, int maxLines) {
    7474  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()) {
    7978      continue;
    8079    }
    81     if (line.find("END OF FILE") != string::npos) {
     80    if (line.indexOf("END OF FILE") != -1) {
    8281      break;
    8382    }
    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();
    8685    if      (key == "END OF HEADER") {
    8786      break;
    8887    }
    8988    else if (key == "RINEX VERSION / TYPE") {
    90       istringstream in(value);
     89      QTextStream in(value.toAscii(), QIODevice::ReadOnly);
    9190      in >> _version;
    9291    }
     
    9594    }
    9695    else if (key == "ANT # / TYPE") {
    97       _antennaName = line.substr(20,20); stripWhiteSpace(_antennaName);
     96      _antennaName = line.mid(20,20).trimmed();
    9897    }
    9998    else if (key == "INTERVAL") {
    100       istringstream in(value);
     99      QTextStream in(value.toAscii(), QIODevice::ReadOnly);
    101100      in >> _interval;
    102101    }
    103102    else if (key == "WAVELENGTH FACT L1/2") {
    104       istringstream in(value);
     103      QTextStream in(value.toAscii(), QIODevice::ReadOnly);
    105104      int wlFactL1 = 0;
    106105      int wlFactL2 = 0;
     
    115114      else {
    116115        for (int ii = 0; ii < numSat; ii++) {
    117           string prn; in >> prn;
     116          QString prn; in >> prn;
    118117          if (prn[0] == 'G') {
    119118            int iPrn;
     
    126125    }
    127126    else if (key == "APPROX POSITION XYZ") {
    128       istringstream in(value);
     127      QTextStream in(value.toAscii(), QIODevice::ReadOnly);
    129128      in >> _xyz[0] >> _xyz[1] >> _xyz[2];
    130129    }
    131130    else if (key == "ANTENNA: DELTA H/E/N") {
    132       istringstream in(value);
     131      QTextStream in(value.toAscii(), QIODevice::ReadOnly);
    133132      in >> _antNEU[2] >> _antNEU[1] >> _antNEU[0];
    134133    }
    135134    else if (key == "ANTENNA: DELTA X/Y/Z") {
    136       istringstream in(value);
     135      QTextStream in(value.toAscii(), QIODevice::ReadOnly);
    137136      in >> _antXYZ[0] >> _antXYZ[1] >> _antXYZ[2];
    138137    }
    139138    else if (key == "ANTENNA: B.SIGHT XYZ") {
    140       istringstream in(value);
     139      QTextStream in(value.toAscii(), QIODevice::ReadOnly);
    141140      in >> _antBSG[0] >> _antBSG[1] >> _antBSG[2];
    142141    }
    143142    else if (key == "# / TYPES OF OBSERV") {
    144       istringstream in(value);
     143      QTextStream in(value.toAscii(), QIODevice::ReadOnly);
    145144      int nTypes;
    146145      in >> nTypes;
    147146      _obsTypesV2.clear();
    148147      for (int ii = 0; ii < nTypes; ii++) {
    149         string hlp;
     148        QString hlp;
    150149        in >> hlp;
    151150        _obsTypesV2.push_back(hlp);
     
    153152    }
    154153    else if (key == "SYS / # / OBS TYPES") {
    155       istringstream* in = new istringstream(value);
     154      QTextStream* in = new QTextStream(value.toAscii(), QIODevice::ReadOnly);
    156155      char sys;
    157156      int nTypes;
     
    160159      for (int ii = 0; ii < nTypes; ii++) {
    161160        if (ii > 0 && ii % 13 == 0) {
    162           getline(*stream, line); ++numLines;
     161          line = stream->readLine(); ++numLines;
    163162          delete in;
    164           in = new istringstream(line);
    165         }
    166         string hlp;
     163          in = new QTextStream(line.toAscii(), QIODevice::ReadOnly);
     164        }
     165        QString hlp;
    167166        *in >> hlp;
    168167        _obsTypesV3[sys].push_back(hlp);
     
    185184  }
    186185  else {
    187     map<char, vector<string> >::const_iterator it = _obsTypesV3.find(sys);
     186    map<char, vector<QString> >::const_iterator it = _obsTypesV3.find(sys);
    188187    if (it != _obsTypesV3.end()) {
    189188      return it->second.size();
     
    197196// Observation Type (satellite-system specific)
    198197////////////////////////////////////////////////////////////////////////////
    199 const string& t_rnxObsFile::t_rnxObsHeader::obsType(char sys, int index) const {
     198const QString& t_rnxObsFile::t_rnxObsHeader::obsType(char sys, int index) const {
    200199  if (_version < 3.0) {
    201200    return _obsTypesV2.at(index);
    202201  }
    203202  else {
    204     map<char, vector<string> >::const_iterator it = _obsTypesV3.find(sys);
     203    map<char, vector<QString> >::const_iterator it = _obsTypesV3.find(sys);
    205204    if (it != _obsTypesV3.end()) {
    206205      return it->second.at(index);
     
    214213// Constructor
    215214////////////////////////////////////////////////////////////////////////////
    216 t_rnxObsFile::t_rnxObsFile(const string& fileName) {
     215t_rnxObsFile::t_rnxObsFile(const QString& fileName) {
    217216  _stream       = 0;
    218217  _flgPowerFail = false;
     
    222221// Open
    223222////////////////////////////////////////////////////////////////////////////
    224 void t_rnxObsFile::open(const string& fileName) {
    225   _stream = new ifstream(expandEnvVar(fileName).c_str());
     223void 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
    226231  _header.read(_stream);
    227232
     
    233238      const t_rnxEpo* rnxEpo = nextEpoch();
    234239      if (!rnxEpo) {
    235         throw string("t_rnxObsFile: not enough epochs");
     240        throw QString("t_rnxObsFile: not enough epochs");
    236241      }
    237242      if (iEpo > 0) {
     
    259264void t_rnxObsFile::close() {
    260265  delete _stream; _stream = 0;
     266  delete _file;   _file = 0;
    261267}
    262268
    263269// Handle Special Epoch Flag
    264270////////////////////////////////////////////////////////////////////////////
    265 void t_rnxObsFile::handleEpochFlag(int flag, const string& line) {
     271void t_rnxObsFile::handleEpochFlag(int flag, const QString& line) {
    266272
    267273  // Power Failure
     
    293299  // --------------
    294300  else {
    295     throw string("t_rnxObsFile: unhandled flag\n" + line);
     301    throw QString("t_rnxObsFile: unhandled flag\n" + line);
    296302  }
    297303}
     
    315321const t_rnxObsFile::t_rnxEpo* t_rnxObsFile::nextEpochV3() {
    316322
    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()) {
    324328      continue;
    325329    }
     
    332336    }
    333337
    334     istringstream in(line.substr(1));
     338    QTextStream in(line.mid(1).toAscii(), QIODevice::ReadOnly);
    335339
    336340    // Epoch Time
     
    351355    // ------------
    352356    for (int iSat = 0; iSat < numSat; iSat++) {
    353       getline(*_stream, line);
     357      line = _stream->readLine();
    354358      _currEpo.rnxSat[iSat].satSys = line[0];
    355359      readInt(line, 1, 2, _currEpo.rnxSat[iSat].satNum);
     
    386390const t_rnxObsFile::t_rnxEpo* t_rnxObsFile::nextEpochV2() {
    387391
    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()) {
    395397      continue;
    396398    }
     
    403405    }
    404406
    405     istringstream in(line);
     407    QTextStream in(line.toAscii(), QIODevice::ReadOnly);
    406408
    407409    // Epoch Time
     
    430432    for (int iSat = 0; iSat < numSat; iSat++) {
    431433      if (iSat > 0 && iSat % 12 == 0) {
    432         getline(*_stream, line);
     434        line = _stream->readLine();
    433435        pos = 32;
    434436      }
     
    443445    // ------------------------
    444446    for (int iSat = 0; iSat < numSat; iSat++) {
    445       getline(*_stream, line);
     447      line = _stream->readLine();
    446448      pos  = 0;
    447449      for (int iType = 0; iType < _header.nTypes(_currEpo.rnxSat[iSat].satSys); iType++) {
    448450        if (iType > 0 && iType % 5 == 0) {
    449           getline(*_stream, line);
     451          line = _stream->readLine();
    450452          pos  = 0;
    451453        }
  • trunk/BNC/rinex/rnxobsfile.h

    r3717 r3718  
    2626#define RNXOBSFILE_H
    2727
    28 #include <QString>
     28#include <QtCore>
    2929
    3030#include <fstream>
     
    9292    ~t_rnxObsHeader();
    9393
    94     t_irc           read(std::ifstream* stream, int maxLines = 0);
     94    t_irc           read(QTextStream* stream, int maxLines = 0);
    9595    int             nTypes(char sys) const;
    9696    const QString&  obsType(char sys, int index) const;
     
    115115  void handleEpochFlag(int flag, const QString& line);
    116116
     117  QFile*         _file;
    117118  QString        _fileName;
     119  QTextStream*   _stream;
    118120  t_rnxObsHeader _header;
    119   std::ifstream* _stream;
    120121  t_rnxEpo       _currEpo;
    121122  bool           _flgPowerFail;
Note: See TracChangeset for help on using the changeset viewer.