⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datastructures.hpp

📁 gps源代码
💻 HPP
📖 第 1 页 / 共 4 页
字号:
/** * @file DataStructures.hpp * Set of several data structures to be used by other GPSTk classes. */#ifndef DATA_STRUCTURES_GPSTK#define DATA_STRUCTURES_GPSTK//============================================================================////  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. 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:     *     *  - Receiver/Source (SourceID)     *  - Epoch (DayTime)     *  - Satellite (SatID)     *  - Type of value (TypeID)     *     * Moreover, all the GNSS data structures have two main parts:     *     *  - Header: Containing the indexes that are common to all the values (sometimes     * with some extra information).     *     *  - 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     *   Position refPosition(3633909.1016, 4425275.5033, 2799861.2736);  // Initial position     *   Position solPosition;                  // Solution     *     *   // Feed the gRin data structure     *   while(rin >> gRin) {     *      gRin.keepOnlyTypeID(TypeID::C1) >> modelPR >> solver >> solPosition;     *      cout << solPosition;     *   }     * @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.        inline TypeIDSet getTypeID() const        {            TypeIDSet typeSet;            typeValueMap::const_iterator pos;            for (pos = (*this).begin(); pos != (*this).end(); ++pos)            {                typeSet.insert( (*pos).first );            }            return typeSet;        }        /// Returns a typeValueMap with only this type of data.        /// @param type Type of value to be extracted.        inline typeValueMap extractTypeID(const TypeID& type) const        {            TypeIDSet typeSet;            typeSet.insert(type);            return (*this).extractTypeID(typeSet);        }        /// Returns a typeValueMap with only these types of data.        /// @param typeSet Set (TypeIDSet) containing the types of data to be extracted.        inline typeValueMap extractTypeID(const TypeIDSet& typeSet) const        {            typeValueMap tvMap;            TypeIDSet::const_iterator pos;            for (pos = typeSet.begin(); pos != typeSet.end(); ++pos)            {                typeValueMap::const_iterator itObs;                itObs = (*this).find(*pos);                if ( itObs != (*this).end() )                 {                    tvMap[ (*itObs).first ] = (*itObs).second;                };            }            return tvMap;        }        /// Modifies this object, keeping only this type of data.        /// @param type Type of value to be kept.        inline typeValueMap& 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 typeValueMap& keepOnlyTypeID(const TypeIDSet& typeSet)        {            typeValueMap tvMap = (*this).extractTypeID(typeSet);            (*this) = tvMap;            return (*this);        }        /// Modifies this object, removing this type of data.        /// @param type Type of value to be removed.        inline 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.        inline typeValueMap& removeTypeID(const TypeIDSet& typeSet)        {            TypeIDSet::const_iterator pos;            for (pos = typeSet.begin(); pos != typeSet.end(); ++pos)            {                (*this).erase(*pos);            }            return (*this);        }        /// Returns a reference to the data value (double) with corresponding type.        /// @param type Type of value to be look for.        inline double& operator()(const TypeID& type) throw(TypeIDNotFound)        {            typeValueMap::iterator itObs;            itObs = (*this).find(type);            if ( itObs != (*this).end() )             {                return (*itObs).second;            } else GPSTK_THROW(TypeIDNotFound("TypeID not found in map"));        }        /// Destructor.        virtual ~typeValueMap() {};    };  // End typeValueMap    /// Map holding SatID with corresponding numeric value.    struct satValueMap : std::map<SatID, double>    {        /// Returns the number of satellites available.        inline size_t numSats() const { return (*this).size(); }        /// Returns a SatIDSet with all the satellites present in this object.        inline SatIDSet getSatID() const        {            SatIDSet satSet;            satValueMap::const_iterator pos;            for (pos = (*this).begin(); pos != (*this).end(); ++pos)            {                satSet.insert( (*pos).first );            }            return satSet;        }        /// Returns a Vector with all the satellites present in this object.        inline Vector<SatID> getVectorOfSatID() const        {            std::vector<SatID> temp;            satValueMap::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 satValueMap with only this satellite.        /// @param satellite Satellite to be extracted.        inline satValueMap extractSatID(const SatID& satellite) const        {            SatIDSet satSet;            satSet.insert(satellite);            return (*this).extractSatID(satSet);        }        /// Returns a satValueMap with only one satellite, identified by the given parameters.        /// @param p Satellite PRN number.        /// @param p System the satellite belongs to.        inline satValueMap 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 satValueMap with only these satellites.        /// @param satSet Set (SatIDSet) containing the satellites to be extracted.        inline satValueMap extractSatID(const SatIDSet& satSet) const        {            satValueMap svMap;            SatIDSet::const_iterator pos;            for (pos = satSet.begin(); pos != satSet.end(); ++pos)            {                satValueMap::const_iterator itObs;                itObs = (*this).find(*pos);                if ( itObs != (*this).end() )                 {                    svMap[ (*itObs).first ] = (*itObs).second;                };            }            return svMap;        }        /// Modifies this object, keeping only this satellite.        /// @param satellite Satellite to be kept.        inline satValueMap& 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 satValueMap& 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 satValueMap& keepOnlySatID(const SatIDSet& satSet)        {            satValueMap svMap = (*this).extractSatID(satSet);            (*this) = svMap;            return (*this);        }        /// Modifies this object, removing this satellite.        /// @param satellite Satellite to be removed.        inline satValueMap& 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 satValueMap& removeSatID(const SatIDSet& satSet)        {            SatIDSet::const_iterator pos;            for (pos = satSet.begin(); pos != satSet.end(); ++pos)            {                (*this).erase(*pos);            }            return (*this);        }        /// Returns a reference to the data value (double) with corresponding SatID.        /// @param satellite Satellite to be look for.        inline double& operator()(const SatID& satellite) throw(SatIDNotFound)        {            satValueMap::iterator itObs;            itObs = (*this).find(satellite);            if ( itObs != (*this).end() )             {                return (*itObs).second;            } else GPSTK_THROW(SatIDNotFound("SatID not found in map"));        }        /// Destructor.        virtual ~satValueMap() {};    };  // End of satValueMap    /// Map holding SatID with corresponding typeValueMap.    struct satTypeValueMap : std::map<SatID, typeValueMap>    {        /// Returns the number of available satellites.        inline 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.         */        inline size_t numElements() const         {             size_t numEle(0);            satTypeValueMap::const_iterator it;            for (it = (*this).begin(); it != (*this).end(); ++it)             {                numEle = numEle + (*it).second.size();            }            return numEle;        }        /// Returns a SatIDSet with all the satellites present in this object.        inline SatIDSet getSatID() const        {            SatIDSet satSet;            satTypeValueMap::const_iterator pos;            for (pos = (*this).begin(); pos != (*this).end(); ++pos)            {                satSet.insert( (*pos).first );            }            return satSet;        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -