示例#1
0
   void RinexNavData::getPRNEpoch(const string& currentLine)
      throw(StringException, FFStreamError)
   {
      try
      {
            // check for spaces in the right spots...
         for (int i = 2; i <= 17; i += 3)
            if (currentLine[i] != ' ')
               throw(FFStreamError("Badly formatted line"));

         PRNID = asInt(currentLine.substr(0,2));

         short yr = asInt(currentLine.substr(2,3));
         short mo = asInt(currentLine.substr(5,3));
         short day = asInt(currentLine.substr(8,3));
         short hr = asInt(currentLine.substr(11,3));
         short min = asInt(currentLine.substr(14,3));
         double sec = asDouble(currentLine.substr(17,5));

            // years 80-99 represent 1980-1999
         const int rolloverYear = 80;
         if (yr < rolloverYear)
            yr += 100;
         yr += 1900;

         // Real Rinex has epochs 'yy mm dd hr 59 60.0' surprisingly often....
         double ds=0;
         if(sec >= 60.) { ds=sec; sec=0.0; }
         time = CivilTime(yr,mo,day,hr,min,sec).convertToCommonTime();
         if(ds != 0) time += ds;

         Toc = (static_cast<GPSWeekSecond>(time)).sow;
         af0 = gpstk::StringUtils::for2doub(currentLine.substr(22,19));
         af1 = gpstk::StringUtils::for2doub(currentLine.substr(41,19));
         af2 = gpstk::StringUtils::for2doub(currentLine.substr(60,19));
      }
      catch (std::exception &e)
      {
         FFStreamError err("std::exception: " +
                           string(e.what()));
         GPSTK_THROW(err);
      }
   }
示例#2
0
   void Rinex3NavData::getPRNEpoch(Rinex3NavStream& strm)
      throw(StringException, FFStreamError)
   {
      try {
         int i;
         short yr,mo,day,hr,min;
         double dsec;

         string line;
         while(line.empty())        // ignore blank lines in place of epoch lines
            strm.formattedGetLine(line, true);

         if(strm.header.version >= 3) {
            // check for spaces in the right spots...
            if(line[3] != ' ')
               throw(FFStreamError("Badly formatted epoch line"));
            for(i = 8; i <= 20; i += 3)
               if(line[i] != ' ')
                  throw(FFStreamError("Badly formatted epoch line"));

            satSys = line.substr(0,1);
            PRNID = asInt(line.substr(1,2));
            sat.fromString(line.substr(0,3));

            yr  = asInt(line.substr( 4,4));
            mo  = asInt(line.substr( 9,2));
            day = asInt(line.substr(12,2));
            hr  = asInt(line.substr(15,2));
            min = asInt(line.substr(18,2));
            dsec = asDouble(line.substr(21,2));
         }
         else {                  // RINEX 2
            for(i=2; i <= 17; i+=3)
               if(line[i] != ' ') {
                  throw(FFStreamError("Badly formatted epoch line"));
               }

            satSys = string(1,strm.header.fileSys[0]);
            PRNID = asInt(line.substr(0,2));
            sat.fromString(satSys + line.substr(0,2));

            yr  = asInt(line.substr( 2,3));
            if(yr < 80) yr += 100;     // rollover is at 1980
            yr += 1900;
            mo  = asInt(line.substr( 5,3));
            day = asInt(line.substr( 8,3));
            hr  = asInt(line.substr(11,3));
            min = asInt(line.substr(14,3));
            dsec = asDouble(line.substr(17,5));
         }

         // Fix RINEX epochs of the form 'yy mm dd hr 59 60.0'
         short ds = 0;
         if(dsec >= 60.) { ds = dsec; dsec = 0; }
         time = CivilTime(yr,mo,day,hr,min,dsec).convertToCommonTime();
         if(ds != 0) time += ds;

         // specify the time system based on satellite system
         time.setTimeSystem(TimeSystem::Any);
         if(satSys == "G") time.setTimeSystem(TimeSystem::GPS);
         if(satSys == "R") time.setTimeSystem(TimeSystem::GLO);
         if(satSys == "E") time.setTimeSystem(TimeSystem::GAL);
         if(satSys == "C") time.setTimeSystem(TimeSystem::BDT);
         if(satSys == "J") time.setTimeSystem(TimeSystem::QZS);
         if(satSys == "S") time.setTimeSystem(TimeSystem::GPS);

         // TOC is the clock time
         GPSWeekSecond gws(time);         // sow is system-independent
         Toc = gws.sow;

         if(strm.header.version < 3) {    // Rinex 2.*
            if(satSys == "G") {
               af0 = StringUtils::for2doub(line.substr(22,19));
               af1 = StringUtils::for2doub(line.substr(41,19));
               af2 = StringUtils::for2doub(line.substr(60,19));
            }
            else if(satSys == "R" || satSys == "S") {
               TauN   =      StringUtils::for2doub(line.substr(22,19));
               GammaN =      StringUtils::for2doub(line.substr(41,19));
               MFtime =(long)StringUtils::for2doub(line.substr(60,19));
               if(satSys == "R") {     // make MFtime consistent with R3.02
                  MFtime += int(Toc/86400) * 86400;
               }
            }
         }
         else if(satSys == "G" || satSys == "E" || satSys == "C" || satSys == "J") {
            af0 = StringUtils::for2doub(line.substr(23,19));
            af1 = StringUtils::for2doub(line.substr(42,19));
            af2 = StringUtils::for2doub(line.substr(61,19));
         }
         else if(satSys == "R" || satSys == "S") {
            TauN   =      StringUtils::for2doub(line.substr(23,19));
            GammaN =      StringUtils::for2doub(line.substr(42,19));
            MFtime =(long)StringUtils::for2doub(line.substr(61,19));
         }
      }
      catch (std::exception &e)
      {
         FFStreamError err("std::exception: " + string(e.what()));
         GPSTK_THROW(err);
      }
   }
示例#3
0
   void RinexNavHeader::reallyGetRecord(FFStream& ffs) 
      throw(std::exception, FFStreamError, StringException)
   {
      RinexNavStream& strm = dynamic_cast<RinexNavStream&>(ffs);
      
         // if already read, just return
      if (strm.headerRead == true)
         return;
      
      valid = 0;
      
         // clear out anything that was unsuccessfully read the first
      commentList.clear();
      
      while (! (valid & endValid))
      {
         string line;
         strm.formattedGetLine(line);
         StringUtils::stripTrailing(line);

         if (line.length()==0) continue;
         else if (line.length()<60 || line.length()>80)
         {
            FFStreamError e("Invalid line length");
            GPSTK_THROW(e);
         }
         
         string thisLabel(line, 60, 20);
         
         if (thisLabel == versionString)
         {
            version = asDouble(line.substr(0,20));
            fileType = strip(line.substr(20,20));
            if ( (fileType[0] != 'N') &&
                 (fileType[0] != 'n'))
            {
               FFStreamError e("This isn't a Rinex Nav file");
               GPSTK_THROW(e);
            }
            valid |= versionValid;
         }
         else if (thisLabel == runByString)
         {
            fileProgram = strip(line.substr(0,20));
            fileAgency = strip(line.substr(20,20));
            date = strip(line.substr(40,20));
            valid |= runByValid;
         }
         else if (thisLabel == commentString)
         {
            commentList.push_back(strip(line.substr(0,60)));
            valid |= commentValid;
         }
         else if (thisLabel == ionAlphaString)
         {
            for(int i = 0; i < 4; i++)
               ionAlpha[i] = gpstk::StringUtils::for2doub(line.substr(2 + 12 * i,12));
            valid |= ionAlphaValid;
         }
         else if (thisLabel == ionBetaString)
         {
            for(int i = 0; i < 4; i++)
               ionBeta[i] = gpstk::StringUtils::for2doub(line.substr(2 + 12 * i,12));
            valid |= ionBetaValid;
         }
         else if (thisLabel == deltaUTCString)
         {
            A0 = gpstk::StringUtils::for2doub(line.substr(3,19));
            A1 = gpstk::StringUtils::for2doub(line.substr(22,19));
            UTCRefTime = asInt(line.substr(41,9));
            UTCRefWeek = asInt(line.substr(50,9));
            valid |= deltaUTCValid;
         }
         else if (thisLabel == leapSecondsString)
         {
            leapSeconds = asInt(line.substr(0,6));
            valid |= leapSecondsValid;
         }
         else if (thisLabel == endOfHeader)
         {
            valid |= endValid;
         }
         else
         {
            throw(FFStreamError("Unknown header label at line " + 
                                asString<size_t>(strm.lineNumber)));
         }
      }
      
      unsigned long allValid;
      if      (version == 2.0)      allValid = allValid20;
      else if (version == 2.1)      allValid = allValid21;
      else if (version == 2.11)     allValid = allValid211;
      else
      {
         FFStreamError e("Unknown or unsupported RINEX version " + 
                         asString(version));
         GPSTK_THROW(e);
      }
      
      if ( (allValid & valid) != allValid)
      {
         FFStreamError e("Incomplete or invalid header");
         GPSTK_THROW(e);               
      }            
      
         // we got here, so something must be right...
      strm.header = *this;
      strm.headerRead = true;      
   }