Esempio n. 1
0
void NavSum::getNewTime(DayTime& dt)
{
   short week = -1;
   double SOW;
   string buf;
   short done = 0;
   
   while (!done)
   {
      cout << " Enter full GPS week: ";
      getline(cin, buf);
      istringstream instr(buf);
      instr >> week;
      if (week != -1)
         done = 1;
      else 
         cout << " Error entering week.  Please try again." << endl;
   }
   
      // Now reset flag and get SOW
   done = 0;
   while (!done)
   {
      cout << " Enter GPS seconds of week: ";
      getline(cin,buf);
      istringstream instr(buf);
      instr >> SOW;
      if ((SOW >= 0.0L) && (SOW < 604800.0L) )
         done = 1;
      else 
         cout << " Error entering SOW.  Please try again." << endl;
   }
   dt.setGPSfullweek(week, SOW);
}
Esempio n. 2
0
int ReadStatsFile(string statsfile)
{
try
{
   ifstream sifs;

   sifs.open(statsfile.c_str());
   if (!sifs) return -5;
   else
   {
      lofs << "Opened stats file for input " << statsfile << endl;
      bool wtd;
      const int BUFF_SIZE=1024;
      char buffer[BUFF_SIZE];
      string line;
      vector<string> fields;
      int i;
      while (sifs.getline(buffer,BUFF_SIZE))
      {
         line = buffer;
         StringUtils::stripTrailing(line,'\r');
         fields.clear();
         for (i=0; i<StringUtils::numWords(line); i++)
         {
            fields.push_back(StringUtils::word(line,i));
         }

         if (fields[0] == string("STAT"))
         {
            i = StringUtils::asInt(fields[1]);
            if (fields[9] == string("Y")) wtd = true; else wtd = false;
            HGridStats[i].Load(
                               (unsigned int)(StringUtils::asInt(fields[4])),
                               StringUtils::asDouble(fields[5]),                // min
                               StringUtils::asDouble(fields[6]),                // max
                               StringUtils::asDouble(fields[7]),                // ave
                               StringUtils::asDouble(fields[8]),                // var
                               wtd,
                               StringUtils::asDouble(fields[10])                // norm
                              );
            if (fields[16] == string("Y")) wtd = true; else wtd = false;
            NGridStats[i].Load(
                               (unsigned int)(StringUtils::asInt(fields[11])),
                               StringUtils::asDouble(fields[12]),               // min
                               StringUtils::asDouble(fields[13]),               // max
                               StringUtils::asDouble(fields[14]),               // ave
                               StringUtils::asDouble(fields[15]),               // var
                               wtd,
                               StringUtils::asDouble(fields[17])                // norm
                              );
         }
         else if (fields[0] == string("WORSTN"))
         {
            IworstN = StringUtils::asInt(fields[1]);
            TworstN.setGPSfullweek(StringUtils::asInt(fields[2]),
        			   StringUtils::asDouble(fields[3]));
            WorstN = StringUtils::asDouble(fields[6]);
            NtrofN = StringUtils::asInt(fields[7]);
         }
         else if (fields[0] == string("WORSTH"))
         {
            IworstH = StringUtils::asInt(fields[1]);
            TworstH.setGPSfullweek(StringUtils::asInt(fields[2]),
        			   StringUtils::asDouble(fields[3]));
            WorstH = StringUtils::asDouble(fields[6]);
            NpeakH = StringUtils::asInt(fields[7]);
         }
         else if (fields[0] == string("WORSTP"))
         {
            IworstP = StringUtils::asInt(fields[1]);
            TworstP.setGPSfullweek(StringUtils::asInt(fields[2]),
        			   StringUtils::asDouble(fields[3]));
            WorstP = StringUtils::asDouble(fields[6]);
            NpeakP = StringUtils::asInt(fields[7]);
         }
      } // end loop over lines in file
   }

   sifs.close();

   return 0;
}
catch(Exception& e) { GPSTK_RETHROW(e); }
}
Esempio n. 3
0
//------------------------------------------------------------------------------------
// Input the time table from a file
int ReadTimeTable(void) throw(Exception)
{
try {
   int week;
   double sow;
   string line;
   DayTime tt;

   // open an input file for all timetables
   if(CI.Debug) oflog << "Try to open time table file " << CI.TimeTableFile << endl;
   ifstream ttifs(CI.TimeTableFile.c_str());
   if(!ttifs) {
      cerr << "Failed to open input time table file " << CI.TimeTableFile << endl;
      return -3;
   }

   //REF site site sat week use_first use_last data_start data_end
   do {
      getline(ttifs,line);
      stripTrailing(line,'\r');
      if(ttifs.eof() || !ttifs.good()) break;

      if(line.size() <= 0) continue;                              // skip blank lines
      if(line[0] == '#') continue;                                // skip comments
      if(numWords(line) < 9) continue; // TD msg?    // skip bad lines
      if(words(line,0,1) != string("REF")) continue; // only REF lines
      TTSegment ts;
      ts.site1 = words(line,1,1);
      ts.site2 = words(line,2,1);
      ts.sat.fromString(words(line,3,1));

      week = asInt(words(line,4,1));
      sow = asInt(words(line,5,1));
      tt.setGPSfullweek(week,sow);           // TD handle week rollover
      ts.first = int(0.5+(tt-FirstEpoch)/CI.DataInterval);

      sow = asInt(words(line,6,1));
      tt.setGPSfullweek(week,sow);
      ts.last = int(0.5+(tt-FirstEpoch)/CI.DataInterval);

      sow = asInt(words(line,7,1));
      tt.setGPSfullweek(week,sow);
      ts.start = int(0.5+(tt-FirstEpoch)/CI.DataInterval);

      sow = asInt(words(line,8,1));
      tt.setGPSfullweek(week,sow);
      ts.end = int(0.5+(tt-FirstEpoch)/CI.DataInterval);

      //ts.minelev = ts.maxelev = 0.0;
      ts.length = ts.end - ts.start + 1;
      ts.findElev();
      TimeTable.push_back(ts);

   } while(1);
   // close the output timetable file
   ttifs.close();

   oflog << "Read time table from file " << CI.TimeTableFile << endl;

   return 0;
}
catch(Exception& e) { GPSTK_RETHROW(e); }
catch(exception& e) { Exception E("std except: "+string(e.what())); GPSTK_THROW(E); }
catch(...) { Exception e("Unknown exception"); GPSTK_THROW(e); }
}