int ConstellationSet::loadFileCSV( const std::string filename ) { FILE* inf = fopen(filename.c_str(),"rt"); if (inf==0) return(0); std::string temp; DayTime tempDT; DayTime testDT = DayTime(2008,1,1,12,0,0.0); string whiteSpace = " \t\n\r"; char comma = ','; int lineCount =0; int cdCount = 0; char fileLine[301]; ConstellationDefinition cd; while (fgets(fileLine, 300, inf)) { // Set a clear starting state cd.clearDefinition(); lineCount++; // Skip first two lines if (lineCount<4) continue; // Move input from character buffer to string. string lineIn = fileLine; // strip trailing whitespace string::size_type endIndex = lineIn.find_last_not_of(whiteSpace); lineIn = lineIn.substr( 0, endIndex+1 ); // First entry should be date string string dateString = lineIn.substr(0,lineIn.find(comma)); int y,m,d; int ntest = sscanf(dateString.c_str(),"%4d-%2d-%2d", &y, &m, &d); if (ntest==3) { try { tempDT.setYMDHMS( (short) y, (short)m, (short)d, 12,0,0.0); cd.setEffectiveTime( tempDT ); } catch(DayTime::DayTimeException e) { // Did not successful parse a date, so // reject the line. continue; } } //if (tempDT==testDT) //cout << "Parsing date: " << tempDT.printf("%02m/%02d/%04Y") // << "size(): " << lineIn.size() << "." << endl; // Next 32 entries are PRN->NAVSTAR number entries followed // by a blank column. // Crack out the NAVSTAR numbers and build the PRN->NAVSTAR number // table. int numItems = 0; int PRNID; string::size_type nextPos = 0; string::size_type cpos = lineIn.find(comma); //cout << "Entering the read loop" << endl; while (numItems<33) { PRNID = numItems + 1; nextPos = lineIn.find(comma,cpos+1); if (PRNID<=gpstk::MAX_PRN) { string SVNString = lineIn.substr(cpos+1,nextPos-cpos-1); if (SVNString.size()>0) { try { int SVNNum = StringUtils::asInt(SVNString); SatID SV( PRNID, SatID::systemGPS ); cd.setSVNforPRN( SV, SVNNum ); // DEBUG //if (tempDT==testDT) //cout << "PRNID, SVN, cpos, nextPos: " << PRNID << ", " // << SVNNum << ", " << cpos << ", " << nextPos << "." << endl; } // If the conversion fails, just move on..... catch(StringUtils::StringException e) { } } } numItems++; cpos = nextPos; } //cout << "Exiting the read loop" << endl; // Next 32 entries contain the by-PRN slot assignments PRNID = 1; while (PRNID<=gpstk::MAX_PRN && cpos<lineIn.size() ) { nextPos = lineIn.find(comma,cpos+1); if (nextPos==string::npos) nextPos = lineIn.size(); string slotString = lineIn.substr(cpos+1,nextPos-cpos-1); //if (tempDT==testDT) //cout << "PRN, slotString, cpos,nextPos: " << PRNID << ", '" // << slotString << "', " // << cpos << ", " << nextPos << "." << endl; // Zero length means this PRN isn't available if (slotString.size()>0) { char plane; int slot; try { plane = slotString[0]; slot = StringUtils::asInt(slotString.substr(1,1)); SatID SV( PRNID, SatID::systemGPS ); cd.setPlaneSlot( SV, plane, slot ); //if (tempDT==testDT) // cout << " plane, slot: " << plane << ", " << slot << ". " << endl; } // If the conversion fails, just move on..... catch(StringUtils::StringException e) { } } PRNID++; cpos = nextPos; } cdMap.insert( make_pair( tempDT, cd ) ); cdCount++; } fclose(inf); return(cdCount); }
//------------------------------------------------------------------------------------ int main(int argc, char **argv) { try { // ------------------------------------------------------------------ // START totaltime = clock(); int iret; DayTime CurrEpoch; // Title title and version Title = PrgmName + ", ARL:UT DD phase estimation processor, Ver " + Version; // PrgmDesc description PrgmDesc = " Prgm " + PrgmName + " will read GPS data from any number of RINEX obs files and process them\n" " in a double-differenced carrier phase estimation algorithm to produce precise\n" " estimates of relative positions. Input is on the command line, or of the same\n" " format in a file (see -f<file> below). DDBase is built on the GPS Toolkit (GPSTk).\n" " NB. Input option --DT <data_interval_(seconds)> is optional but recommended.\n" " NB. Stations are defined, and many inputs for each are identified, by a label\n" " (called station label or id below), which is case sensitive and must be used\n" " consistently throughout. It cannot be 'X','Y' or 'Z' nor contain '-' or '_';\n" " four characters work best.\n" " NB. There must be at least two stations defined, with observation file(s)\n" " provided for each, and at least one station must be fixed.\n" " Options may be given in an input file (see -f<file>); the '#' character marks\n" " a comment, to EOL. All input options are shown below, followed by a\n" " description, and the default value, if there is one, in ().\n"; // get current time time_t timer; struct tm *tblock; timer = time(NULL); tblock = localtime(&timer); CurrEpoch.setYMDHMS(1900+tblock->tm_year,1+tblock->tm_mon, tblock->tm_mday,tblock->tm_hour,tblock->tm_min,tblock->tm_sec); // print title and current time to screen Title += CurrEpoch.printf(", Run %04Y/%02m/%02d %02H:%02M:%02S"); cout << Title << endl; for(;;) { // ------------------------------------------------------------------ // get command line input; -99 is 'help' return if((iret = CI.GetCmdInput(argc, argv))) break; // ------------------------------------------------------------------ // test command input for validity if((iret = CI.ValidateCmdInput())) break; // dump command input to log if(CI.Verbose) { cout << "Output is directed to log file " << CI.LogFile << endl; CI.Dump(oflog); } // if 'validate' switch is on, quit here if(CI.Validate) break; // ------------------------------------------------------------------ // Configure #1 if((iret = Configure(1))) break; // ------------------------------------------------------------------ // Open and read all files, compute PR solution, edit and buffer raw data if((iret = ReadAndProcessRawData())) break; // ------------------------------------------------------------------ // Edit buffers if((iret = EditRawDataBuffers())) break; // ------------------------------------------------------------------ // Output raw data buffers if((iret = OutputRawDataBuffers())) break; // ------------------------------------------------------------------ // Configure #2 if((iret = Configure(2))) break; // ------------------------------------------------------------------ // clock processing if((iret = ClockModel())) break; // ------------------------------------------------------------------ // synchronization of data to epoch (SolutionEpoch) if((iret = Synchronization())) break; // ------------------------------------------------------------------ // correct ephemeris range, elevation, and compute phase windup if((iret = RecomputeFromEphemeris())) break; // ------------------------------------------------------------------ // Orbit processing if((iret = EphemerisImprovement())) break; // ------------------------------------------------------------------ // output 'raw' data here OutputRawData(); // ------------------------------------------------------------------ // Compute or read the timetable if((iret = Timetable())) break; // ------------------------------------------------------------------ // Compute double differences, and buffer if((iret = DoubleDifference())) break; // ------------------------------------------------------------------ // Edit double differences if((iret = EditDDs())) break; // ------------------------------------------------------------------ // Configure #3 : prepare estimation if((iret = Configure(3))) break; // ------------------------------------------------------------------ // Estimation if((iret = Estimation())) break; break; } // end for(;;) // END -------------------------------------------------------------- // error condition? -99 is 'normal' help return from GetCmdInput if(iret != -99) { if(iret) { cerr << PrgmName << " terminating with error code " << iret << endl; oflog << PrgmName << " terminating with error code " << iret << endl; } // compute run time totaltime = clock()-totaltime; cout << PrgmName << " timing: " << fixed << setprecision(3) << double(totaltime)/double(CLOCKS_PER_SEC) << " seconds." << endl; oflog << PrgmName << " timing: " << fixed << setprecision(3) << double(totaltime)/double(CLOCKS_PER_SEC) << " seconds." << endl; } return iret; } catch(Exception& e) { cerr << "GPSTk Exception : " << e; oflog << "GPSTk Exception : " << e; } catch (...) { cerr << "Unknown error in DDBase. Abort." << endl; oflog << "Unknown error in DDBase. Abort." << endl; } // close files oflog.close(); return -1; } // end main()
int ConstellationSet::loadFileARL( const std::string filename ) { FILE* inf = fopen(filename.c_str(),"rt"); if (inf==0) return(0); std::string temp; DayTime tempDT; string whiteSpace = " \t\n\r"; char comma = ','; bool inDefinition = false; int lineCount =0; int cdCount = 0; char fileLine[200]; ConstellationDefinition cd; while (fgets(fileLine, 200, inf)) { lineCount++; string lineIn = fileLine; // strip trailing whitespace string::size_type endIndex = lineIn.find_last_not_of(whiteSpace); lineIn = lineIn.substr( 0, endIndex+1 ); string lead4Chars = lineIn.substr(0,4); // Start new CD definition if (lead4Chars.compare("DATE")==0) { // Store any CD currently "in progress" before starting new. if (inDefinition) { cdMap.insert( make_pair( tempDT, cd ) ); cdCount++; cd.clearDefinition(); inDefinition = false; } // Attempt to crack Date and form an effective date for this CD string::size_type start = lineIn.find_first_not_of(whiteSpace,4); int y,m,d; string t = lineIn.substr(start); int ntest = sscanf(t.c_str(),"%4d%2d%2d", &y, &m, &d); if (start!=string::npos && ntest==3) { try { tempDT.setYMDHMS( (short) y, (short)m, (short)d, 12,0,0.0); cd.setEffectiveTime( tempDT ); inDefinition = true; } catch(DayTime::DayTimeException e) { // do nothing - ACTUALLY the fact that we did NOT // set inDefinition is the action. } } } // Add to current CD definition if (lead4Chars.compare("PLAN")==0 && inDefinition) { // List should be comma separated value (CSV) list // First find plane, then parse list of PRNs string::size_type end = lineIn.find(comma); // Comma after "PLANE" end = lineIn.find(comma, end+1); // Comma after plane character char plane = lineIn[end-1]; string::size_type start = end+1; bool done = false; int slot = 1; while (!done) { end = lineIn.find(comma,start); bool empty = true; string::size_type check = lineIn.find_first_not_of(whiteSpace,start); if (check<end) empty = false; int PRNID = 0; if (!empty) { try { PRNID = StringUtils::asInt(lineIn.substr(start,(end-start))); } catch(StringUtils::StringException e) { } SatID SV( PRNID, SatID::systemGPS ); cd.setPlaneSlot( SV, plane, slot ); } // If there's a null entry within the first four slots, // we simply want to move to the next item. // If the null entry is after the fourth slot, then // it's time to stop looking. else { if (slot>4) done = true; } slot++; start = end +1; } } } if (inDefinition) { cdMap.insert( make_pair( tempDT, cd ) ); cdCount++; } fclose(inf); return(cdCount); }