Changeset 3746 in ntrip for trunk/BNC/rinex/rnxnavfile.cpp


Ignore:
Timestamp:
Mar 30, 2012, 10:51:20 AM (12 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

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

    r3721 r3746  
    8888t_rnxNavFile::t_rnxNavFile(QString fileName) {
    8989  expandEnvVar(fileName);
    90   _file   = new QFile(fileName);
    91   _file->open(QIODevice::ReadOnly | QIODevice::Text);
    92   _stream = new QTextStream();
    93   _stream->setDevice(_file);
    94   _header.read(_stream);
     90  QFile*       file   = new QFile(fileName);
     91  file->open(QIODevice::ReadOnly | QIODevice::Text);
     92  QTextStream* stream = new QTextStream();
     93  stream->setDevice(file);
     94  _header.read(stream);
     95  this->read(stream);
     96  delete stream;
     97  delete file;
    9598}
    9699
     
    98101////////////////////////////////////////////////////////////////////////////
    99102t_rnxNavFile::~t_rnxNavFile() {
    100   delete _stream;
    101   delete _file;
    102103}
    103104
    104 // Read Next Ephemeris
     105// Read File Content
    105106////////////////////////////////////////////////////////////////////////////
    106 t_eph* t_rnxNavFile::getNextEph() {
     107void t_rnxNavFile::read(QTextStream* stream) {
    107108
    108   t_eph* eph = 0;
    109 
    110   while (_stream->status() == QTextStream::Ok && !_stream->atEnd()) {
    111     QString line = _stream->readLine();
     109  while (stream->status() == QTextStream::Ok && !stream->atEnd()) {
     110    QString line = stream->readLine();
    112111    if (line.isEmpty()) {
    113112      continue;
     
    126125      }
    127126    }
     127    t_eph* eph = 0;
    128128    QStringList lines; lines << line;
    129129    if      (prn[0] == 'G') {
    130130      for (int ii = 1; ii < 8; ii++) {
    131         lines << _stream->readLine();
     131        lines << stream->readLine();
    132132      }
    133133      eph = new t_ephGPS(version(), lines);
     
    135135    else if (prn[0] == 'R') {
    136136      for (int ii = 1; ii < 4; ii++) {
    137         lines << _stream->readLine();
     137        lines << stream->readLine();
    138138      }
    139139      eph = new t_ephGlo(version(), lines);
     
    141141    else if (prn[0] == 'E') {
    142142      for (int ii = 1; ii < 8; ii++) {
    143         lines << _stream->readLine();
     143        lines << stream->readLine();
    144144      }
    145145      eph = new t_ephGal(version(), lines);
    146146    }
    147147    if (eph && eph->ok()) {
    148       // ColumnVector xc(4);
    149       // ColumnVector vv(3);
    150       // eph->position(eph->GPSweek(), eph->GPSweeks(), xc.data(), vv.data());
    151       // cout << eph->prn().toAscii().data() << " " << xc.t();
    152       return eph;
     148      _ephs.push(eph);
     149    }
     150    else {
     151      delete eph;
    153152    }
    154153  }
     154}
    155155
    156   delete eph;
     156// Read Next Ephemeris
     157////////////////////////////////////////////////////////////////////////////
     158t_eph* t_rnxNavFile::getNextEph() {
     159  if (!_ephs.empty()) {
     160    t_eph* eph = _ephs.front();
     161    _ephs.pop();
     162    return eph;
     163  }
    157164  return 0;
    158165}
Note: See TracChangeset for help on using the changeset viewer.