// Dump the overhead information as a string containing a single line. // @throw Invalid Request if the required data has not been stored. string GalEphemeris::asString(void) const { if(!dataLoadedFlag) GPSTK_THROW(InvalidRequest("Data not loaded")); try { ostringstream os; CivilTime ct; os << "EPH E" << setfill('0') << setw(2) << satID.id << setfill(' '); ct = CivilTime(beginValid); os << printTime(ct," | %4Y %3j %02H:%02M:%02S |"); ct = CivilTime(ctToe); os << printTime(ct," %3j %02H:%02M:%02S |"); ct = CivilTime(ctToc); os << printTime(ct," %3j %02H:%02M:%02S |"); ct = CivilTime(endValid); os << printTime(ct," %3j %02H:%02M:%02S |"); ct = CivilTime(transmitTime); os << printTime(ct," %3j %02H:%02M:%02S | "); os << setw(3) << IODnav; //<< " | " << fixed << setprecision(2) << getAccuracy() os << " | 0x" << hex << setw(3) <<setfill('0')<< health <<dec<<setfill(' '); os << " | " << ((datasources & 0x5) ? "E15b" : "") // 1 or 4 << ((datasources & 0x2) ? "E5a " : "") //<< ((datasources & 0x4) ? "E5b " : "") << ((datasources & 0x100) ? " a1" : "") << ((datasources & 0x200) ? " b1" : "") << " |"; return os.str(); } catch(Exception& e) { GPSTK_RETHROW(e); } }
CivilTime RinexClockBase::parseTime(const string& line) const throw(FFStreamError) { if ( line.size() != 26 ) { FFStreamError e("Invalid time string length: " + StringUtils::asString(line.size())); GPSTK_THROW(e); } if ( line == std::string(26, ' ') ) { return CommonTime::BEGINNING_OF_TIME; } int year, month, day, hour, min; double sec; year = StringUtils::asInt( line.substr(0, 4) ); month = StringUtils::asInt( line.substr(4, 3) ); day = StringUtils::asInt( line.substr(7, 3) ); hour = StringUtils::asInt( line.substr(10, 3) ); min = StringUtils::asInt( line.substr(13, 3) ); sec = StringUtils::asDouble( line.substr(16, 10) ); return CivilTime(year, month, day, hour, min, sec); } // parseTime
void RinexClockData::reallyGetRecord(FFStream& ffs) throw(exception, FFStreamError, StringException) { // cast the stream to be an RinexClockStream RinexClockStream& strm = dynamic_cast<RinexClockStream&>(ffs); clear(); string line; strm.formattedGetLine(line,true); // true means 'expect possible EOF' stripTrailing(line); if(line.length() < 59) { FFStreamError e("Short line : " + line); GPSTK_THROW(e); } //cout << "Data Line: /" << line << "/" << endl; datatype = line.substr(0,2); site = line.substr(3,4); if(datatype == string("AS")) { strip(site); int prn(asInt(site.substr(1,2))); if(site[0] == 'G') sat = RinexSatID(prn,RinexSatID::systemGPS); else if(site[0] == 'R') sat = RinexSatID(prn,RinexSatID::systemGlonass); else { FFStreamError e("Invalid sat : /" + site + "/"); GPSTK_THROW(e); } site = string(); } time = CivilTime(asInt(line.substr( 8,4)), asInt(line.substr(12,3)), asInt(line.substr(15,3)), asInt(line.substr(18,3)), asInt(line.substr(21,3)), asDouble(line.substr(24,10)), TimeSystem::Any); int n(asInt(line.substr(34,3))); bias = asDouble(line.substr(40,19)); if(n > 1 && line.length() >= 59) sig_bias = asDouble(line.substr(60,19)); if(n > 2) { strm.formattedGetLine(line,true); stripTrailing(line); if(int(line.length()) < (n-2)*20-1) { FFStreamError e("Short line : " + line); GPSTK_THROW(e); } drift = asDouble(line.substr( 0,19)); if(n > 3) sig_drift = asDouble(line.substr(20,19)); if(n > 4) accel = asDouble(line.substr(40,19)); if(n > 5) sig_accel = asDouble(line.substr(60,19)); } } // end reallyGetRecord()
// Dump the overhead information as a string containing a single line. // @throw Invalid Request if the required data has not been stored. string GPSEphemeris::asString(void) const { if(!dataLoadedFlag) GPSTK_THROW(InvalidRequest("Data not loaded")); try { ostringstream os; CivilTime ct; os << "EPH G" << setfill('0') << setw(2) << satID.id << setfill(' '); ct = CivilTime(beginValid); os << printTime(ct," | %4Y %3j %02H:%02M:%02S |"); ct = CivilTime(ctToe); os << printTime(ct," %3j %02H:%02M:%02S |"); ct = CivilTime(ctToc); os << printTime(ct," %3j %02H:%02M:%02S |"); ct = CivilTime(endValid); os << printTime(ct," %3j %02H:%02M:%02S |"); ct = CivilTime(transmitTime); os << printTime(ct," %3j %02H:%02M:%02S | "); os << setw(3) << IODE << " | " << setw(3) << IODC << " | " << health; return os.str(); } catch(Exception& e) { GPSTK_RETHROW(e); } }
/** This function sets the time for this header. * It looks at \a line to obtain the needed information. */ CommonTime Rinex3ClockHeader::parseTime(const string& line) const { int year, month, day, hour, min; double sec; year = asInt( line.substr( 0, 4 )); month = asInt( line.substr( 4, 3 )); day = asInt( line.substr( 7, 3 )); hour = asInt( line.substr(10, 3 )); min = asInt( line.substr(13, 3 )); sec = asDouble(line.substr(16, 10)); return CivilTime(year, month, day, hour, min, sec).convertToCommonTime(); } // End of method 'Rinex3ClockHeader::parseTime(const string& line)'
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); } }
UTCTime(int year,int month,int day,int hour,int minute,double second) {CivilTime(year, month, day, hour, minute, second);}
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); } }