⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driver.cpp

📁 gps 读renix文件格式的源代码
💻 CPP
字号:
//---Note:  This file was generated using Borland C++ Builder 5.0 -----------//          (the #pragma statements may be removed)#include <iostream>#include <fstream>using namespace std;#pragma hdrstop//// Driver program for testing the RINEX C++ classes  27AUG01#pragma argsused#include "rinex.h";using namespace std;using namespace NGSrinex;int main(int argc, char* argv[]){  string filename;  string theObsFileType;  int i;  if( argc < 2 )  {    cout << "usage: driver filename " << endl    << "where filename is the name of a RINEX file." << endl;    return -1;  }  ofstream sum("driver.sum");  if( !sum )  {    cout << "Error! Cannot open driver.sum !" << endl    << "Terminating program DRIVER. " << endl << endl;    return -1;  }  sum << "Program DRIVER      Version:  0108.27" << endl << endl;  filename = argv[1];  cout << endl << "The file name is: " << filename << endl << endl;  sum  << endl << "The file name is: " << filename << endl << endl;  RinexFile *myFile = new RinexFile();  try { myFile->setPathFilenameMode( filename, ios::in );  }  catch( RinexFileException &openExcep )  {    cout << "Error opening the file: " << filename << endl    << "Rinex File Exception: " << endl << openExcep.getMessage() << endl    << "Terminating program DRIVER. " << endl << endl;    sum  << "Error opening the file: " << filename << endl    << "Rinex File Exception: " << endl << openExcep.getMessage() << endl    << "Terminating program DRIVER. " << endl << endl;  }  cout << "The RINEX file TYPE is: " <<  myFile->getRinexFileType() << endl << endl;  theObsFileType = myFile->getRinexFileType();  cout << "The Program Name is: " <<  myFile->getRinexProgram() << endl << endl;  delete myFile;  myFile = 0; // ------------ If the file is an OBS file  if( theObsFileType[0] == 'O' ) {   RinexObsFile myobs;   RinexObsFile mynewobs;   ObsEpoch  currentObsEpoch;   string newobsfile = "newobsfile";   try{      myobs.setPathFilenameMode(filename,ios_base::in);    }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << filename << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mynewobs.setPathFilenameMode(newobsfile,ios_base::out);    }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << newobsfile << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      myobs.readHeader();      myobs.writeHeaderImage( mynewobs.outputStream );    }   catch( RequiredRecordMissingException &headerExcep )   {      cout << " RequiredRecordMissingException is: " << endl <<      headerExcep.getMessage() << endl;   }   // read the observation epochs   try   {     cout << "Now reading the OBSERVATION DATA FILE." << endl;     while( myobs.readEpoch( currentObsEpoch ) != 0 )     {       myobs.writeEpoch(mynewobs.outputStream, currentObsEpoch);     }   }   catch( RinexReadingException &readingExcep )   {      cout << " RinexReadingException is: " << endl <<      readingExcep.getMessage() << endl;   }   sum << endl << endl;   sum << "The numberObsFiles = " << RinexObsFile::getObsFilesCount() << endl;   sum << endl << endl;   sum << "Number OBS Warnings = " << myobs.getNumberWarnings() << endl;   sum << endl << endl;   sum << "*** Here are the OBS ERROR MESSAGES:" << endl;   sum << myobs.getErrorMessages() << endl;   sum << "*** Here are the OBS WARNING MESSAGES:" << endl;   sum << myobs.getWarningMessages() << endl; } // ------------ If the file is an NAV file  else if( theObsFileType[0] == 'N' ) {   RinexNavFile mynav;   RinexNavFile mynewnav;   PRNBlock  currentPRNBlock;   string newnavfile = "newnavfile";   try{      mynav.setPathFilenameMode(filename,ios_base::in);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << filename << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mynewnav.setPathFilenameMode(newnavfile,ios_base::out);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << newnavfile << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mynav.readHeader();      mynav.writeHeaderImage(mynewnav.outputStream);    }   catch( RequiredRecordMissingException &headerExcep )   {      cout << " RequiredRecordMissingException is: " << endl <<      headerExcep.getMessage() << endl;   }    //read the PRN Blocks   try   {     cout << "Now reading the NAVIGATION MESSAGE FILE. " << endl;     while( mynav.readPRNBlock( currentPRNBlock ) != 0 )     {       mynav.writePRNBlock(mynewnav.outputStream, currentPRNBlock);     }   }   catch( RinexReadingException &readingExcep )   {      cout << " RinexReadingException is: " << endl <<      readingExcep.getMessage() << endl;   }   sum << endl << endl;   sum << "The numberNavFiles = " << RinexNavFile::getNavFilesCount() << endl;   sum << endl << endl;   sum << "Number NAV Warnings = " << mynav.getNumberWarnings() << endl;   sum << endl << endl;   sum << "*** Here are the NAV ERROR MESSAGES:" << endl;   sum << mynav.getErrorMessages() << endl;   sum << "*** Here are the NAV WARNING MESSAGES:" << endl;   sum << mynav.getWarningMessages() << endl; } // ------------ If the file is an MET file  else if( theObsFileType[0] == 'M' ) {   RinexMetFile mymet;   RinexMetFile mynewmet;   MetEpoch  currentMetEpoch;   string newmetfile = "newmetfile";   try{      mymet.setPathFilenameMode(filename,ios_base::in);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << filename << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mynewmet.setPathFilenameMode(newmetfile,ios_base::out);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << newmetfile << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mymet.readHeader();      mymet.writeHeaderImage(mynewmet.outputStream);    }   catch( RequiredRecordMissingException &headerExcep )   {      cout << " RequiredRecordMissingException is: " << endl <<      headerExcep.getMessage() << endl;   }    //read the MET epochs   try   {     cout << "Now reading the METEOROLOGICAL DATA FILE. " << endl;     while( mymet.readEpoch( currentMetEpoch ) != 0 )     {       mymet.writeEpoch(mynewmet.outputStream, currentMetEpoch);     }   }   catch( RinexReadingException &readingExcep )   {      cout << " RinexReadingException is: " << endl <<      readingExcep.getMessage() << endl;   }   sum << endl << endl;   sum << "The numberMetFiles = " << RinexMetFile::getMetFilesCount() << endl;   sum << endl << endl;   sum << "Number MET Warnings = " << mymet.getNumberWarnings() << endl;   sum << endl << endl;   sum << "*** Here are the MET ERROR MESSAGES:" << endl;   sum << mymet.getErrorMessages() << endl;   sum << "*** Here are the MET WARNING MESSAGES:" << endl;   sum << mymet.getWarningMessages() << endl; } // ------------ If the file is a GLONASS NAV file  else if( theObsFileType[0] == 'G' ) {   GlonassNavFile mynav;   GlonassNavFile mynewnav;   GlonassEphemEpoch  currentEphemEpoch;   string newnavfile = "newnavfile";   try{      mynav.setPathFilenameMode(filename,ios_base::in);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << filename << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mynewnav.setPathFilenameMode(newnavfile,ios_base::out);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << newnavfile << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mynav.readHeader();      mynav.writeHeaderImage(mynewnav.outputStream);    }   catch( RequiredRecordMissingException &headerExcep )   {      cout << " RequiredRecordMissingException is: " << endl <<      headerExcep.getMessage() << endl;   }    //read the Glonass Ephemeris Epochs   try   {     cout << "Now reading the GLONASS NAVIGATION MESSAGE FILE. " << endl;     while( mynav.readEphemEpoch( currentEphemEpoch ) != 0 )     {       mynav.writeEphemEpoch(mynewnav.outputStream, currentEphemEpoch);     }   }   catch( RinexReadingException &readingExcep )   {      cout << " RinexReadingException is: " << endl <<      readingExcep.getMessage() << endl;   }   sum << endl << endl;   sum << "The numberGlonassNavFiles = "       << GlonassNavFile::getFilesCount() << endl;   sum << endl << endl;   sum << "Number GLONASS NAV Warnings = " << mynav.getNumberWarnings() << endl;   sum << endl << endl;   sum << "*** Here are the GLONASS NAV ERROR MESSAGES:" << endl;   sum << mynav.getErrorMessages() << endl;   sum << "*** Here are the GLONASS NAV WARNING MESSAGES:" << endl;   sum << mynav.getWarningMessages() << endl; } // ------------ If the file is a GEOSTATIONARY NAV file  else if( theObsFileType[0] == 'H' ) {   GeostationaryNavFile mynav;   GeostationaryNavFile mynewnav;   GeostationaryEphemEpoch  currentEphemEpoch;   string newnavfile = "newnavfile";   try{      mynav.setPathFilenameMode(filename,ios_base::in);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << filename << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mynewnav.setPathFilenameMode(newnavfile,ios_base::out);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << newnavfile << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mynav.readHeader();      mynav.writeHeaderImage(mynewnav.outputStream);    }   catch( RequiredRecordMissingException &headerExcep )   {      cout << " RequiredRecordMissingException is: " << endl <<      headerExcep.getMessage() << endl;   }    //read the Geostationary Ephemeris Epochs   try   {     cout << "Now reading the GEOSTATIONARY NAVIGATION MESSAGE FILE. " << endl;     while( mynav.readEphemEpoch( currentEphemEpoch ) != 0 )     {       mynav.writeEphemEpoch(mynewnav.outputStream, currentEphemEpoch);     }   }   catch( RinexReadingException &readingExcep )   {      cout << " RinexReadingException is: " << endl <<      readingExcep.getMessage() << endl;   }   sum << endl << endl;   sum << "The numberGeostationaryNavFiles = "       << GeostationaryNavFile::getFilesCount() << endl;   sum << endl << endl;   sum << "Number GEOSTATIONARY NAV Warnings = " << mynav.getNumberWarnings() << endl;   sum << endl << endl;   sum << "*** Here are the GEOSTATIONARY NAV ERROR MESSAGES:" << endl;   sum << mynav.getErrorMessages() << endl;   sum << "*** Here are the GEOSTATIONARY NAV WARNING MESSAGES:" << endl;   sum << mynav.getWarningMessages() << endl; } // ------------ If the file is a CLOCK DATA FILE  else if( theObsFileType[0] == 'C' ) {   ClockDataFile myclk;   ClockDataFile mynewclk;   ClkEpoch  currentClkEpoch;   string newclkfile = "newclkfile";   try{      myclk.setPathFilenameMode(filename,ios::in);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << filename << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      mynewclk.setPathFilenameMode(newclkfile,ios::out);   }   catch( RinexFileException &openExcep )   {      cout << "Error opening file: " << newclkfile << endl;      cout << " RinexFileException is: " << endl <<      openExcep.getMessage() << endl;   }   try{      myclk.readHeader();      myclk.writeHeaderImage(mynewclk.outputStream);    }   catch( RequiredRecordMissingException &headerExcep )   {      cout << " RequiredRecordMissingException is: " << endl <<      headerExcep.getMessage() << endl;   }    //read the CLK epochs   try   {     cout << "Now reading the CLOCK DATA FILE. " << endl;     while( myclk.readEpoch( currentClkEpoch ) != 0 )     {       myclk.writeEpoch(mynewclk.outputStream, currentClkEpoch);     }   }   catch( RinexReadingException &readingExcep )   {      cout << " RinexReadingException is: " << endl <<      readingExcep.getMessage() << endl;   }   sum << endl << endl;   sum << "The numberClkFiles = " << ClockDataFile::getClkFilesCount() << endl;   sum << endl << endl;   sum << "Number CLK Warnings = " << myclk.getNumberWarnings() << endl;   sum << endl << endl;   sum << "*** Here are the CLK ERROR MESSAGES:" << endl;   sum << myclk.getErrorMessages() << endl;   sum << "*** Here are the CLK WARNING MESSAGES:" << endl;   sum << myclk.getWarningMessages() << endl; } else   // for any "Illegal" file-type designations {     cout << "Warning ! A Rinex File Type other than O,N,M,G,H,C has been found !"     << endl << "Now terminating program DRIVER." << endl << endl;     return -1; }  cout << endl << "Normal Termination for program DRIVER." << endl << endl;  sum  << endl << "Normal Termination for program DRIVER." << endl << endl;  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -