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

📄 rinex.cpp

📁 gps 读renix文件格式的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
bool GeostationaryEphemEpoch::setEpochSec(double input){  if( input >= 0.0 && input <= 60.0)  {    epochSec = input;    return true;  }  else  {    epochSec = 0.0;    return false;  }}bool GeostationaryEphemEpoch::setSvClockBias(double input){    svClockBias = input;    return true;}bool GeostationaryEphemEpoch::setSvRelFreqBias(double input){    svRelFreqBias = input;    return true;}bool GeostationaryEphemEpoch::setMessageFrameTime(double input){    messageFrameTime = input;    return true;}bool GeostationaryEphemEpoch::setPosX(double input)     { posX = input; return true; }bool GeostationaryEphemEpoch::setVelX(double input)     { velX = input; return true; }bool GeostationaryEphemEpoch::setAccX(double input)     { accX = input; return true; }bool GeostationaryEphemEpoch::setSvHealth(double input)     { svHealth = input; return true; }bool GeostationaryEphemEpoch::setPosY(double input)     { posY = input; return true; }bool GeostationaryEphemEpoch::setVelY(double input)     { velY = input; return true; }bool GeostationaryEphemEpoch::setAccY(double input)     { accY = input; return true; }bool GeostationaryEphemEpoch::setAccurCode(double input)     { accurCode = input; return true; }bool GeostationaryEphemEpoch::setPosZ(double input)     { posZ = input; return true; }bool GeostationaryEphemEpoch::setVelZ(double input)     { velZ = input; return true; }bool GeostationaryEphemEpoch::setAccZ(double input)     { accZ = input; return true; }bool GeostationaryEphemEpoch::setSpare(double input)     { spare = input; return true; }// Selectorsunsigned short GeostationaryEphemEpoch::getSatelliteNumber()               { return satelliteNumber; }unsigned short GeostationaryEphemEpoch::getEpochYear()               { return epochYear; }unsigned short GeostationaryEphemEpoch::getEpochMonth()               { return epochMonth; }unsigned short GeostationaryEphemEpoch::getEpochDay()               { return epochDay; }unsigned short GeostationaryEphemEpoch::getEpochHour()               { return epochHour; }unsigned short GeostationaryEphemEpoch::getEpochMin()               { return epochMin; }double         GeostationaryEphemEpoch::getEpochSec()               { return epochSec; }double GeostationaryEphemEpoch::getSvClockBias() { return svClockBias; }double GeostationaryEphemEpoch::getSvRelFreqBias() { return svRelFreqBias; }double GeostationaryEphemEpoch::getMessageFrameTime()       { return messageFrameTime; }double GeostationaryEphemEpoch::getPosX() { return posX; }double GeostationaryEphemEpoch::getVelX() { return velX; }double GeostationaryEphemEpoch::getAccX() { return accX; }double GeostationaryEphemEpoch::getSvHealth() { return svHealth; }double GeostationaryEphemEpoch::getPosY() { return posY; }double GeostationaryEphemEpoch::getVelY() { return velY; }double GeostationaryEphemEpoch::getAccY() { return accY; }double GeostationaryEphemEpoch::getAccurCode() { return accurCode; }double GeostationaryEphemEpoch::getPosZ() { return posZ; }double GeostationaryEphemEpoch::getVelZ() { return velZ; }double GeostationaryEphemEpoch::getAccZ() { return accZ; }double GeostationaryEphemEpoch::getSpare() { return spare; }//===================== HeaderRecord Class ====================================// ConstructorsHeaderRecord::HeaderRecord()    {       first60 = "";       label = "";    }HeaderRecord::HeaderRecord(string input) // input is the entire header record    {       first60 = input.substr(0,60);       label = input.substr(60,20);    }HeaderRecord::~HeaderRecord()    {}void HeaderRecord::SetHeaderRecord(string input)    {       first60 = input.substr(0,60);       label = input.substr(60,20);    }void HeaderRecord::SetFirst60(string input)    {       first60 = input.substr(0,60);    }void HeaderRecord::SetLabel(string input)    {       label = input.substr(0,20);    }string HeaderRecord::GetFirst60()    {       return( first60 );    }string HeaderRecord::GetLabel()    {       return( label );    }ostream& operator <<(ostream& os, const HeaderRecord& input)    {       os << input.first60 << input.label << endl;       return os;    }istream& operator >>(istream& is, HeaderRecord& output)    {      string temp;      getline( is, temp );      output.SetHeaderRecord(temp);      return is;    }HeaderRecord& HeaderRecord::operator=(const HeaderRecord& input)    {       first60 = input.first60;       label = input.label;       return *this;    }HeaderRecord* HeaderRecord::operator&(HeaderRecord input)    {       return &input;    }//========================== RinexHeader Class ================================// ConstructorsRinexHeader::RinexHeader()   // default constructor{}RinexHeader::RinexHeader( list<HeaderRecord> inputImage ) // copy constructor{  // Copy an existing linked list of type HeaderRecord into headerImage.  headerImage = inputImage;}// DestructorRinexHeader::~RinexHeader(){}// Initializersvoid RinexHeader::appendHeaderRecord(HeaderRecord addedRec){ // Append addedRec to the end of the headerImage linked list. headerImage.push_back(addedRec);}void RinexHeader::insertHeaderRecBeforeLabel(string inputLabel,                                            HeaderRecord addedRec){  // InsertaddedRec before the first occurance of inputLabel.  list<HeaderRecord>::iterator iter = headerImage.begin();   for( ; iter != headerImage.end(); ++iter )   {     if( iter->GetLabel() == inputLabel.substr(0,iter->GetLabel().length()) )     {       headerImage.insert(iter, addedRec);       break;     }   }}void RinexHeader::insertHeaderRecAfterLabel(string inputLabel,                                            HeaderRecord addedRec){  // InsertaddedRec after the first occurance of inputLabel.  list<HeaderRecord>::iterator iter = headerImage.begin();   for( ; iter != headerImage.end(); ++iter )   {     if( iter->GetLabel() == inputLabel.substr(0,iter->GetLabel().length()) )     {       headerImage.insert(iter++, addedRec);       break;     }   }}void RinexHeader::overwriteHeaderRecord(string inputLabel,                                        string newFirst60){  // Overwrite the first occurance of inputLabel using newFirst60.  list<HeaderRecord>::iterator iter = headerImage.begin();   for( ; iter != headerImage.end(); ++iter )   {     if( iter->GetLabel() == inputLabel.substr(0,iter->GetLabel().length()) )     {       iter->SetFirst60(newFirst60);       break;     }   }}void RinexHeader::deleteHeaderRecord(string inputLabel){   // Delete the first occurance of the HeaderRecord matching inputLabel.   // If no match is found in the headerImage linked list, nothing is done.   list<HeaderRecord>::iterator iter = headerImage.begin();   for( ; iter != headerImage.end(); ++iter )   {     if( iter->GetLabel() == inputLabel.substr(0,iter->GetLabel().length()) )     {       headerImage.erase(iter);       break;     }   }}void RinexHeader::setHeaderImage(list<HeaderRecord> inputImage){   // Copy an existing linked list of type HeaderRecord into headerImage   headerImage = inputImage;}//SelectorsHeaderRecord RinexHeader::getHeaderRecord(string inputLabel){  // Get the HeaderRecord corresponding to the first occurance of inputLabel.  list<HeaderRecord>::iterator iter = headerImage.begin();   for( ; iter != headerImage.end(); ++iter )   {     if( iter->GetLabel() == inputLabel.substr(0,iter->GetLabel().length()) )     {       return *iter;     }   }   // If inputLabel is not found, return an empty HeaderRecord using   // the default constructor for class HeaderRecord.   HeaderRecord emptyHeaderRecord;   return  emptyHeaderRecord;}void RinexHeader::writeHeaderImage( ofstream &outputStream ){  // Write headerImage to an output file using an ofstream.  list<HeaderRecord>::iterator iter = headerImage.begin();   for( ; iter != headerImage.end(); ++iter )   {     outputStream << iter->GetFirst60() << iter->GetLabel() << endl;   }} //========================== RinexFile Class ==================================RinexFile::RinexFile()   // this is a base class{    pathFilename = "nofilename.out";    fileMode = ios::out;}RinexFile::RinexFile(string inputFilePath, ios::openmode mode){    string record;    pathFilename = inputFilePath;    fileMode = mode;    if( fileMode == ios::in )    {      inputStream.open( pathFilename.c_str(), fileMode );      if( !inputStream )      {	tempStream << "Error: In RinexFile constructor, unable to open file:"        << endl << pathFilename << " using mode: " << fileMode << endl;	appendToErrorMessages( tempStream.str() );        RinexFileException  excep( tempStream.str() );	throw excep;      }      readFileTypeAndProgramName();   // read the RINEX VERSION/TYPE and                                            // PGM/RUN BY/DATE header records      inputStream.close();      inputStream.open( pathFilename.c_str(), fileMode );  // reset the file at                                                           // its beginning.      numberLinesRead = 0;      numberWarnings = 0;      numberErrors = 0;    }    else    {      outputStream.open( pathFilename.c_str(), fileMode );      if( !outputStream )      {	tempStream << "Error: In RinexFile constructor, unable to open file:"        << endl << pathFilename << " using mode: " << fileMode << endl;	appendToErrorMessages( tempStream.str() );        RinexFileException  excep( tempStream.str() );	throw excep;      }    }} // DestructorRinexFile::~RinexFile(){    if( fileMode == ios::in )    {      inputStream.close();    }    else    {       outputStream.close();    }    pathFilename = "nofilename.out";    fileMode = ios::out;}// Initializersvoid RinexFile::setPathFilenameMode(string inputFilePath,                                    ios::openmode mode){    pathFilename = inputFilePath;    fileMode = mode;    if( fileMode == ios::in )  // input file    {      inputStream.open( pathFilename.c_str(), fileMode );      if( !inputStream )      {	tempStream <<	"Error: In setPathFilenameMode, unable to open file:"        << endl << pathFilename << " using mode: " << fileMode << endl;	appendToErrorMessages( tempStream.str() );        RinexFileException  excep( tempStream.str() );	throw excep;      }      readFileTypeAndProgramName();   // read the RINEX VERSION/TYPE and                                            // PGM/RUN BY/DATE header records      inputStream.close();      inputStream.open( pathFilename.c_str(), fileMode );  // reset the file at                                                           // its beginning.      numberLinesRead = 0;      numberWarnings = 0;      numberErrors = 0;    }    else  // output file    {      outputStream.open( pathFilename.c_str(), fileMode );      if( !outputStream )      {	tempStream <<	"Error: In setPathFilenameMode, unable to open file:"        << endl << pathFilename << " using mode: " << fileMode << endl;	appendToErrorMessages( tempStream.str() );        RinexFileException  excep( tempStream.str() );	throw excep;      }    }}bool RinexFile::setRinexHeaderImage(list<HeaderRecord> input){    rinexHeaderImage.setHeaderImage(input);    return true;}bool RinexFile::setFormatVersion(float input){   if( input > 0.99  &&  input < 2.11 )   {    formatVersion = input;    return true;   }   else   {    formatVersion = 9999;    return false;   }}bool RinexFile::setRinexFileType(string input){  rinexFileType = input[0];  return true;}bool RinexFile::setSatSystem(string input){  satSystem = input[0];  return true;}bool RinexFile::setRinexProgram(string input){  rinexProgram = input.substr(0,20);  return true;}bool RinexFile::setCreatedByAgency(string input){  createdByAgency = input.substr(0,20);  return true;}bool RinexFile::setDateFileCreated(string input){  dateFileCreated = input.substr(0,20);  return true;}bool RinexFile::incrementNumberErrors(unsigned long n){  numberErrors = numberErrors + n;  return true;}bool RinexFile::incrementNumberWarnings(unsigned long n){  numberWarnings = numberWarnings + n;  return true;}bool RinexFile::incrementNumberLinesRead(unsigned long n){  numberLinesRead = numberLinesRead + n;  return true;}bool RinexFile::setCurrentEpoch(DateTime input){  DateTime  Jan1_1980, Dec31_2079;    Jan1_1980.SetYMDHMS(1980,1,1,0,0,0.00000001);    Dec31_2079.SetYMDHMS(2079,12,31,23,59,59.99999999);    if( input >= Jan1_1980 && input <= Dec31_2079 )    {       currentEpoch = input;       return true;    }    else    {       currentEpoch.SetYMDHMS( 9999, 1, 1, 0, 0, 0.0 );       return false;    }}void RinexFile::appendToErrorMessages(string errMessage){  string temp = "---------------------------------------"; // 39 chars  errorMessages << temp << temp << endl << errMessage << endl;  numberErrors++;  // Since an error has occured, output all warnings and  // errors that have been logged up to this point.  cerr << "An error has occurred for file: " << getPathFilename() << endl  << endl << "Here are the Warning Messages for this file:" << endl  << getWarningMessages() << endl  << endl << "Here are the Error Messages for this file:" << endl  << getErrorMessages() << endl << endl;}void RinexFile::appendToWarningMessages(string warnMessage){  string tempd = "---------------------------------------"; // 39 chars  const string resetStr = " \0";  warningMessages << tempd << tempd << endl << warnMessage << endl;  numberWarnings++;  tempStream.str(resetStr);  // clear tempStream for use by the next warning}//Selectorsstring RinexFile::getPathFilename(){    return (pathFilename);}ios::openmode RinexFile::getFileMode(){    return (fileMode);}RinexHeader RinexFile::getRinexHeaderImage(){

⌨️ 快捷键说明

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