RinexDatum Rinex3ObsData::getObs(const RinexSatID& svID, const RinexObsID& obsID, const Rinex3ObsHeader& hdr ) const throw(InvalidRequest) { string sys(1,svID.systemChar()); return getObs(svID, hdr.getObsIndex(sys, obsID)); }
void Rinex3ObsData::setObs(const RinexDatum& data, const RinexSatID& svID, const RinexObsID& obsID, const Rinex3ObsHeader& hdr ) throw(InvalidRequest) { size_t index = hdr.getObsIndex(string(1,svID.systemChar()), obsID); if (obs[svID].size() <= index) obs[svID].resize(index+1); obs[svID][index] = data; }
/** Get a combination of observations from a Rinex3ObsData object * * @param rinexData The Rinex data set holding the observations. * @param type1 String representing observation type #1. * @param type2 String representing observation type #2. * @param hdr RINEX Observation Header for current RINEX file. * * @return * Number of SVs with this combination of observables available */ int ExtractCombinationData::getData( const Rinex3ObsData& rinexData, std::string type1, std::string type2, const Rinex3ObsHeader& hdr ) throw(InvalidRequest) { // Get the indexes corresponding to these observation types int index1( hdr.getObsIndex(type1) ); int index2( hdr.getObsIndex(type2) ); // Call the appropriate method return ( getData(rinexData, index1, index2) ); } // End of method 'ExtractData::getData()'
RinexDatum Rinex3ObsData::getObs(const RinexSatID& svID, const std::string& type, const Rinex3ObsHeader& hdr ) const throw(InvalidRequest) { string obsID; // Add GNSS code if needed if( type.size() == 3 ) obsID = svID.systemChar() + type; else obsID = type; return getObs(svID, hdr.getObsIndex(obsID)); }
/* This method returns the RinexDatum of a given observation * * @param sat Satellite whose observation we want to fetch. * @param type String representing the observation type. * @param hdr RINEX Observation Header for current RINEX file. */ RinexDatum Rinex3ObsData::getObs( const SatID& sat, std::string type, const Rinex3ObsHeader& hdr ) const throw(InvalidRequest) { // We will need the system 'char' of the satellite RinexSatID rsat(sat); // Add GNSS code if needed if( type.size() == 3 ) { char sysCode = rsat.systemChar(); type = sysCode + type; } // Get the index corresponding to this observation type int index( hdr.getObsIndex(type) ); // Return the corresponding data return getObs(sat, index); } // End of method 'Rinex3ObsData::getValue( const SatID sat,...'
bool convertRinex2ObsFile(std::string& fileName, std::string& outFile) { bool retBool = true; try { // Open the input & output files. if (debug) cout << "Trying to open input file:" << fileName << endl; RinexObsStream obsIn(fileName.c_str(), ios::in); if (!obsIn) return false; else if (debug) cout << "...opened" << endl; if (outFile.length() == 0) { if (outputPath.length() > 0) outFile = outputPath; int lastIndexOf = fileName.find_last_of("\\/"); if (lastIndexOf == -1) lastIndexOf = 0; outFile = fileName.substr(lastIndexOf); } if (debug) cout << "Trying to open output file: " << outFile << endl; Rinex3ObsStream obsOut(outFile.c_str(), ios::out); if (!obsOut) return false; else if (debug) cout << "...opened" << endl; // Declare the header and its converted version. RinexObsHeader robsHead; Rinex3ObsHeader convHead; // Read in the header data. if (debug) cout << "Reading in header..." << endl; obsIn >> robsHead; if (debug) cout << "...finished" << endl; // Convert the obs header and test, all in one step. // If the header couldn't be converted return false. if (debug) cout << "Converting header..." << endl; if (!RinexConverter::convertToRinex3(convHead, robsHead)) return false; if (debug) cout << "...finished" << endl; // Write out the converted header data. obsOut << convHead; if (debug) { convHead.dump(cout); /* cout << " Version: " << convHead.version << endl; cout << " File Type: " << convHead.fileType << endl; cout << " System: " << convHead.system << endl; cout << " File Program: " << convHead.fileProgram << endl; cout << " File Agency: " << convHead.fileAgency << endl; cout << " Date: " << convHead.date << endl; cout << " Marker Name: " << convHead.markerName << endl; cout << " Marker Number: " << convHead.markerNumber << endl; cout << " Marker Type: " << convHead.markerType << endl; cout << " Observer: " << convHead.observer << endl; cout << " Agency: " << convHead.agency << endl; cout << " Rec. No: " << convHead.recNo << endl; cout << " Rec. Type: " << convHead.recType << endl; cout << " Rec. Version: " << convHead.recVers << endl; cout << " Ant. No: " << convHead.antNo << endl; cout << " Ant. Type: " << convHead.antType << endl; cout << " Ant. Position: " << convHead.antennaPosition << endl; cout << " Ant. Delta HEN: " << convHead.antennaDeltaHEN << endl; cout << " Interval: " << convHead.interval << endl; cout << "Receiver Offset: " << convHead.receiverOffset << endl; cout << " Leap Seconds: " << convHead.leapSeconds << endl; cout << " Num SVs: " << convHead.numSVs << endl; cout << " Valid: " << convHead.valid << endl; */ } // All of the data contained in the file. vector<RinexObsData> robsData; // A temporary data object for reading in from the stream. RinexObsData temp; // Converted data object. Rinex3ObsData convData; // Last observed epoch CommonTime lastEpoch = CommonTime::BEGINNING_OF_TIME; // Flags for the presence of the different systems bool hasGPS, hasGLO, hasGAL, hasGEO; hasGPS = hasGLO = hasGAL = hasGEO = false; if (debug) cout << "Start reading in data..." << endl; while(1) { try { obsIn >> temp; } catch (Exception gpstkEx) { if (printExceptions) cout << "Exception Reading Data:" << endl << gpstkEx << endl; continue; } catch (exception stdEx) { if (printExceptions) cout << "Exception Reading Data:" << endl << stdEx.what() << endl; continue; } catch (...) { if (printExceptions) cout << "Exception Reading Data" << endl; continue; } // Break for bad data or end of file. if (!obsIn.good() || obsIn.eof()) break; // Otherwise, save the data. robsData.push_back(temp); if (temp.time > lastEpoch) lastEpoch = temp.time; // Set the system flags. RinexSatID id; RinexObsData::RinexSatMap::const_iterator iter = temp.obs.begin(); while(iter != temp.obs.end()) { id = RinexSatID(iter->first); if (id.systemChar() == 'G') hasGPS = true; else if (id.systemChar() == 'R') hasGLO = true; else if (id.systemChar() == 'E') hasGAL = true; else if (id.systemChar() == 'S') hasGEO = true; ++iter; } } /// For now, comment out the following. While logical, we will abide by the /// philosophy that this converter sould simply read in and write out, not /// alter the data in any way. /* // Erase any systems that were not present. map<string, vector<ObsID> >::const_iterator mapIter; mapIter = convHead.mapObsTypes.find("G"); if (!hasGPS && mapIter != convHead.mapObsTypes.end()) convHead.mapObsTypes.erase("G"); mapIter = convHead.mapObsTypes.find("R"); if (!hasGPS && mapIter != convHead.mapObsTypes.end()) convHead.mapObsTypes.erase("R"); mapIter = convHead.mapObsTypes.find("E"); if (!hasGPS && mapIter != convHead.mapObsTypes.end()) convHead.mapObsTypes.erase("E"); mapIter = convHead.mapObsTypes.find("S"); if (!hasGPS && mapIter != convHead.mapObsTypes.end()) convHead.mapObsTypes.erase("S"); // close the input stream obsIn.clear(); obsIn.close(); */ for (int i = 0; i < robsData.size(); ++i) { RinexConverter::convertToRinex3(convData, robsData[i], robsHead); obsOut << convData; } // obsOut.flush(); obsOut.close(); } catch(Exception gpstkException) { if (printExceptions) cout << "GPSTk Exception:" << gpstkException << endl; return false; } catch(exception stdException) { if (printExceptions) cout << "Exception:" << stdException.what() << endl; return false; } catch(...) { if (printExceptions) cout << "Exception!" << endl; return false; } }