1 //==============================================================================
2 //
3 //  This file is part of GPSTk, the GPS Toolkit.
4 //
5 //  The GPSTk is free software; you can redistribute it and/or modify
6 //  it under the terms of the GNU Lesser General Public License as published
7 //  by the Free Software Foundation; either version 3.0 of the License, or
8 //  any later version.
9 //
10 //  The GPSTk is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU Lesser General Public License for more details.
14 //
15 //  You should have received a copy of the GNU Lesser General Public
16 //  License along with GPSTk; if not, write to the Free Software Foundation,
17 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 //  This software was developed by Applied Research Laboratories at the
20 //  University of Texas at Austin.
21 //  Copyright 2004-2020, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 //  This software was developed by Applied Research Laboratories at the
28 //  University of Texas at Austin, under contract to an agency or agencies
29 //  within the U.S. Department of Defense. The U.S. Government retains all
30 //  rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 //  Pursuant to DoD Directive 523024
33 //
34 //  DISTRIBUTION STATEMENT A: This software has been approved for public
35 //                            release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #ifndef GPSTK_NAVID_HPP
40 #define GPSTK_NAVID_HPP
41 
42 #include <iostream>
43 #include <iomanip>
44 #include <sstream>
45 #include "gps_constants.hpp"
46 
47 #include "SatID.hpp"
48 #include "ObsID.hpp"
49 #include "NavType.hpp"
50 
51 /**
52  * @file NavID.hpp
53  * gpstk::NavID - navigation message-independent representation of a satellite.
54  */
55 
56 namespace gpstk
57 {
58       /// @ingroup GNSSEph
59       //@{
60 
61    class NavID
62    {
63    public:
64          /// empty constructor, creates an invalid object
NavID()65       NavID() { navType=NavType::Unknown; }
66 
67          /// explicit constructor, no defaults
68          /// WARNING: This constructor has proven insufficient
69          /// for BeiDou.  The BDS ICD requires that PRN 1-5
70          /// use format D2 and PRN 6-30 use format D1.  That
71          /// appears to not be followed in all cases.   Therefore
72          /// users need to differentiate D1/D2 outside NavID
73          /// and use the explicit constructor
74          ///      NavID( NavType::<xxxxx> )
75          /// to instatiate a BeiDou-related NavID.
76       NavID( const SatID& sidr, const ObsID& oidr );
77 
NavID(const NavType nt)78       NavID( const NavType nt) { navType = nt; }
79 
80       NavID( const std::string& s );
81 
82          /// Convenience output method.
dump(std::ostream & s) const83       void dump(std::ostream& s) const
84       {
85          s << convertNavTypeToString(navType);
86       }
87 
88          /// operator == for NavID
operator ==(const NavID & right) const89       bool operator==(const NavID& right) const
90       { return (navType == right.navType); }
91 
92          /// operator != for NavID
operator !=(const NavID & right) const93       bool operator!=(const NavID& right) const
94       { return !(operator==(right)); }
95 
96          /// operator < for NavID : order by system, then number
operator <(const NavID & right) const97       bool operator<(const NavID& right) const
98       {  return (navType<right.navType); }
99 
100          /// operator > for NavID
operator >(const NavID & right) const101       bool operator>(const NavID& right) const
102       {  return (!operator<(right) && !operator==(right)); }
103 
104          /// operator <= for NavID
operator <=(const NavID & right) const105       bool operator<=(const NavID& right) const
106       { return (operator<(right) || operator==(right)); }
107 
108          /// operator >= for NavID
operator >=(const NavID & right) const109       bool operator>=(const NavID& right) const
110       { return !(operator<(right)); }
111 
112       NavType navType;   ///< navType for this satellite
113    }; // class NavID
114 
115       /// stream output for NavID
operator <<(std::ostream & s,const NavID & p)116    inline std::ostream& operator<<(std::ostream& s, const NavID& p)
117    {
118       p.dump(s);
119       return s;
120    }
121 
122       //@}
123 
124    namespace StringUtils
125    {
126          /// @ingroup StringUtils
asString(const NavID & p)127       inline std::string asString(const NavID& p)
128       {
129          std::ostringstream oss;
130          p.dump(oss);
131          return oss.str();
132       }
133    }
134 
135 } // namespace gpstk
136 
137 #endif
138