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

📄 intrpsp3.cpp

📁 这是用于生成GPS星空图的一个c++程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// intrpSP3.cpp// Methods for reading and interpolating SP3 precise ephemerides#include <sstream>#include <iomanip>#include "datetime.h"#include "intrpSP3.h"using namespace std;using namespace NGSdatetime;const double EVCF[5][5] = {{ 1.7873015873015873e+00,-0.9359567901234568e+00, 0.1582175925925926e+00,-0.9755291005291005e-02, 0.1929012345679012e-03},{-0.4960317460317460e+00, 0.6057098765432098e+00,-0.1171296296296296e+00, 0.7605820105820106e-02,-0.1543209876543210e-03},{ 0.1206349206349206e+00,-0.1632716049382716e+00, 0.4606481481481481e-01,-0.3505291005291005e-02, 0.7716049382716048e-04},{-0.1984126984126984e-01, 0.2779982363315696e-01,-0.8796296296296296e-02, 0.8597883597883598e-03,-0.2204585537918871e-04},{ 0.1587301587301587e-02,-0.2259700176366843e-02, 0.7523148148148148e-03,-0.8267195767195767e-04, 0.2755731922398589e-05} };  // the Everett coefficientsconst double MFACT[9] = { 1.0, 3.0, 5.0, 7.0, 9.0,     2.0, 4.0, 6.0, 18.0 }; // multiplicative factors//================== SP3File class =============================SP3File::SP3File() {    pathFilename = "nofilename.out";    fileMode = ios_base::out;}SP3File::SP3File(string inputFilePath, ios_base::openmode mode){    string record;    pathFilename = inputFilePath;    fileMode = mode;    fileStream.open( pathFilename.c_str(), fileMode );    if( ! fileStream )    {	cerr << "Error: unable to open SP3 file in constructor: "	     << pathFilename << " using mode: " << fileMode << endl;//        SP3FileException  excep( "Error opening file " );//	excep.ErrorMessage.append( pathFilename );//	throw excep;    }}// DestructorSP3File::~SP3File(){    pathFilename = "nofilename.out";    fileMode = ios_base::out;    fileStream.close();}void SP3File::setPathFilenameMode(string inputFilePath,                                    ios_base::openmode mode){    pathFilename = inputFilePath;    fileMode = mode;    fileStream.open( pathFilename.c_str(), fileMode );    if( ! fileStream )    {	cerr << "Error: unable to open SP3 file in setPathFilenameMode: "	     << pathFilename << " using mode: " << fileMode << endl;//        SP3FileException  excep( "Error opening file " );//	excep.ErrorMessage.append( pathFilename );//	throw excep;    }}void SP3File::initHeaderInfo(){   int i,j,k,l;   formatVersion = ' ';   modeFlag = ' ';   SP3StartTime.SetYMDHMS(1999,1,1,0,0,0.0);   SP3EndTime.SetYMDHMS(1999,1,1,0,0,0.0);   numberSP3epochs = 0;   dataUsed = "";   coordFrame = "";   orbitType = "";   sourceAgency = "";   gpsWeek = 9999;   secsOfWeek = 0.0;   SP3interval = 0.0;   SP3mjd = 999999;   SP3fmjd = 0.0;   numberSP3svs = 0;   numberGoodPRNs = 0;   numberGoodACCURs = 0;   for( i = 0; i < MAXSVSEPH + 1; i++)   {     sp3PRNs[i] = 0;     svAccur[i] = 0;   }   lastEpochRead = 0;   currEpoch = 0;   numberSVparams = 0;   for(i = 0; i < 5 + 1;  i++ )     for(j = 0; j < 2 + 1; j++ )       for(k = 0; k < MAXPARAM + 1; k++ )         for(l = 0; l < MAXSVSEPH + 1; l++ )            intrpCoeff[i][j][k][l] = 0.0;   for(i = 0; i < 10 + 1; i++ )     for(j = 0; j < MAXPARAM + 1; j++ )       for(k = 0; k < MAXSVSEPH + 1; k++ )            inputValues[i][j][k] = 0.0;};int SP3File::readHeader(){   string      recType;   string      inputRec;   string      temp;   char        nextFirstChar;   char        inputRecC[ 256 ];   long        year, month, day, hour, minute;//   long        mjd;   double      sec;//   double      fmjd;//   int         numsvs = 0;   int         indexPRN = 0;   int         indexACC = 0;   int         lineLength = 0;   int         i, prn, accur;//   int         reply;   prn = 0;   initHeaderInfo();   // position the stream at the beginning of the file   fileStream.seekg(0);   while( fileStream.getline(inputRecC, 255, '\n') )   {      inputRec = inputRecC;      recType = inputRec.substr( 0, 2 );      if( recType[0] == '#' && recType[1] != '#' )      {	  formatVersion = recType[1];//cout << formatVersion << endl;  cin >> reply;	  if( formatVersion != 'a' && formatVersion != 'A' )	  {	      cerr << "This program reads only SP3 files with format-mode: aP "	      << endl << "This file has format version: " << formatVersion << endl;	      return( -1 );          }	  modeFlag = inputRec[2];//cout << modeFlag << endl;  cin >> reply;	  if( modeFlag != 'P' && modeFlag != 'p' )	  {	      cerr << "This program reads only SP3 files with format-mode: aP "	      << endl << "This file has mode flag: " << modeFlag << endl;	      return( -1 );          }          temp = inputRec.substr( 3, 4 );            year = atol( temp.c_str() );          temp = inputRec.substr( 8, 2 );            month = atol( temp.c_str() );          temp = inputRec.substr(11, 2 );            day = atol( temp.c_str() );          temp = inputRec.substr(14, 2 );            hour = atol( temp.c_str() );          temp = inputRec.substr(17, 2 );            minute = atol( temp.c_str() );          temp = inputRec.substr(20, 11 );            sec = atof( temp.c_str() );	  SP3StartTime.SetYMDHMS(year, month, day, hour, minute, sec);	  SP3EndTime.SetYMDHMS(year, month, day, hour, minute, sec); // this will get added to later          temp = inputRec.substr(32, 7 );            numberSP3epochs = (unsigned long) atol( temp.c_str() );          dataUsed = inputRec.substr(40, 5 );          coordFrame = inputRec.substr(46, 5 );          orbitType = inputRec.substr(52, 3 );          sourceAgency = inputRec.substr(56, 4 );      }      else if( recType[0] == '#' && recType[1] == '#' )      {          temp = inputRec.substr(3, 4 );            gpsWeek = (unsigned long) atol( temp.c_str() );          temp = inputRec.substr(8, 15 );            secsOfWeek = atof( temp.c_str() );          temp = inputRec.substr(24, 14 );            SP3interval = atof( temp.c_str() );          temp = inputRec.substr(39, 5 );            SP3mjd = atol( temp.c_str() );          temp = inputRec.substr(45, 15 );            SP3fmjd = atof( temp.c_str() );      }      else if( recType[0] == '+' && recType[1] == ' ' )      {	  if( numberSP3svs == 0 )	  {            temp = inputRec.substr(4, 2 );              numberSP3svs = (unsigned short) atoi( temp.c_str() );            lineLength = inputRec.size();	    for( i = 9; i < lineLength; i=i+3 )	    {              temp = inputRec.substr( i, 3 );	      prn = atoi( temp.c_str() );	      if( prn > 0 )	      {	        sp3PRNs[indexPRN + 1] = (unsigned short) prn;	        indexPRN++;	      }            }          }	  else	  {            lineLength = inputRec.size();	    for( i = 9; i < lineLength; i=i+3 )	    {              temp = inputRec.substr( i, 3 );	      prn = atoi( temp.c_str() );	      if( prn > 0 )	      {	        sp3PRNs[indexPRN + 1] = (unsigned short) prn;	        indexPRN++;	      }            }          }      }      else if( recType[0] == '+' && recType[1] == '+' )      {         lineLength = inputRec.size();	 for( i = 9; i < lineLength; i=i+3 )	 {           temp = inputRec.substr( i, 3 );	   accur = atoi( temp.c_str() );	   if( accur > 0 )	   {	     svAccur[indexACC + 1] = (unsigned short) accur;	     if( accur <= 0 )	     {	       cerr << "WARNING ! accuracy code ZERO for PRN: " <<	       sp3PRNs[indexACC + 1] << endl;               sp3PRNs[indexACC + 1] = -1.0 * sp3PRNs[indexACC + 1];             }	     indexACC++;	   }         }      }      nextFirstChar = (char) fileStream.peek();      if( nextFirstChar == '*' ) break;  // exit while loop   } // end of while loop to read all SP3 header records   numberSVparams = 4;   numberGoodPRNs = (unsigned short) indexPRN;   numberGoodACCURs = (unsigned short) indexPRN;   SP3EndTime = SP3EndTime +     (double)(numberSP3epochs - 1)*SP3interval/86400.0;   if( numberGoodPRNs <= 0  ||  numberSP3svs != numberGoodPRNs )

⌨️ 快捷键说明

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