00001 #pragma ident "$Id: SatID.hpp 2466 2010-09-13 20:34:16Z snelsen $"
00002
00003 #ifndef GPSTK_SATID_HPP
00004 #define GPSTK_SATID_HPP
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <iostream>
00043 #include <iomanip>
00044 #include <sstream>
00045 #include "gps_constants.hpp"
00046
00052 namespace gpstk
00053 {
00054
00055 class SatID;
00056
00057
00060 class SatID
00061 {
00062 public:
00064 enum SatelliteSystem
00065 {
00066 systemGPS = 1,
00067 systemGalileo,
00068 systemGlonass,
00069 systemGeosync,
00070 systemLEO,
00071 systemTransit,
00072 systemMixed,
00073 systemUserDefined,
00074 systemUnknown
00075 };
00076
00078 SatID() { id=-1; system=systemGPS; }
00079
00083 SatID(int p, SatelliteSystem s) { id=p; system=s; }
00084
00085
00086
00088 static std::string convertSatelliteSystemToString(SatelliteSystem s)
00089 {
00090 switch(s)
00091 {
00092 case systemGPS: return "GPS"; break;
00093 case systemGalileo: return "Galileo"; break;
00094 case systemGlonass: return "GLONASS"; break;
00095 case systemGeosync: return "Geostationary"; break;
00096 case systemLEO: return "LEO"; break;
00097 case systemTransit: return "Transit"; break;
00098 case systemMixed: return "Mixed"; break;
00099 case systemUserDefined: return "UserDefined"; break;
00100 case systemUnknown: return "Unknown"; break;
00101 default: return "??"; break;
00102 };
00103 }
00104
00106 void dump(std::ostream& s) const
00107 {
00108 s << convertSatelliteSystemToString(system) << " " << id;
00109 }
00110
00112 bool operator==(const SatID& right) const
00113 { return ((system == right.system) && (id == right.id)); }
00114
00116 bool operator!=(const SatID& right) const
00117 { return !(operator==(right)); }
00118
00120 bool operator<(const SatID& right) const
00121 {
00122 if (system==right.system)
00123 return (id<right.id);
00124 return (system<right.system);
00125 }
00126
00128 bool operator>(const SatID& right) const
00129 { return (!operator<(right) && !operator==(right)); }
00130
00132 bool operator<=(const SatID& right) const
00133 { return (operator<(right) || operator==(right)); }
00134
00136 bool operator>=(const SatID& right) const
00137 { return !(operator<(right)); }
00138
00143 bool isValid() const
00144 {
00145 switch(system)
00146 {
00147 case systemGPS: return (id > 0 && id <= MAX_PRN);
00148
00149
00150
00151
00152
00153 default: return (id > 0 && id < 100);
00154 }
00155 }
00156
00157 int id;
00158 SatelliteSystem system;
00159
00160 };
00161
00162 namespace StringUtils
00163 {
00164 inline std::string asString(const SatID& p)
00165 {
00166 std::ostringstream oss;
00167 p.dump(oss);
00168 return oss.str();
00169 }
00170 }
00171
00173 inline std::ostream& operator<<(std::ostream& s, const SatID& p)
00174 {
00175 p.dump(s);
00176 return s;
00177 }
00178
00179 }
00180
00181 #endif