//------------------------------------------------------------------------------------ int AfterReadingFiles(int reading) throw(Exception) { try { int i,j,iret=0; double dt; if(reading == 1) { // compute data interval for this file for(j=0,i=1; i<9; i++) { if(PIC.ndt[i]>PIC.ndt[j]) j=i; } PIC.DT = PIC.estdt[j]; PIC.oflog << endl; PIC.oflog << "Estimated data interval is " << PIC.DT << " seconds.\n"; PIC.oflog << "Interpolate to " << PIC.irate << " times the input data rate\n"; PIC.oflog << "Last data epoch is " << PIC.LastEpoch.printf("%04Y/%02m/%02d %02H:%02M:%06.3f = %4F %.3g") << endl; if(TimePositionMap.size() == 0) { cout << "No position information was found in the input file! Abort.\n"; PIC.oflog << "No position information was found in the input file! Abort.\n"; return -1; } PIC.oflog << endl; // dump the map of positions if(PIC.DumpMap) { PIC.oflog << "Here is all the Time/Position information:\n"; map<DayTime,PosInfo>::const_iterator itr; itr = TimePositionMap.begin(); i = 0; while(itr != TimePositionMap.end()) { PIC.oflog << setw(4) << i << " " << itr->first.printf("%04Y/%02m/%02d %02H:%02M:%6.3f %4F %10.3g") << fixed << setprecision(3) << " " << setw(2) << itr->second.N << " " << setw(13) << itr->second.X << " " << setw(13) << itr->second.Y << " " << setw(13) << itr->second.Z << " " << setw(13) << itr->second.T << " " << setw(7) << itr->second.rms << endl; itr++; i++; } PIC.oflog << "End of the Time/Position information.\n\n"; } // open output file if(!PIC.OutRinexObs.empty()) { ofstr.open(PIC.OutRinexObs.c_str(), ios::out); if(ofstr.fail()) { PIC.oflog << "Failed to open output file " << PIC.OutRinexObs << ". Abort.\n"; return 1; } else PIC.oflog << "Opened output file " << PIC.OutRinexObs << endl; ofstr.exceptions(ios::failbit); } } else if(reading==2) { PIC.oflog << "Close the output file\n"; ofstr.close(); } return iret; } catch(Exception& e) { GPSTK_RETHROW(e); } catch(exception& e) { Exception E("std except: "+string(e.what())); GPSTK_THROW(E); } catch(...) { Exception e("Unknown exception"); GPSTK_THROW(e); } }
//------------------------------------------------------------------------------------ // open the file, read header and check for data; then loop over the epochs // Return 0 ok, <0 fatal error, >0 non-fatal error (ie skip this file) // 0 ok, 1 couldn't open file, 2 file doesn't have required data int ReadFile(int nfile, int reading) throw(Exception) { try { int i,iret; RinexObsData rodata; RinexObsStream ifstr; // open input file ifstr.open(PIC.InputObsName[nfile].c_str(),ios::in); if(ifstr.fail()) { PIC.oflog << "(" << reading << ") Failed to open input file " << PIC.InputObsName[nfile] << ". Abort.\n"; return 1; } else PIC.oflog << "(" << reading << ") Opened input file " << PIC.InputObsName[nfile] << endl; ifstr.exceptions(ios::failbit); // read header and (on 2nd reading) output iret = ProcessHeader(ifstr, nfile, reading); if(iret) return iret; // loop over epochs in the file if(reading == 2) LastInterpolated = DayTime::BEGINNING_OF_TIME; while(1) { try { ifstr >> rodata; } catch(Exception& e) { GPSTK_RETHROW(e); } catch(...) { Exception e("Unknown exception in ReadFile() from operator>>"); GPSTK_THROW(e); break; } if(ifstr.eof()) break; if(ifstr.bad()) { Exception e("Bad read in ReadFile() from operator>>"); GPSTK_THROW(e); } iret = ProcessOneEntireEpoch(rodata,reading); if(iret < -1) break; if(iret == -1) { iret=0; break; } // end of file if(iret == 1) continue; // ignore this epoch } ifstr.clear(); ifstr.close(); PIC.oflog << endl << "Finished reading (" << reading << ") file " << PIC.InputObsName[nfile] << endl; return iret; } catch(Exception& e) { GPSTK_RETHROW(e); } catch(exception& e) { Exception E("std except: "+string(e.what())); GPSTK_THROW(E); } catch(...) { Exception e("Unknown exception"); GPSTK_THROW(e); } }