// ----------------------------------------------------------------------------------- int main(int argc, char **argv) { try { int i,n,nobs,nnav; // get the current system time time_t timer; struct tm *tblock; timer = time(NULL); tblock = localtime(&timer); CurrEpoch = SystemTime(); i = GetCommandInput(argc, argv); if(i) return 0; if(verbose) { cout << Prgm << " version " << Vers << " run " << CurrEpoch << endl; DumpCommandLine(); } i = OpenFiles(); if(i) return i; // declare data objects used for I/O long bytesread=0; // at the end, bytesread should equal the Novatel file size. NovatelData novad; novad.setWeek(gpsWeek); RinexNavHeader rnh; RinexNavData rnd; RinexObsData rod; // initialize the headers (indexes inC1,etc defined here) InitializeHeaders(roh, rnh); // write headers rostr << roh; rnstr << rnh; // prep for the I/O loop FirstEpoch = CommonTime::BEGINNING_OF_TIME; for(i=0; i<9; i++) ndt[i] = -1; // show a counter nobs = nnav = n = 0; // loop over data in the Novatel file try{ while(instr >> novad) { if(Debug) cout << "Read " << NovatelData::RecNames[novad.rectype] << " size " << novad.headersize << " + " << novad.datasize << " number " << novad.recnum; if(novad.isOEM2()) { if(roh.recVers == string("OEM2/4")) roh.recVers = "OEM2"; if(Debug) cout << " OEM2"; } if(novad.isOEM4()) { if(Debug) cout << " OEM4"; if(roh.recVers == string("OEM2/4")) roh.recVers = "OEM4"; } if(Debug) { if(novad.isObs()) cout << " obs"; if(novad.isNav()) cout << " nav"; if(novad.isAux()) cout << " aux"; cout << endl; } bytesread += novad.datasize + novad.headersize; if(novad.isOEM2()) bytesread += 1; // CRC byte if(novad.isOEM4()) bytesread += 4; // CRC bytes if(novad.isObs() && novad.datasize > 4) { // obs only, with data try{ rod = RinexObsData(novad); // convert }catch(Exception e){cout << "Malformed Novatel obs record" << endl;} if(rod.time < BegTime) continue; if(rod.time > EndTime) break; if(Debug) rod.dump(cout); // dump rostr << rod; // write out nobs++; UpdateInformation(rod); } else if(novad.isNav()) { // nav only try{ rnd = RinexNavData(novad); // convert }catch(Exception e){cout << "Malformed Novatel nav record" << endl;} if(Debug) rnd.dump(cout); // dump rnstr << rnd; // write out nnav++; } n++; if(verbose && !Debug) { if(n == 100) cout << "Reading Novatel records: (100 per .)\n"; if(!(n % 100)) { cout << "."; cout.flush(); } if(!(n % 8000)) cout << endl; } } // end while loop over data } catch(Exception& e) { GPSTK_RETHROW(e); } if(verbose && !Debug) cout << "\n"; //instr.clear(); instr.close(); //rostr.clear(); rostr.close(); //rnstr.clear(); rnstr.close(); // now update the header and (re)write it to the file i = UpdateHeader(TempFileName, RinexObsFile, roh); if(verbose) { cout << "novaRinex read " << n << " records, and wrote " << nobs << " observations and " << nnav << " ephemerides\n"; cout << "Total bytes read = " << bytesread << endl; } return i; } catch(Exception& e) { cerr << "Caught exception\n" << e << endl; } catch(...) { cerr << "Unknown error." << endl; } return -1; }