📄 datastructures.hpp
字号:
/// Returns a Vector with all the satellites present in this object. inline Vector<SatID> getVectorOfSatID() const { std::vector<SatID> temp; satTypeValueMap::const_iterator pos; for (pos = (*this).begin(); pos != (*this).end(); ++pos) { temp.push_back( (*pos).first ); } Vector<SatID> result; result = temp; return result; } /// Returns a TypeIDSet with all the data types present in this object. inline TypeIDSet getTypeID() const { TypeIDSet typeSet; satTypeValueMap::const_iterator pos; for (pos = (*this).begin(); pos != (*this).end(); ++pos) { typeValueMap::const_iterator it; for (it = (*pos).second.begin(); it != (*pos).second.end(); ++it) { typeSet.insert( (*it).first ); } } return typeSet; } /// Returns a satTypeValueMap with only this satellite. /// @param satellite Satellite to be extracted. inline satTypeValueMap extractSatID(const SatID& satellite) const { SatIDSet satSet; satSet.insert(satellite); return (*this).extractSatID(satSet); }; /// Returns a satTypeValueMap with only one satellite, identified by the given parameters. /// @param p Satellite PRN number. /// @param p System the satellite belongs to. inline satTypeValueMap extractSatID(const int& p, const SatID::SatelliteSystem& s) const { SatID tempSatellite(p, s); // We build a temporary SatID object return (*this).extractSatID(tempSatellite); } /// Returns a satTypeValueMap with only these satellites. /// @param satSet Set (SatIDSet) containing the satellites to be extracted. inline satTypeValueMap extractSatID(const SatIDSet& satSet) const { satTypeValueMap stvMap; SatIDSet::const_iterator pos; for (pos = satSet.begin(); pos != satSet.end(); ++pos) { satTypeValueMap::const_iterator itObs; itObs = (*this).find(*pos); if ( itObs != (*this).end() ) { stvMap[ (*itObs).first ] = (*itObs).second; }; } return stvMap; } /// Modifies this object, keeping only this satellite. /// @param satellite Satellite to be kept. inline satTypeValueMap& keepOnlySatID(const SatID& satellite) { SatIDSet satSet; satSet.insert(satellite); return (*this).keepOnlySatID(satSet); } /// Modifies this object, keeping only this satellite. /// @param p Satellite PRN number. /// @param p System the satellite belongs to. inline satTypeValueMap& keepOnlySatID(const int& p, const SatID::SatelliteSystem& s) { SatID tempSatellite(p, s); // We build a temporary SatID object return (*this).keepOnlySatID(tempSatellite); } /// Modifies this object, keeping only these satellites. /// @param satSet Set (SatIDSet) containing the satellites to be kept. inline satTypeValueMap& keepOnlySatID(const SatIDSet& satSet) { satTypeValueMap stvMap( (*this).extractSatID(satSet) ); (*this) = stvMap; return (*this); } /// Returns a satTypeValueMap with only this type of value. /// @param type Type of value to be extracted. inline satTypeValueMap extractTypeID(const TypeID& type) const { TypeIDSet typeSet; typeSet.insert(type); return (*this).extractTypeID(typeSet); }; /// Returns a satTypeValueMap with only these types of data. /// @param typeSet Set (TypeIDSet) containing the types of data to be extracted. inline satTypeValueMap extractTypeID(const TypeIDSet& typeSet) const { satTypeValueMap theMap; satTypeValueMap::const_iterator it; for (it = (*this).begin(); it != (*this).end(); ++it) { typeValueMap tvMap = (*it).second.extractTypeID(typeSet); if( tvMap.size() > 0 ) { theMap[(*it).first] = tvMap; }; }; return theMap; }; /// Modifies this object, keeping only this type of data. /// @param type Type of value to be kept. inline satTypeValueMap& keepOnlyTypeID(const TypeID& type) { TypeIDSet typeSet; typeSet.insert(type); return (*this).keepOnlyTypeID(typeSet); } /// Modifies this object, keeping only these types of data. /// @param typeSet Set (TypeIDSet) containing the types of data to be kept. inline satTypeValueMap& keepOnlyTypeID(const TypeIDSet& typeSet) { satTypeValueMap stvMap( (*this).extractTypeID(typeSet) ); (*this) = stvMap; return (*this); } /// Modifies this object, removing this satellite. /// @param satellite Satellite to be removed. inline satTypeValueMap& removeSatID(const SatID& satellite) { (*this).erase(satellite); return (*this); } /// Modifies this object, removing these satellites. /// @param satSet Set (SatIDSet) containing the satellites to be removed. inline satTypeValueMap& removeSatID(const SatIDSet& satSet) { SatIDSet::const_iterator pos; for (pos = satSet.begin(); pos != satSet.end(); ++pos) { (*this).erase(*pos); } return (*this); } /// Modifies this object, removing this type of data. /// @param type Type of value to be removed. inline satTypeValueMap& removeTypeID(const TypeID& type) { satTypeValueMap::iterator it; for (it = (*this).begin(); it != (*this).end(); ++it) { (*it).second.removeTypeID(type); } return (*this); } /// Modifies this object, removing these types of data. /// @param typeSet Set (TypeIDSet) containing the types of data to be kept. inline satTypeValueMap& removeTypeID(const TypeIDSet& typeSet) { TypeIDSet::const_iterator pos; for (pos = typeSet.begin(); pos != typeSet.end(); ++pos) { (*this).removeTypeID(*pos); } return (*this); } /// Returns a GPSTk::Vector containing the data values with this type. /// @param type Type of value to be returned. inline Vector<double> getVectorOfTypeID(const TypeID& type) const { std::vector<double> temp; typeValueMap::const_iterator itObs; satTypeValueMap::const_iterator it; for (it = (*this).begin(); it != (*this).end(); ++it) { itObs = (*it).second.find(type); if ( itObs != (*it).second.end() ) temp.push_back( (*itObs).second ); else temp.push_back( 0.0 ); } Vector<double> result; result = temp; return result; } /// Returns a GPSTk::Matrix containing the data values in this set. /// @param typeSet TypeIDSet of values to be returned. inline Matrix<double> getMatrixOfTypes(const TypeIDSet& typeSet) const { // First, let's create a Matrix<double> of the proper size Matrix<double> tempMat( (*this).numSats(), typeSet.size(), 0.0 ); size_t numRow(0), numCol(0); satTypeValueMap::const_iterator it; for (it = (*this).begin(); it != (*this).end(); ++it) { numCol=0; typeValueMap::const_iterator itObs; TypeIDSet::const_iterator pos; for (pos = typeSet.begin(); pos != typeSet.end(); ++pos) { itObs = (*it).second.find(*pos); if ( itObs != (*it).second.end() ) tempMat(numRow, numCol) = (*itObs).second; ++numCol; } ++numRow; } return tempMat; } // End getMatrixOfTypes(const TypeIDSet& typeSet) /** Modifies this object, adding one vector of data with this type, one value * per satellite. * * If type already exists, data is overwritten. If the number of values does not * match with the number of satellites, a NumberOfSatsMismatch exception is thrown. * * Given that dataVector does not store information about the satellites the * values correspond to, the user is held responsible for having the data values * stored in dataVector in the proper order regarding the SatIDs in this object. * * @param type Type of data to be added. * @param dataVector GPSTk Vector containing the data to be added. */ inline satTypeValueMap& insertTypeIDVector(const TypeID& type, const Vector<double> dataVector) throw(NumberOfSatsMismatch) { if ( dataVector.size() == (*this).numSats() ) { size_t pos = 0; satTypeValueMap::iterator it; for (it = (*this).begin(); it != (*this).end(); ++it) { (*it).second[type] = dataVector[pos]; ++pos; } return (*this); } else GPSTK_THROW(NumberOfSatsMismatch("Number of data values in vector and number of satellites do not match")); } /** Modifies this object, adding a matrix of data, one vector per satellite. * * If types already exists, data is overwritten. If the number of rows in matrix does not * match with the number of satellites, a NumberOfSatsMismatch exception is thrown. If the * number of columns in matrix does not match with the number of types in typeSet, a * NumberOfTypesMismatch exception is thrown. * * Given that dataMatrix does not store information about the satellites and types the * values correspond to, the user is held responsible for having those data values * stored in dataMatrix in the proper order regarding the SatIDs in this object and the * provided typeSet. * * @param typeSet Set (TypeIDSet) containing the types of data to be added. * @param dataMatrix GPSTk Matrix containing the data to be added. */ inline satTypeValueMap& insertMatrix(const TypeIDSet& typeSet, const Matrix<double> dataMatrix) throw(NumberOfSatsMismatch, NumberOfTypesMismatch) { if ( dataMatrix.rows() != (*this).numSats() ) GPSTK_THROW(NumberOfSatsMismatch("Number of rows in matrix and number of satellites do not match")); if ( dataMatrix.cols() == typeSet.size() ) { size_t pos(0); satTypeValueMap::iterator it; for (it = (*this).begin(); it != (*this).end(); ++it) { size_t idx(0); TypeIDSet::const_iterator itSet; for (itSet = typeSet.begin(); itSet != typeSet.end(); ++itSet) { (*it).second[(*itSet)] = dataMatrix(pos,idx); ++idx; } ++pos; } return (*this); } else GPSTK_THROW(NumberOfTypesMismatch("Number of data values per row in matrix and number of types do not match")); } /// Returns a reference to the typeValueMap with corresponding SatID. /// @param type Type of value to be look for. inline typeValueMap& operator()(const SatID& satellite) throw(SatIDNotFound) { satTypeValueMap::iterator itObs; itObs = (*this).find(satellite); if ( itObs != (*this).end() ) { return (*itObs).second; } else GPSTK_THROW(SatIDNotFound("SatID not found in map")); } /// Convenience output method virtual std::ostream& dump(std::ostream& s, int mode = 0) const; /// Destructor. virtual ~satTypeValueMap() {}; }; // End of satTypeValueMap /// stream output for satTypeValueMap std::ostream& operator<<(std::ostream& s, const satTypeValueMap& stvMap); /// Map holding epoch with corresponding satTypeValueMap. typedef std::map<DayTime, satTypeValueMap> epochSatTypeValueMap; /// Map holding epoch with corresponding satValueMap. typedef std::map<DayTime, satValueMap> epochSatValueMap; /// Map holding epoch with corresponding typeValueMap. typedef std::map<DayTime, typeValueMap> epochTypeValueMap; /// Basic gnssData structure. template <class HEADER_CLASS, class BODY_CLASS> struct gnssData { /// Header. HEADER_CLASS header; /// Body. BODY_CLASS body; /// Default constructor. gnssData() {} /// Common constructor. gnssData(const HEADER_CLASS& h, const BODY_CLASS& b) { header = h; body = b; } /// Copy constructor. template<class H, class B> gnssData(const gnssData<H,B>& g) { header = g.header; body = g.body; } /// Destructor. virtual ~gnssData() {}; }; // End of gnssData // Further type definitions /// GNSS data structure with source, epoch and data type as header (common indexes) and satValueMap as body. struct gnssSatValue : gnssData<sourceEpochTypeHeader, satValueMap> { /// Returns the number of satellites available in the body (a satValueMap). inline size_t numSats() const { return body.numSats(); }; /// Returns a SatIDSet with all the satellites present in this object. inline SatIDSet getSatID() const { return (*this).body.getSatID(); } /// Returns a Vector with all the satellites present in this object. inline Vector<SatID> getVectorOfSatID() const { return (*this).body.getVectorOfSatID(); } /// Returns a gnssSatValue with only this satellite. /// @param satellite Satellite to be extracted. inline gnssSatValue extractSatID(const SatID& satellite) const { gnssSatValue result; result.header = (*this).header; result.body = (*this).body.extractSatID(satellite); return result;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -