当前位置: 首页>>代码示例>>C++>>正文


C++ CommonTime::setTimeSystem方法代码示例

本文整理汇总了C++中CommonTime::setTimeSystem方法的典型用法代码示例。如果您正苦于以下问题:C++ CommonTime::setTimeSystem方法的具体用法?C++ CommonTime::setTimeSystem怎么用?C++ CommonTime::setTimeSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommonTime的用法示例。


在下文中一共展示了CommonTime::setTimeSystem方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: adjustBeginningValidity

void OrbElemRinex::adjustBeginningValidity()
{
    if (!dataLoaded()) return;

    // The nominal beginning of validity is calculated from
    // the fit interval and the Toe.  In RINEX the fit duration
    // in hours is stored in the file.
    long  oneHalfInterval = ((long)fitDuration/2) * 3600;

    // If we assume this is the SECOND set of elements in a set
    // (which is an assumption of this function - see the .hpp) then
    // the "small offset in Toe" will actually push the Toe-oneHalfInterval
    // too early. For example, consider the following case.
    //         Toe : 19:59:44  (really near 20:00:00)
    //  first xMit : 18:00:00  (nominal)
    // Blindly setting beginValid top Toe - 1/2 fit interval will
    // result in 17:59:44.  But 18:00:00 actually is the right answer
    // because the -16 second offset is an artifact.
    //
    // Therefore, we are FIRST going to remove that offset,
    // THEN determine beginValid.
    long sow = (long) (static_cast<GPSWeekSecond>(ctToe)).sow;
    short week = (static_cast<GPSWeekSecond>(ctToe)).week;
    sow = sow + (3600 - (sow%3600));
    CommonTime adjustedToe = GPSWeekSecond(week, (double) sow);
    adjustedToe.setTimeSystem(TimeSystem::GPS);

    beginValid = adjustedToe - oneHalfInterval;
    return;
}
开发者ID:xiangyan66,项目名称:GPSTk,代码行数:30,代码来源:OrbElemRinex.cpp

示例2: e

CommonTime Rinex3ObsData::parseTime(const string& line,
                                    const Rinex3ObsHeader& hdr,
                                    const TimeSystem& ts) const
throw(FFStreamError)
{
    try
    {
        // check if the spaces are in the right place - an easy
        // way to check if there's corruption in the file
        if( (line[ 1] != ' ') || (line[ 6] != ' ') || (line[ 9] != ' ') ||
                (line[12] != ' ') || (line[15] != ' ') || (line[18] != ' ') ||
                (line[29] != ' ') || (line[30] != ' '))
        {
            FFStreamError e("Invalid time format");
            GPSTK_THROW(e);
        }

        // if there's no time, just return a bad time
        if(line.substr(2,27) == string(27, ' '))
            return CommonTime::BEGINNING_OF_TIME;

        int year, month, day, hour, min;
        double sec;

        year  = asInt(   line.substr( 2,  4));
        month = asInt(   line.substr( 7,  2));
        day   = asInt(   line.substr(10,  2));
        hour  = asInt(   line.substr(13,  2));
        min   = asInt(   line.substr(16,  2));
        sec   = asDouble(line.substr(19, 11));

        // Real Rinex has epochs 'yy mm dd hr 59 60.0' surprisingly often.
        double ds = 0;
        if(sec >= 60.)
        {
            ds = sec;
            sec = 0.0;
        }

        CommonTime rv = CivilTime(year,month,day,hour,min,sec).convertToCommonTime();
        if(ds != 0) rv += ds;

        rv.setTimeSystem(ts);

        return rv;
    }
    // string exceptions for substr are caught here
    catch (std::exception &e)
    {
        FFStreamError err("std::exception: " + string(e.what()));
        GPSTK_THROW(err);
    }
    catch (gpstk::Exception& e)
    {
        FFStreamError err(e);
        GPSTK_THROW(err);
    }
}  // end parseTime
开发者ID:rumkex,项目名称:GPSTk,代码行数:58,代码来源:Rinex3ObsData.cpp

示例3: timeSystemTest

        //============================================================
        // Test Suite: timeSystemTest()
        //============================================================
        //
        // Test will check the TimeSystem comparisons when using
        // the comparison operators.
        //
        //============================================================
        int timeSystemTest( void )
        {
            TestUtil testFramework( "CommonTime", "Differing TimeSystem == Operator", __FILE__, __LINE__ );

            CommonTime GPS1;       GPS1.set( 1000, 200, 0.2, TimeSystem(2) );
            CommonTime GPS2;       GPS2.set( 100,  200, 0.2, TimeSystem(2) );
            CommonTime UTC1;       UTC1.set( 1000, 200, 0.2, TimeSystem(5) );
            CommonTime UNKNOWN; UNKNOWN.set( 1000, 200, 0.2, TimeSystem(0) );
            CommonTime ANY;         ANY.set( 1000, 200, 0.2, TimeSystem(1) );

            //----------------------------------------
            // ???
            //----------------------------------------
            testFramework.assert( !(GPS1 == GPS2), "Verify same Time System but different time inequality", __LINE__ );
            testFramework.assert( GPS1.getTimeSystem() == GPS2.getTimeSystem(), "Verify same Time System equality", __LINE__ );

            //----------------------------------------
            // Differing TimeSystem != Operator
            //----------------------------------------
            testFramework.changeSourceMethod( "Differing TimeSystem != Operator" );
            testFramework.assert( GPS1 != UTC1,    "Verify different Time System but same time inequality", __LINE__ );
            testFramework.assert( GPS1 != UNKNOWN, "Verify different Time System but same time inequality", __LINE__ );

            //----------------------------------------
            // ANY TimeSystem == Operator
            //----------------------------------------
            testFramework.changeSourceMethod( "ANY TimeSystem == Operator" );
            testFramework.assert( GPS1 == ANY,    "Verify TimeSystem=ANY does not matter in TimeSystem=GPS comparisons",    __LINE__ );
            testFramework.assert( UTC1 == ANY,    "Verify TimeSystem=ANY does not matter in TimeSystem=UTC comparisons",    __LINE__ );
            testFramework.assert( UNKNOWN == ANY, "Verify TimeSystem=ANY does not matter in TimeSystem=UNKOWN comparisons", __LINE__ );

            //----------------------------------------
            // ANY TimeSystem < Operator
            //----------------------------------------
            testFramework.changeSourceMethod( "ANY TimeSystem < Operator" );
            testFramework.assert( !(GPS2 == ANY) && (GPS2 < ANY), "Verify TimeSystem=ANY does not matter in other operator comparisons", __LINE__ );

            //----------------------------------------
            // setTimeSystem
            //----------------------------------------
            testFramework.changeSourceMethod( "setTimeSystem" );
            UNKNOWN.setTimeSystem( TimeSystem(2) ); //Set the Unknown TimeSystem
            testFramework.assert( UNKNOWN.getTimeSystem()==TimeSystem(2), "Ensure resetting a Time System changes it", __LINE__ );

            //----------------------------------------
            // The End!
            //----------------------------------------
            return testFramework.countFails();
        }
开发者ID:vestuto,项目名称:GPSTk,代码行数:57,代码来源:CommonTime_T.cpp

示例4: main

