📄 datastructures.hpp
字号:
#pragma ident "$Id: $"/** * @file DataStructures.hpp * Set of several data structures to be used by other GPSTk classes. */#ifndef DATASTRUCTURES_HPP#define DATASTRUCTURES_HPP//============================================================================//// This file is part of GPSTk, the GPS Toolkit.//// The GPSTk is free software; you can redistribute it and/or modify// it under the terms of the GNU Lesser General Public License as published// by the Free Software Foundation; either version 2.1 of the License, or// any later version.//// The GPSTk is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public// License along with GPSTk; if not, write to the Free Software Foundation,// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//// Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007////============================================================================#include <utility>#include <vector>#include <set>#include <map>#include <string>#include "DataHeaders.hpp"#include "FFData.hpp"#include "RinexObsStream.hpp"#include "RinexObsData.hpp"#include "StringUtils.hpp"#include "Vector.hpp"#include "Matrix.hpp"#include "icd_200_constants.hpp"namespace gpstk{ /** @defgroup DataStructures GPSTk data structures * * This is a set of several data structures to be used by other * GPSTk classes. * * Each data structure is composed of a header and a body. The header * contains the information that is common to all the data stored in * the structure, and the body contains the data themselves along with * the information (indexes) necessary to access them. * * In this regard, four basic indexes are considered enough to * completely identify any GNSS value: * * \li Receiver/Source (SourceID) * \li Epoch (DayTime) * \li Satellite (SatID) * \li Type of value (TypeID) * * Moreover, all the GNSS data structures have two main parts: * * \li Header: Containing the indexes that are common to all the values * (sometimes with some extra information). * * \li Body: Containing the GNSS values themselves, organized in * std::maps. * * The general idea is to use the GNSS data structures like WHITE BOXES * that are able to carry all the important data around in an easy way, * in order to do something like the following to process GNSS data: * * @code * RinexObsStream rin("bahr1620.04o"); // Create the input file stream * gnssRinex gRin; // Declare a gnssRinex object * * ModeledPR modelPR; // Declare a ModeledReferencePR object * SolverLMS solver; // Declare an object to apply LMS method * * * // ... other inicialization code here ... * * * // Feed the gRin data structure * while(rin >> gRin) * { * * gRin.keepOnlyTypeID(TypeID::C1) >> modelPR >> solver; * * // Print the results for this epoch * cout << gRin.header.epoch.DOYsecond() << " "; // Epoch * cout << solver.solution[0] << " "; // dx * cout << solver.solution[1] << " "; // dy * cout << solver.solution[2] << " "; // dz * * } * @endcode * */ //@{ // First, we must declare some important exception objects /// Thrown when attempting to access a value and the corresponding TypeID /// does not exist in the map. /// @ingroup exceptiongroup NEW_EXCEPTION_CLASS(TypeIDNotFound, gpstk::Exception); /// Thrown when attempting to access a value and the corresponding SatID /// does not exist in the map. /// @ingroup exceptiongroup NEW_EXCEPTION_CLASS(SatIDNotFound, gpstk::Exception); /// Thrown when the number of data values and the number of /// corresponding types does not match. /// @ingroup exceptiongroup NEW_EXCEPTION_CLASS(NumberOfTypesMismatch, gpstk::Exception); /// Thrown when the number of data values and the number of /// corresponding satellites does not match. /// @ingroup exceptiongroup NEW_EXCEPTION_CLASS(NumberOfSatsMismatch, gpstk::Exception); // Now, some useful type definitions /// Set containing TypeID objects. typedef std::set<TypeID> TypeIDSet; /// Set containing SatID objects. typedef std::set<SatID> SatIDSet; /// Map holding TypeID with corresponding numeric value. struct typeValueMap : std::map<TypeID, double> { /// Returns the number of different types available. inline size_t numTypes() const { return (*this).size(); } /// Returns a TypeIDSet with all the data types present in /// this object. TypeIDSet getTypeID() const; /// Returns a typeValueMap with only this type of data. /// @param type Type of value to be extracted. typeValueMap extractTypeID(const TypeID& type) const; /// Returns a typeValueMap with only these types of data. /// @param typeSet Set (TypeIDSet) containing the types of data to /// be extracted. typeValueMap extractTypeID(const TypeIDSet& typeSet) const; /// Modifies this object, keeping only this type of data. /// @param type Type of value to be kept. typeValueMap& keepOnlyTypeID(const TypeID& type); /// Modifies this object, keeping only these types of data. /// @param typeSet Set (TypeIDSet) containing the types of data /// to be kept. typeValueMap& keepOnlyTypeID(const TypeIDSet& typeSet); /// Modifies this object, removing this type of data. /// @param type Type of value to be removed. typeValueMap& removeTypeID(const TypeID& type) { (*this).erase(type); return (*this); } /// Modifies this object, removing these types of data. /// @param typeSet Set (TypeIDSet) containing the types of data /// to be kept. typeValueMap& removeTypeID(const TypeIDSet& typeSet); /// Returns a reference to the data value (double) with /// corresponding type. /// @param type Type of value to be looked for. double& operator()(const TypeID& type) throw(TypeIDNotFound); /// Destructor. virtual ~typeValueMap() {}; }; // End typeValueMap /// Map holding SatID with corresponding numeric value. struct satValueMap : std::map<SatID, double> { /// Returns the number of satellites available. size_t numSats() const { return (*this).size(); } /// Returns a SatIDSet with all the satellites present in this object. SatIDSet getSatID() const; /// Returns a Vector with all the satellites present in this object. Vector<SatID> getVectorOfSatID() const; /// Returns a satValueMap with only this satellite. /// @param satellite Satellite to be extracted. satValueMap extractSatID(const SatID& satellite) const; /// Returns a satValueMap with only one satellite, identified by /// the given parameters. /// @param p Satellite PRN number. /// @param p System the satellite belongs to. satValueMap extractSatID( const int& p, const SatID::SatelliteSystem& s ) const; /// Returns a satValueMap with only these satellites. /// @param satSet Set (SatIDSet) containing the satellites to /// be extracted. satValueMap extractSatID(const SatIDSet& satSet) const; /// Modifies this object, keeping only this satellite. /// @param satellite Satellite to be kept. satValueMap& keepOnlySatID(const SatID& satellite); /// Modifies this object, keeping only this satellite. /// @param p Satellite PRN number. /// @param p System the satellite belongs to. satValueMap& keepOnlySatID( const int& p, const SatID::SatelliteSystem& s ); /// Modifies this object, keeping only these satellites. /// @param satSet Set (SatIDSet) containing the satellites to be kept. satValueMap& keepOnlySatID(const SatIDSet& satSet); /// Modifies this object, removing this satellite. /// @param satellite Satellite to be removed. satValueMap& removeSatID(const SatID& satellite) { (*this).erase(satellite); return (*this); } /// Modifies this object, removing the given satellites. /// @param satSet Set (SatIDSet) containing the satellites to /// be removed. satValueMap& removeSatID(const SatIDSet& satSet); /// Returns a reference to the data value (double) with /// corresponding SatID. /// @param satellite Satellite to be looked for. double& operator()(const SatID& satellite) throw(SatIDNotFound); /// Destructor. virtual ~satValueMap() {}; }; // End of satValueMap /// Map holding SatID with corresponding typeValueMap. struct satTypeValueMap : std::map<SatID, typeValueMap> { /// Returns the number of available satellites. size_t numSats() const { return (*this).size(); } /** Returns the total number of data elements in the map. * This method DOES NOT suppose that all the satellites have * the same number of type values. */ size_t numElements() const; /// Returns a SatIDSet with all the satellites present in this object. SatIDSet getSatID() const; /// Returns a Vector with all the satellites present in this object. Vector<SatID> getVectorOfSatID() const; /// Returns a TypeIDSet with all the data types present in /// this object. This does not imply that all satellites have /// these types. TypeIDSet getTypeID() const; /// Returns a satTypeValueMap with only this satellite. /// @param satellite Satellite to be extracted. satTypeValueMap extractSatID(const SatID& satellite) const; /// Returns a satTypeValueMap with only one satellite, identified /// by the given parameters. /// @param p Satellite PRN number. /// @param p System the satellite belongs to. satTypeValueMap extractSatID( const int& p, const SatID::SatelliteSystem& s) const; /// Returns a satTypeValueMap with only these satellites. /// @param satSet Set (SatIDSet) containing the satellites to /// be extracted. satTypeValueMap extractSatID(const SatIDSet& satSet) const; /// Modifies this object, keeping only this satellite. /// @param satellite Satellite to be kept. satTypeValueMap& keepOnlySatID(const SatID& satellite); /// Modifies this object, keeping only this satellite. /// @param p Satellite PRN number. /// @param p System the satellite belongs to. satTypeValueMap& keepOnlySatID( const int& p, const SatID::SatelliteSystem& s ); /// Modifies this object, keeping only these satellites. /// @param satSet Set (SatIDSet) containing the satellites to be kept. satTypeValueMap& keepOnlySatID(const SatIDSet& satSet); /// Returns a satTypeValueMap with only this type of value. /// @param type Type of value to be extracted. satTypeValueMap extractTypeID(const TypeID& type) const; /// Returns a satTypeValueMap with only these types of data. /// @param typeSet Set (TypeIDSet) containing the types of data /// to be extracted. satTypeValueMap extractTypeID(const TypeIDSet& typeSet) const; /// Modifies this object, keeping only this type of data. /// @param type Type of value to be kept. satTypeValueMap& keepOnlyTypeID(const TypeID& type); /// Modifies this object, keeping only these types of data. /// @param typeSet Set (TypeIDSet) containing the types of data /// to be kept. satTypeValueMap& keepOnlyTypeID(const TypeIDSet& typeSet); /// Modifies this object, removing this satellite. /// @param satellite Satellite to be removed.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -