Legend:
- Unmodified
- Added
- Removed
-
trunk/BNS/bns.cpp
r848 r849 116 116 delete it.value(); 117 117 } 118 delete _rnx; 119 delete _sp3; 118 120 } 119 121 -
trunk/BNS/bnssp3.cpp
r848 r849 19 19 20 20 #include "bnssp3.h" 21 #include "bnsutils.h" 21 22 22 23 using namespace std; … … 25 26 //////////////////////////////////////////////////////////////////////////// 26 27 bnsSP3::bnsSP3() { 28 QSettings settings; 29 30 _headerWritten = false; 31 _ID4 = "BNS_"; 32 _ext = ".SP3"; 33 _samplingRate = settings.value("sp3Sampl").toInt(); 34 _intr = settings.value("rnxIntr").toString(); 35 _path = settings.value("rnxPath").toString(); 36 expandEnvVar(_path); 37 if ( _path.length() > 0 && _path[_path.length()-1] != QDir::separator() ) { 38 _path += QDir::separator(); 39 } 27 40 } 28 41 … … 30 43 //////////////////////////////////////////////////////////////////////////// 31 44 bnsSP3::~bnsSP3() { 45 _out.close(); 32 46 } 33 47 34 // 48 // Close the Old RINEX File 49 //////////////////////////////////////////////////////////////////////////// 50 void bnsSP3::closeFile() { 51 _out.close(); 52 } 53 54 // Next File Epoch (static) 55 //////////////////////////////////////////////////////////////////////////// 56 QString bnsSP3::nextEpochStr(const QDateTime& datTim, 57 const QString& intStr, QDateTime* nextEpoch) { 58 59 QString epoStr; 60 61 QTime nextTime; 62 QDate nextDate; 63 64 int indHlp = intStr.indexOf("min"); 65 66 if ( indHlp != -1) { 67 int step = intStr.left(indHlp-1).toInt(); 68 char ch = 'A' + datTim.time().hour(); 69 epoStr = ch; 70 if (datTim.time().minute() >= 60-step) { 71 epoStr += QString("%1").arg(60-step, 2, 10, QChar('0')); 72 if (datTim.time().hour() < 23) { 73 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0); 74 nextDate = datTim.date(); 75 } 76 else { 77 nextTime.setHMS(0, 0, 0); 78 nextDate = datTim.date().addDays(1); 79 } 80 } 81 else { 82 for (int limit = step; limit <= 60-step; limit += step) { 83 if (datTim.time().minute() < limit) { 84 epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0')); 85 nextTime.setHMS(datTim.time().hour(), limit, 0); 86 nextDate = datTim.date(); 87 break; 88 } 89 } 90 } 91 } 92 else if (intStr == "1 hour") { 93 char ch = 'A' + datTim.time().hour(); 94 epoStr = ch; 95 if (datTim.time().hour() < 23) { 96 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0); 97 nextDate = datTim.date(); 98 } 99 else { 100 nextTime.setHMS(0, 0, 0); 101 nextDate = datTim.date().addDays(1); 102 } 103 } 104 else { 105 epoStr = "0"; 106 nextTime.setHMS(0, 0, 0); 107 nextDate = datTim.date().addDays(1); 108 } 109 110 if (nextEpoch) { 111 *nextEpoch = QDateTime(nextDate, nextTime); 112 } 113 114 return epoStr; 115 } 116 117 // File Name according to RINEX Standards 118 //////////////////////////////////////////////////////////////////////////// 119 void bnsSP3::resolveFileName(const QDateTime& datTim) { 120 121 QString hlpStr = nextEpochStr(datTim, _intr, &_nextCloseEpoch); 122 123 _fName = (_ID4 124 + QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) 125 + hlpStr 126 + _ext).toAscii(); 127 } 128 129 // Write Header 130 //////////////////////////////////////////////////////////////////////////// 131 void bnsSP3::writeHeader(const QDateTime& datTim) { 132 133 // Open the Output File 134 // -------------------- 135 resolveFileName(datTim); 136 137 _out.open(_fName.data()); 138 _out.setf(ios::showpoint | ios::fixed); 139 140 _out << "THIS IS A DUMMY HEADER" << endl; 141 142 _headerWritten = true; 143 } 144 145 // Write One Epoch 35 146 //////////////////////////////////////////////////////////////////////////// 36 147 void bnsSP3::write(int GPSweek, double GPSweeks, const QString& prn, 37 148 const ColumnVector& xx) { 149 150 QDateTime datTim = dateAndTimeFromGPSweek(GPSweek, GPSweeks); 151 152 // Close the file 153 // -------------- 154 if (_nextCloseEpoch.isValid() && datTim >= _nextCloseEpoch) { 155 closeFile(); 156 _headerWritten = false; 157 } 158 159 // Write Header 160 // ------------ 161 if (!_headerWritten) { 162 writeHeader(datTim); 163 } 164 165 int year, month, day, hour, min; 166 double sec; 167 168 _out << "* " << setw(4) << year 169 << setw(3) << month 170 << setw(3) << day 171 << setw(3) << hour 172 << setw(3) << min 173 << setw(12) << setprecision(8) << sec << endl; 174 _out << "P" << prn.toAscii().data() 175 << setw(14) << setprecision(6) << xx(1) / 1000.0 176 << setw(14) << setprecision(6) << xx(2) / 1000.0 177 << setw(14) << setprecision(6) << xx(3) / 1000.0 178 << " 999999.999999" << endl; 38 179 } -
trunk/BNS/bnssp3.h
r848 r849 8 8 class bnsSP3 { 9 9 public: 10 bnsSP3(); 11 ~bnsSP3(); 12 void write(int GPSweek, double GPSweeks, const QString& prn, 13 const ColumnVector& xx); 10 bnsSP3(); 11 ~bnsSP3(); 12 void write(int GPSweek, double GPSweeks, const QString& prn, 13 const ColumnVector& xx); 14 15 static QString nextEpochStr(const QDateTime& datTim, 16 const QString& intStr, 17 QDateTime* nextEpoch = 0); 18 14 19 private: 20 void resolveFileName(const QDateTime& datTim); 21 void writeHeader(const QDateTime& datTim); 22 void closeFile(); 23 24 int _samplingRate; 25 bool _headerWritten; 26 QDateTime _nextCloseEpoch; 27 std::ofstream _out; 28 QString _path; 29 QString _intr; 30 QString _ext; 31 QString _ID4; 32 QByteArray _fName; 15 33 }; 16 34
Note:
See TracChangeset
for help on using the changeset viewer.