int main(int argc, char *argv[])
{
   string Usage(
      "Usage: bc2sp3 <RINEX nav file(s)> [options]\n"
      " Read RINEX nav file(s) and write to SP3(a or c) file.\n"
      " Options (defaults):\n"
      "  --in <file>   Read the input file <file> (--in is optional, repeatable) ()\n"
      "  --out <file>  Name the output file <file> (sp3.out)\n"
      "  --tb <time>   Output beginning epoch; <time> = week,sec-of-week (earliest in input)\n"
      "  --te <time>   Output ending epoch; <time> = week,sec-of-week (latest in input)\n"
      "  --outputC     Output version c (no correlation) (otherwise a)\n"
      "  --msg \"...\"   Add ... as a comment to the output header (repeatable)\n"
      "  --verbose     Output to screen: dump headers, data, etc\n"
      "  --help        Print this message and quit\n"
      );
   if(argc < 2) { cout << Usage; return -1; }

   try
   {
      bool verbose=false;
      //char version_out='a';
      SP3Header::Version version_out(SP3Header::SP3a);
      int i,j;
      size_t k,nfile;
      string fileout("sp3.out");
      vector<string> inputFiles;
      vector<string> comments;
      map<SatID,long> IODEmap;
      CommonTime begTime=CommonTime::BEGINNING_OF_TIME;
      CommonTime endTime=CommonTime::END_OF_TIME;
      CommonTime tt;
      GPSEphemerisStore BCEph;
      SP3Header sp3header;
      SP3Data sp3data;

      for(i=1; i<argc; i++) {

         if(argv[i][0] == '-') {
            string arg(argv[i]);
            if(arg == string("--outputC")) {
               version_out = SP3Header::SP3c;   //'c';
               if(verbose) cout << " Output version c\n";
            }
            else if(arg == string("--in")) {
               inputFiles.push_back(string(argv[++i]));
               if(verbose) cout << " Input file name "
                  << inputFiles[inputFiles.size()-1] << endl;
            }
            else if(arg == string("--out")) {
               fileout = string(argv[++i]);
               if(verbose) cout << " Output file name " << fileout << endl;
            }
            else if(arg == string("--tb")) {
               arg = string(argv[++i]);
               int wk=StringUtils::asInt(StringUtils::stripFirstWord(arg,','));
               double sow=StringUtils::asDouble(StringUtils::stripFirstWord(arg,','));
               begTime=GPSWeekSecond(wk,sow);
	       begTime.setTimeSystem(TimeSystem::GPS);
               if(verbose) cout << " Begin time "
                  << printTime(begTime,"%Y/%02m/%02d %2H:%02M:%06.3f = %F/%10.3g")
                  << endl;
            }
            else if(arg == string("--te")) {
               arg = string(argv[++i]);
               int wk=StringUtils::asInt(StringUtils::stripFirstWord(arg,','));
               double sow=StringUtils::asDouble(StringUtils::stripFirstWord(arg,','));
               endTime=GPSWeekSecond(wk,sow);
	       endTime.setTimeSystem(TimeSystem::GPS);
               if(verbose) cout << " End time   "
                  << printTime(endTime,"%Y/%02m/%02d %2H:%02M:%06.3f = %F/%10.3g")
                  << endl;
            }
            else if(arg == string("--msg")) {
               comments.push_back(string(argv[++i]));
               if(verbose) cout << " Add comment " << comments[comments.size()-1]
                  << endl;
            }
            else if(arg == string("--help")) {
               cout << Usage;
               return -1;
            }
            else if(arg == string("--verbose"))
               verbose = true;
            else
               cout << "Ignore unknown option: " << arg << endl;
         }
         else {
            inputFiles.push_back(string(argv[i]));
            if(verbose) cout << " Input file name "
               << inputFiles[inputFiles.size()-1] << endl;
         }
      }

      if(inputFiles.size() == 0) {
         cout << "Error - no input filename specified. Abort.\n";
         return -1;
      }

      // open the output SP3 file
      SP3Stream outstrm(fileout.c_str(),ios::out);
//.........这里部分代码省略.........
开发者ID:JC5005,项目名称:GPSTk,代码行数:101,代码来源:bc2sp3.cpp

示例5: mixedScanTime

   void mixedScanTime( CommonTime& t,
                       const string& str,
                       const string& fmt )
   {
      try
      {
         using namespace gpstk::StringUtils;

            // Get the mapping of character (from fmt) to value (from str).
         TimeTag::IdToValue info;
         TimeTag::getInfo( str, fmt, info );
         
            // These indicate which information has been found.
         bool hsow( false ), hweek( false ), hfullweek( false ),
            hdow( false ), hyear( false ), hmonth( false ), hday( false ),
            hzcount( false ), hdoy( false ), hzcount29( false ), 
            hhour( false ), hmin( false ), hsec( false ),
            hsod( false ), hepoch( false ), hunixsec( false ),
            hunixusec( false ),
            hbdsw( false ), hqzsw( false ), hgalw( false ),
            hbdsfw( false ), hqzsfw( false ), hgalfw( false ),
            hbdse( false ), hqzse( false ), hgale( false);
#pragma unused(hunixsec,hunixusec)
            // MJD, Julian Date, ANSI time, Unix time, and 32-bit Zcounts
            // are treated as stand-alone types and are not mixed with others
            // if detected.
         
            // These variables will hold the values for use later.
         double isow, isod, isec;
         int iweek, ifullweek, idow, iyear, imonth, iday, izcount, idoy,
            izcount29, ihour, imin, iepoch;
         TimeSystem ts;

         for( TimeTag::IdToValue::iterator itr = info.begin();
              itr != info.end(); itr++ )
         {
            switch( itr->first )
            {
               case 'P':
                  ts.fromString(itr->second);
                  t.setTimeSystem(ts);
                  break;

               case 'Q':
                  t = MJD( asLongDouble(itr->second) );
                  return;

               case 'J':
                  t = JulianDate( asLongDouble(itr->second) );
                  return;
                  
               case 'C':
                  t = GPSWeekZcount().setZcount32( asInt(itr->second) );
                  return;

               case 'K':
                  t = ANSITime( asInt(itr->second) );
                  return;
                  
               case 'U':
               case 'u':
               {
                  UnixTime tt;
                  tt.setFromInfo( info );
                  t = tt.convertToCommonTime();
                  return;
               }
               break;

               case 'Z':
                  hzcount = true;
                  izcount = asInt(itr->second);
                  break;

               case 's':
                  hsod = true;
                  isod = asDouble(itr->second);
                  break;

               case 'g':
                  hsow = true;
                  isow = asDouble(itr->second);
                  break;

               case 'w':
                  idow = asInt(itr->second);
                  hdow = true;
                  break;

               case 'G':
                  hweek = true;
                  iweek = asInt(itr->second);
                  break;

               case 'F':
                  hfullweek = true;
                  ifullweek = asInt(itr->second);
                  break;

               case 'j':
//.........这里部分代码省略.........
开发者ID:Milfhunter,项目名称:gpstk,代码行数:101,代码来源:TimeString.cpp

示例6: scanTime

   void scanTime( CommonTime& t,
                  const string& str,
                  const string& fmt )
   {
      try
      {
         using namespace gpstk::StringUtils;

            // Get the mapping of character (from fmt) to value (from str).
         TimeTag::IdToValue info;
         TimeTag::getInfo( str, fmt, info );
         
            // These indicate which information has been found.
         bool hmjd( false ), hsow( false ), hweek( false ), hfullweek( false ),
            hdow( false ), hyear( false ), hmonth( false ), hday( false ),
            hzcount( false ), hdoy( false ), hzcount29( false ), 
            hzcount32( false ), hhour( false ), hmin( false ), hsec( false ),
            hsod( false ), hunixsec( false ), hunixusec( false ), 
            hepoch( false ), hansi( false ), hjulian( false ),
            hbdsw( false ), hqzsw( false ), hgalw( false ),
            hbdsfw( false ), hqzsfw( false ), hgalfw( false ),
            hbdse( false ), hqzse( false ), hgale( false);

            // These are to hold data that no one parses.
         int idow(0);
         TimeSystem ts;

         for( TimeTag::IdToValue::iterator itr = info.begin();
              itr != info.end(); itr++ )
         {
            switch( itr->first )
            {
               case 'P':
                  ts.fromString(itr->second);
                  t.setTimeSystem(ts);
                  break;

               case 'Q':
                  hmjd = true;
                  break;

               case 'Z':
                  hzcount = true;
                  break;

               case 's':
                  hsod = true;
                  break;

               case 'g':
                  hsow = true;
                  break;

               case 'w':
                  idow = asInt( itr->second );
                  hdow = true;
                  break;

               case 'G':
                  hweek = true;
                  break;

               case 'F':
                  hfullweek = true;
                  break;

               case 'j':
                  hdoy = true;
                  break;

               case 'b':
               case 'B':
                  hmonth = true;
                  break;

               case 'Y':
               case 'y':
                  hyear = true;
                  break;

               case 'a':
               case 'A':
                  {
                     hdow = true;
                     string thisDay = firstWord( itr->second );
                     lowerCase(thisDay);
                     if (isLike(thisDay, "sun.*")) idow = 0;
                     else if (isLike(thisDay, "mon.*")) idow = 1;
                     else if (isLike(thisDay, "tue.*")) idow = 2;
                     else if (isLike(thisDay, "wed.*")) idow = 3;
                     else if (isLike(thisDay, "thu.*")) idow = 4;
                     else if (isLike(thisDay, "fri.*")) idow = 5;
                     else if (isLike(thisDay, "sat.*")) idow = 6;
                     else
                     {
                        hdow = false;
                     }
                  }
                  break;
                  
//.........这里部分代码省略.........
开发者ID:Milfhunter,项目名称:gpstk,代码行数:101,代码来源:TimeString.cpp

示例7: corr

   double TimeSystemCorrection ::
   Correction(const CommonTime& ct) const
   {
      double corr(0.0), dt;
      TimeSystem fromTS(ct.getTimeSystem());
      GPSWeekSecond gpsws;
      CommonTime refTime;
      Exception e("Unable to compute correction - wrong TimeSystem");
      Exception eSBAS("TimeSystemCorrection SBAS <=> UTC has not been implemented");

      switch(type)
      {
         case GPUT:
            if(fromTS != TimeSystem::GPS && fromTS != TimeSystem::UTC)
            {
               GPSTK_THROW(e);
            }

               // dt = fromTime - refTime
            gpsws = GPSWeekSecond(refWeek,refSOW);
            refTime = gpsws.convertToCommonTime();
            refTime.setTimeSystem(fromTS);
            dt = ct - refTime;

            if(fromTS == TimeSystem::GPS)             // GPS => UTC
               corr = -A0-A1*dt;
            else                                      // UTC => GPS
               corr = A0+A1*dt;

            break;

         case GAUT:
            if(fromTS != TimeSystem::GAL && fromTS != TimeSystem::UTC)
            { GPSTK_THROW(e); }

               // dt = fromTime - refTime
            gpsws = GPSWeekSecond(refWeek,refSOW);
            refTime = gpsws.convertToCommonTime();
            refTime.setTimeSystem(fromTS);
            dt = ct - refTime;

            if(fromTS == TimeSystem::GAL)             // GAL => UTC
               corr = A0+A1*dt;
            else                                      // UTC => GAL
               corr = -A0-A1*dt;

            break;

         case SBUT:
            GPSTK_THROW(eSBAS);
            break;

         case GLUT:
            if(fromTS != TimeSystem::GLO && fromTS != TimeSystem::UTC)
            {
               GPSTK_THROW(e);
            }

            if(fromTS == TimeSystem::GLO)             // GLO => UTC
               corr = A0;
            else                                      // UTC => GLO
               corr = -A0;

            break;

         case GPGA:
            if(fromTS != TimeSystem::GPS && fromTS != TimeSystem::GAL)
            {
               GPSTK_THROW(e);
            }

               // dt = fromTime - refTime
            gpsws = GPSWeekSecond(refWeek,refSOW);
            refTime = gpsws.convertToCommonTime();
            refTime.setTimeSystem(fromTS);
            dt = ct - refTime;

            if(fromTS == TimeSystem::GPS)             // GPS => GAL
               corr = A0+A1*dt;
            else                                      // GAL => GPS
               corr = -A0-A1*dt;

            break;

         case GLGP:
            if(fromTS != TimeSystem::GLO && fromTS != TimeSystem::GPS)
            {
               GPSTK_THROW(e);
            }

            if(fromTS == TimeSystem::GLO)             // GLO => GPS
               corr = A0;
            else                                      // GPS => GLO
               corr = -A0;

            break;

         case QZGP:
            if(fromTS != TimeSystem::QZS && fromTS != TimeSystem::GPS)
            {
//.........这里部分代码省略.........
开发者ID:PPNav,项目名称:GPSTk,代码行数:101,代码来源:TimeSystemCorr.cpp


注:本文中的CommonTime::setTimeSystem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。