Changeset 4502 in ntrip
- Timestamp:
- Aug 12, 2012, 12:15:40 PM (12 years ago)
- Location:
- trunk/BNC/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bncrinex.cpp
r4501 r4502 177 177 // Read Skeleton Header File 178 178 //////////////////////////////////////////////////////////////////////////// 179 void bncRinex::readSkeleton( bool& obsTypesFound) {179 void bncRinex::readSkeleton() { 180 180 181 181 // Read the local file … … 197 197 } 198 198 } 199 } 200 201 // Next File Epoch (static) 202 //////////////////////////////////////////////////////////////////////////// 203 QString bncRinex::nextEpochStr(const QDateTime& datTim, 204 const QString& intStr, QDateTime* nextEpoch) { 205 206 QString epoStr; 207 208 QTime nextTime; 209 QDate nextDate; 210 211 int indHlp = intStr.indexOf("min"); 212 213 if ( indHlp != -1) { 214 int step = intStr.left(indHlp-1).toInt(); 215 char ch = 'A' + datTim.time().hour(); 216 epoStr = ch; 217 if (datTim.time().minute() >= 60-step) { 218 epoStr += QString("%1").arg(60-step, 2, 10, QChar('0')); 219 if (datTim.time().hour() < 23) { 220 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0); 221 nextDate = datTim.date(); 222 } 223 else { 224 nextTime.setHMS(0, 0, 0); 225 nextDate = datTim.date().addDays(1); 226 } 227 } 228 else { 229 for (int limit = step; limit <= 60-step; limit += step) { 230 if (datTim.time().minute() < limit) { 231 epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0')); 232 nextTime.setHMS(datTim.time().hour(), limit, 0); 233 nextDate = datTim.date(); 234 break; 235 } 236 } 237 } 238 } 239 else if (intStr == "1 hour") { 240 char ch = 'A' + datTim.time().hour(); 241 epoStr = ch; 242 if (datTim.time().hour() < 23) { 243 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0); 244 nextDate = datTim.date(); 245 } 246 else { 247 nextTime.setHMS(0, 0, 0); 248 nextDate = datTim.date().addDays(1); 249 } 250 } 251 else { 252 epoStr = "0"; 253 nextTime.setHMS(0, 0, 0); 254 nextDate = datTim.date().addDays(1); 255 } 256 257 if (nextEpoch) { 258 *nextEpoch = QDateTime(nextDate, nextTime); 259 } 260 261 return epoStr; 262 } 263 264 // File Name according to RINEX Standards 265 //////////////////////////////////////////////////////////////////////////// 266 void bncRinex::resolveFileName(const QDateTime& datTim) { 199 267 200 268 bncSettings settings; 269 QString path = settings.value("rnxPath").toString(); 270 expandEnvVar(path); 271 272 if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) { 273 path += QDir::separator(); 274 } 275 276 QString hlpStr = nextEpochStr(datTim, settings.value("rnxIntr").toString(), 277 &_nextCloseEpoch); 278 279 QString ID4 = _statID.left(4); 280 281 // Check name conflict 282 // ------------------- 283 QString distStr; 284 int num = 0; 285 QListIterator<QString> it(settings.value("mountPoints").toStringList()); 286 while (it.hasNext()) { 287 QString mp = it.next(); 288 if (mp.indexOf(ID4) != -1) { 289 ++num; 290 } 291 } 292 if (num > 1) { 293 distStr = "_" + _statID.mid(4); 294 } 295 296 QString sklExt = settings.value("rnxSkel").toString(); 297 if (!sklExt.isEmpty()) { 298 _sklName = path + ID4 + distStr + "." + sklExt; 299 } 300 301 path += ID4 + 302 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) + 303 hlpStr + distStr + datTim.toString(".yyO"); 304 305 _fName = path.toAscii(); 306 } 307 308 // Write RINEX Header 309 //////////////////////////////////////////////////////////////////////////// 310 void bncRinex::writeHeader(const QByteArray& format, 311 const QDateTime& datTimNom) { 312 313 bncSettings settings; 314 315 // Open the Output File 316 // -------------------- 317 resolveFileName(datTimNom); 318 319 // Append to existing file and return 320 // ---------------------------------- 321 if ( QFile::exists(_fName) ) { 322 if (_reconnectFlag || 323 Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) { 324 _out.open(_fName.data(), ios::app); 325 _out.setf(ios::showpoint | ios::fixed); 326 _headerWritten = true; 327 _reconnectFlag = false; 328 return; 329 } 330 } 331 332 _out.open(_fName.data()); 333 _out.setf(ios::showpoint | ios::fixed); 334 335 // Read Skeleton Header 336 // -------------------- 337 readSkeleton(); 338 339 // Set RINEX Version 340 // ----------------- 201 341 if ( Qt::CheckState(settings.value("rnxV3").toInt()) == Qt::Checked) { 202 342 _header._version = 3.01; … … 206 346 } 207 347 208 obsTypesFound = true; 209 210 // Default RINEX v2 Types 211 // ------------------------- 348 // Set Marker Name 349 // --------------- 350 if (_header._markerName.isEmpty()) { 351 _header._markerName = _statID; 352 } 353 354 // Set Default RINEX v2 Types 355 // -------------------------- 212 356 if (_header._obsTypesV2.size() == 0) { 213 357 if (_header._version < 3.0) { 214 obsTypesFound = false;215 358 } 216 359 _header._obsTypesV2 << "C1" << "P1" << "L1" << "S1" … … 218 361 } 219 362 220 // Default RINEX v3 Types 221 // ------------------------- 363 QStringList addComments; 364 365 // Set Default RINEX v3 Types 366 // --------------------------- 222 367 if (_header._obsTypesV3.size() == 0) { 223 368 if (_header._version >= 3.0) { 224 obsTypesFound = false;225 369 } 226 370 _header._obsTypesV3['G'] << "C1C" << "L1C" << "D1C" << "S1C" … … 253 397 << "C7" << "L7" << "D7" << "S7"; 254 398 } 255 }256 257 // Next File Epoch (static)258 ////////////////////////////////////////////////////////////////////////////259 QString bncRinex::nextEpochStr(const QDateTime& datTim,260 const QString& intStr, QDateTime* nextEpoch) {261 262 QString epoStr;263 264 QTime nextTime;265 QDate nextDate;266 267 int indHlp = intStr.indexOf("min");268 269 if ( indHlp != -1) {270 int step = intStr.left(indHlp-1).toInt();271 char ch = 'A' + datTim.time().hour();272 epoStr = ch;273 if (datTim.time().minute() >= 60-step) {274 epoStr += QString("%1").arg(60-step, 2, 10, QChar('0'));275 if (datTim.time().hour() < 23) {276 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);277 nextDate = datTim.date();278 }279 else {280 nextTime.setHMS(0, 0, 0);281 nextDate = datTim.date().addDays(1);282 }283 }284 else {285 for (int limit = step; limit <= 60-step; limit += step) {286 if (datTim.time().minute() < limit) {287 epoStr += QString("%1").arg(limit-step, 2, 10, QChar('0'));288 nextTime.setHMS(datTim.time().hour(), limit, 0);289 nextDate = datTim.date();290 break;291 }292 }293 }294 }295 else if (intStr == "1 hour") {296 char ch = 'A' + datTim.time().hour();297 epoStr = ch;298 if (datTim.time().hour() < 23) {299 nextTime.setHMS(datTim.time().hour() + 1 , 0, 0);300 nextDate = datTim.date();301 }302 else {303 nextTime.setHMS(0, 0, 0);304 nextDate = datTim.date().addDays(1);305 }306 }307 else {308 epoStr = "0";309 nextTime.setHMS(0, 0, 0);310 nextDate = datTim.date().addDays(1);311 }312 313 if (nextEpoch) {314 *nextEpoch = QDateTime(nextDate, nextTime);315 }316 317 return epoStr;318 }319 320 // File Name according to RINEX Standards321 ////////////////////////////////////////////////////////////////////////////322 void bncRinex::resolveFileName(const QDateTime& datTim) {323 324 bncSettings settings;325 QString path = settings.value("rnxPath").toString();326 expandEnvVar(path);327 328 if ( path.length() > 0 && path[path.length()-1] != QDir::separator() ) {329 path += QDir::separator();330 }331 332 QString hlpStr = nextEpochStr(datTim, settings.value("rnxIntr").toString(),333 &_nextCloseEpoch);334 335 QString ID4 = _statID.left(4);336 337 // Check name conflict338 // -------------------339 QString distStr;340 int num = 0;341 QListIterator<QString> it(settings.value("mountPoints").toStringList());342 while (it.hasNext()) {343 QString mp = it.next();344 if (mp.indexOf(ID4) != -1) {345 ++num;346 }347 }348 if (num > 1) {349 distStr = "_" + _statID.mid(4);350 }351 352 QString sklExt = settings.value("rnxSkel").toString();353 if (!sklExt.isEmpty()) {354 _sklName = path + ID4 + distStr + "." + sklExt;355 }356 357 path += ID4 +358 QString("%1").arg(datTim.date().dayOfYear(), 3, 10, QChar('0')) +359 hlpStr + distStr + datTim.toString(".yyO");360 361 _fName = path.toAscii();362 }363 364 // Write RINEX Header365 ////////////////////////////////////////////////////////////////////////////366 void bncRinex::writeHeader(const QByteArray& format,367 const QDateTime& datTimNom) {368 369 bncSettings settings;370 371 // Open the Output File372 // --------------------373 resolveFileName(datTimNom);374 375 // Append to existing file and return376 // ----------------------------------377 if ( QFile::exists(_fName) ) {378 if (_reconnectFlag ||379 Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {380 _out.open(_fName.data(), ios::app);381 _out.setf(ios::showpoint | ios::fixed);382 _headerWritten = true;383 _reconnectFlag = false;384 return;385 }386 }387 388 _out.open(_fName.data());389 _out.setf(ios::showpoint | ios::fixed);390 391 // Copy Skeleton Header392 // --------------------393 bool obsTypesFound;394 readSkeleton(obsTypesFound);395 if (_header._markerName.isEmpty()) {396 _header._markerName = _statID;397 }398 399 399 400 // A few additional comments 400 401 // ------------------------- 401 402 QMap<QString, QString> txtMap; 402 QStringList addComments;403 403 404 404 addComments << format.left(6) + " " + _mountPoint.host() + _mountPoint.path(); -
trunk/BNC/src/bncrinex.h
r4501 r4502 55 55 static std::string obsToStr(double val, int width = 14, int precision = 3); 56 56 void resolveFileName(const QDateTime& datTim); 57 void readSkeleton( bool& obsTypesFound);57 void readSkeleton(); 58 58 void writeHeader(const QByteArray& format, const QDateTime& datTimNom); 59 59 void closeFile();
Note:
See TracChangeset
for help on using the changeset viewer.