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

📄 rinex.cpp

📁 gps 读renix文件格式的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    return (rinexHeaderImage);}float   RinexFile::getFormatVersion() { return formatVersion; }char    RinexFile::getRinexFileType() { return rinexFileType; }char    RinexFile::getSatSystem() { return satSystem; }string  RinexFile::getRinexProgram() { return rinexProgram; }string  RinexFile::getCreatedByAgency() { return createdByAgency; }string  RinexFile::getDateFileCreated() { return dateFileCreated; }unsigned long  RinexFile::getNumberErrors() { return numberErrors; }unsigned long  RinexFile::getNumberWarnings() { return numberWarnings; }unsigned long  RinexFile::getNumberLinesRead() { return numberLinesRead; }DateTime       RinexFile::getCurrentEpoch() { return currentEpoch; }string RinexFile::getErrorMessages(){    return (errorMessages.str());}string RinexFile::getWarningMessages(){    return (warningMessages.str());}void RinexFile::readFileTypeAndProgramName(){   string         inputRec;   string         recordReadIn;   bool  endOfHeaderFound = false;   if( !validFirstLine(recordReadIn) )   {     tempStream << "Error: First Line is incorrect in File: "     << getPathFilename() << endl << recordReadIn << endl;     appendToErrorMessages( tempStream.str() );     RequiredRecordMissingException excep( tempStream.str() );     throw excep;   }   // read all Header lines from line 2 to END OF HEADER   // until the PGM / RUN BY / DATE record is found   while( !endOfHeaderFound )   {     if( !getline( inputStream, inputRec, '\n') )     {       // Error reading a header line of the RINEX File       tempStream << "Error reading a header line of file:" << endl       << getPathFilename() << endl;       appendToErrorMessages( tempStream.str() );       RinexReadingException  excep( tempStream.str() );       throw excep;     }     if( blankString(inputRec) )     {         if( formatVersion < 2.0 )         {           endOfHeaderFound = true;           break;   // end the while loop         }         else         {           continue;   // go to read the next record         }     }     if( inputRec.find( "END OF HEADER" ) == 60 )     {       endOfHeaderFound = true;       break;     }     else if( inputRec.find( "PGM / RUN BY / DATE" ) == 60 )     {       rinexProgram    = inputRec.substr(  0, 20 );       createdByAgency = inputRec.substr( 20, 20 );       dateFileCreated = inputRec.substr( 40, 20 );       endOfHeaderFound = true;       break;     }     else     {       continue;  // go to read the next record     }   } // end of while loop over all header records}// private methodsbool RinexFile::blankString(string inputStr){   for(int i = 0; i < (unsigned short)inputStr.length(); i++ )   {     if( inputStr[i] != ' ' )     {       return false;     }   }   return true;}void RinexFile::makeRecordLength80(string &inputRec){  string BlankString("                                        ");  size_t slen;   BlankString.append("                                        ");   if( inputRec.length() > RINEXRECSIZE )   {      tempStream << "Warning! On line #" << getNumberLinesRead() << ":"      << endl << inputRec << endl      << " the Rinex record has " << inputRec.length()      << " characters. This record will be truncated to 80 characters." << endl;      appendToWarningMessages( tempStream.str() );      inputRec = inputRec.substr(0,80);   }   else if( inputRec.length() > 80  &&  inputRec.length() <= RINEXRECSIZE )   {      inputRec = inputRec.substr(0,80);   }      else if( inputRec.length() < 80 )   {     slen = 80 - inputRec.length();     inputRec.append(BlankString,0,slen);   }}void RinexFile::truncateHeaderRec(string &inputRec){  string BlankString("                                        ");  size_t slen;   BlankString.append("                                        ");   if( inputRec.length() > RINEXRECSIZE )   {      tempStream << "Warning! On line #" << getNumberLinesRead() << ":"      << endl << inputRec << endl      << " the Rinex record has " << inputRec.length()      << " characters. This record will be truncated to 80 characters." << endl;      appendToWarningMessages( tempStream.str() );      inputRec = inputRec.substr(0,80);   }   else if( inputRec.length() > 80  &&  inputRec.length() <= RINEXRECSIZE )   {      inputRec = inputRec.substr(0,80);   }}bool RinexFile::alphasInString(string inputStr){   for(int i = 0; i < (unsigned short)inputStr.length(); i++ )   {     if( isalpha(inputStr[i]) )     {       return true;     }   }   return false;}bool RinexFile::validFirstLine(string &recordReadIn){  double tempD;  string inputRec;  string temp;   if( getline( inputStream, inputRec, '\n') )   {      incrementNumberLinesRead(1);      recordReadIn = inputRec;      bool problemsFound = false;      if ( inputRec.find( "RINEX VERSION / TYPE" ) == 60 )      {         temp = inputRec.substr( 0, 9 );         if( getDouble(temp, tempD) )           formatVersion = tempD;	 if( formatVersion < 1.0 || formatVersion > 2.1 )         {	   tempStream << "On line #" << getNumberLinesRead() << ":"           << endl << inputRec << endl           << "Format version is  incorrect:" << temp << "." << endl;           appendToWarningMessages( tempStream.str() );           problemsFound = true;         }         rinexFileType = inputRec.substr( 20, 1 )[0];	 if( rinexFileType != 'O' && rinexFileType != 'N' &&	   rinexFileType != 'M' && rinexFileType != 'G'  &&           rinexFileType != 'H' && rinexFileType != 'C')         {	   tempStream << "On line #" << getNumberLinesRead() << ":"           << endl << inputRec << endl           << "RINEX File Type is unacceptable:" << temp << "." << endl	   << "File Type must be O, N, M, G, H, or C !" << endl;           appendToWarningMessages( tempStream.str() );           problemsFound = true;         }	 if( rinexFileType == 'O' )	 {           satSystem = inputRec.substr( 40, 1 )[0];           // Satellite System "S" and "T" are currently not supported	   if( satSystem != 'G' && satSystem != ' ' &&	       satSystem != 'R' && satSystem != 'M' )           {	     tempStream << "On line #" << getNumberLinesRead() << ":"             << endl << inputRec << endl             << "Satellite System is unacceptable:" << temp << "." << endl	     << "Satellite System must be G, R, M, or blank !"  << endl             << "Sat System = >" << satSystem << "<  " << endl;             appendToWarningMessages( tempStream.str() );             problemsFound = true;           }         } // satSystem is only used for OBS files      }      else      {	 tempStream << "On line #" << getNumberLinesRead() << ":"         << endl << inputRec << endl         << "First line is not RINEX VERSION / TYPE ." << endl;         appendToWarningMessages( tempStream.str() );         problemsFound = true;      }      if( problemsFound )        return false;      else        return true;   }   else   {      // Error reading the first line of the OBS File      tempStream << "On line #" << getNumberLinesRead() << ":"      << endl << inputRec << endl      << "Error reading the first line of file:" << getPathFilename() << endl;      appendToErrorMessages( tempStream.str() );      RinexReadingException  excep( tempStream.str() );      throw excep;   }} bool RinexFile::getDouble(string input, double &output){  char *p;  bool blank_string = true;  output = strtod( input.c_str(), &p );  int l = strlen(p);  // HUGE_VAL should be defined in math.h, if not, define it in rinex.h  if( output == HUGE_VAL )  {    tempStream << "On line #" << getNumberLinesRead() << ","  << endl <<    "overflow error in getDouble() reading string: >" << input << "<" << endl;    appendToWarningMessages( tempStream.str() );    return false;  }  else if ( l > 0 )  {     for(int i = 0; i < l; i++ )       if( p[i] != ' ' ) blank_string = false;     if( blank_string )        return true;     else     {        tempStream << "On line # " << getNumberLinesRead() << ","        << " warning from function RinexFile::getDouble()." << endl        << "Illegal characters found while reading string: >"        << input << "< " << endl        << "The illegal characters are >" << p << "< " << endl;        appendToWarningMessages( tempStream.str() );        return false;     }  }  else     return true;}bool RinexFile::getLong(string input, long &output){  char *p;  bool blank_string = true;  output = strtol( input.c_str(), &p, 10 );  int l = strlen(p);  // LONG_MAX should be defined in _lim.h, if not, define it in rinex.h  if( output == LONG_MAX )  {    tempStream << "On line # " << getNumberLinesRead() << ","  << endl    << "overflow error in getLong() reading string: " << input << endl;    appendToWarningMessages( tempStream.str() );    return false;  }  // LONG_MIN should be defined in _lim.h, if not, define it in rinex.h  else if( output == LONG_MIN )  {    tempStream << "On line # " << getNumberLinesRead() << "," << endl    << "underflow error in getLong() reading string: " << input << endl;    appendToWarningMessages( tempStream.str() );    return false;  }  else if ( l > 0 )  {     for(int i = 0; i < l; i++ )       if( p[i] != ' ' ) blank_string = false;     if( blank_string )        return true;     else     {        tempStream << "On line # " << getNumberLinesRead() << ","        << " warning from function RinexFile::getLong()." << endl        << "Illegal characters found while reading string: >"        << input << "< " << endl        << "The illegal characters are >" << p << "< " << endl;        appendToWarningMessages( tempStream.str() );        return false;     }  }  else     return true;}bool RinexFile::validYMDHMS(long year, long month, long day, long hour,                            long minute, double second, string &warningString){  bool problemsFound = false;  int  daysInMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };  warningString = "";  if( year < 1980 || year > 2079)  {    warningString.append("The year is incorrect \n");    problemsFound = true;  }  if( month < 1 || month > 12)  {    warningString.append("The month is incorrect \n");    problemsFound = true;  }  if( day < 1 || day > daysInMonth[month - 1] )  {    warningString.append("The day is incorrect \n");    problemsFound = true;  }  if( hour < 0 || hour > 24)  {    warningString.append("The hour is incorrect \n");    problemsFound = true;  }  if( minute < 0 || minute > 60)  {    warningString.append("The minute is incorrect \n");    problemsFound = true;  }  if( second < 0.0 || second > 60.00000001)  {    warningString.append("The seconds are incorrect \n");    problemsFound = true;  }  if( problemsFound )    return false;  else    return true;}//========================== RinexObsFile Class ===============================// Initialize static data memberunsigned int  RinexObsFile::numberObsFiles = 0;   // no objects yet// ConstructorsRinexObsFile::RinexObsFile() : RinexFile()  // calls the base class constructor{    initializeData();    numberObsEpochs = 0;    numberObsFiles++;}RinexObsFile::RinexObsFile(string inputFilePath, ios::openmode mode): RinexFile(inputFilePath, mode){    initializeData();    numberObsEpochs = 0;    numberObsFiles++;}// DestructorRinexObsFile::~RinexObsFile(){   --numberObsFiles;}// Initilizersbool RinexObsFile::setMarkerName(string input){  markerName = input.substr(0,60);  return true;}bool RinexObsFile::setMarkerNumber(string input){  markerNumber = input.substr(0,20);  return true;}bool RinexObsFile::setObserverName(string input){  observerName = input.substr(0,20);  return true;}bool RinexObsFile::setObserverAgency(string input){  observerAgency = input.substr(0,40);  return true;}bool RinexObsFile::setReceiverNumber(string input){  receiverNumber = input.substr(0,20);  return true;}bool RinexObsFile::setReceiverType(string input){  receiverType = input.substr(0,20);  return true;}bool RinexObsFile::setReceiverFirmwareVersion(string input){  receiverFirmwareVersion = input.substr(0,20);  return true;}bool RinexObsFile::setAntennaNumber(string input){  antennaNumber = input.substr(0,20);  return true;}bool RinexObsFile::setAntennaType(string input){  antennaType = input.substr(0,20);  return true;}bool RinexObsFile::setApproxX(double input){  if( fabs(input) < 6400000.0 )  {    approxX = input;    return true;  }  else  {    approxX = 0.0;    return false;  }}bool RinexObsFile::setApproxY(double input){  if( fabs(input) < 6400000.0 )  {    approxY = input;    return true;  }  else  {    approxY = 0.0;    return false;  }}bool RinexObsFile::setApproxZ(double input){  if( fabs(input) < 6400000.0 )  {    approxZ = input;    return true;  }  else  {    approxZ = 0.0;    return false;  }}bool RinexObsFile::setAntennaDeltaH(double input){  if( input > 0.0  &&  input < 6400000.0 ) // No negative antenna heights  {    antennaDeltaH = input;    return true;  }  else  {    antennaDeltaH = 0.0;    return false;  }}bool RinexObsFile::setAntennaDeltaE(double input){  if( fabs(input) < 6400000.0 )  {    antennaDeltaE = input;    return true;  }  else  {    antennaDeltaE = 0.0;    return false;  }}bool RinexObsFile::setAntennaDeltaN(double input){  if( fabs(input) < 6400000.0 )  {    antennaDeltaN = input;

⌨️ 快捷键说明

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