Changeset 6331 in ntrip for trunk/BNC/src/bncsp3.cpp


Ignore:
Timestamp:
Nov 24, 2014, 4:38:47 PM (9 years ago)
Author:
mervart
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncsp3.cpp

    r4991 r6331  
    1717
    1818#include <iomanip>
     19#include <sstream>
    1920#include <math.h>
    2021
     
    2627// Constructor
    2728////////////////////////////////////////////////////////////////////////////
     29bncSP3::bncSP3(const QString& fileName) : bncoutf(QString(), QString(), 0) {
     30  _inpOut    = input;
     31  _currEpoch = 0;
     32  _prevEpoch = 0;
     33
     34  _stream.open(fileName.toAscii().data());
     35  if (!_stream.good()) {
     36    throw "t_sp3File: cannot open file " + fileName;
     37  } 
     38
     39  while (_stream.good()) {
     40    getline(_stream, _lastLine);
     41    if (_lastLine[0] == '*') {
     42      break;
     43    }
     44  }
     45}
     46
     47// Constructor
     48////////////////////////////////////////////////////////////////////////////
    2849bncSP3::bncSP3(const QString& sklFileName, const QString& intr, int sampl)
    2950  : bncoutf(sklFileName, intr, sampl) {
     51  _inpOut    = output;
     52  _currEpoch = 0;
     53  _prevEpoch = 0;
    3054}
    3155
     
    3357////////////////////////////////////////////////////////////////////////////
    3458bncSP3::~bncSP3() {
     59  delete _currEpoch;
     60  delete _prevEpoch;
    3561}
    3662
     
    133159}
    134160
     161// Read Next Epoch
     162////////////////////////////////////////////////////////////////////////////
     163const bncSP3::t_sp3Epoch* bncSP3::nextEpoch() {
     164
     165  delete _prevEpoch; _prevEpoch = _currEpoch; _currEpoch = 0;
     166
     167  while (true) {
     168
     169    if (!_currEpoch) {
     170      _currEpoch = new t_sp3Epoch();
     171      istringstream in(_lastLine.substr(1).c_str());
     172      int    YY, MM, DD, hh, mm;
     173      double ss;
     174      in >> YY >> MM >> DD >> hh >> mm >> ss;
     175      _currEpoch->_tt.set(YY, MM, DD, hh, mm, ss);
     176    }
     177
     178    getline(_stream, _lastLine);
     179    if (_stream.eof() || _lastLine.find("EOF") == 0) {
     180      throw "t_sp3File: end of file";
     181      break;
     182    }
     183    if (_lastLine[0] == '*') {
     184      break;
     185    }
     186
     187    t_sp3Sat* sp3Sat = new t_sp3Sat();
     188    istringstream in(_lastLine.substr(1).c_str());
     189    in >> sp3Sat->_prn >> sp3Sat->_xyz(1) >> sp3Sat->_xyz(2) >> sp3Sat->_xyz(3) >> sp3Sat->_clk;
     190
     191    sp3Sat->_xyz *= 1.e3;
     192    sp3Sat->_clk *= t_CST::c * 1.e-6;
     193
     194    _currEpoch->_sp3Sat.push_back(sp3Sat);
     195  }
     196
     197  return _currEpoch;
     198}
Note: See TracChangeset for help on using the changeset viewer.