SatID.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: SatID.hpp 3184 2012-07-01 13:11:07Z yanweignss $"
00002 
00003 #ifndef GPSTK_SATID_HPP
00004 #define GPSTK_SATID_HPP
00005 
00006 //============================================================================
00007 //
00008 //  This file is part of GPSTk, the GPS Toolkit.
00009 //
00010 //  The GPSTk is free software; you can redistribute it and/or modify
00011 //  it under the terms of the GNU Lesser General Public License as published
00012 //  by the Free Software Foundation; either version 2.1 of the License, or
00013 //  any later version.
00014 //
00015 //  The GPSTk is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU Lesser General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU Lesser General Public
00021 //  License along with GPSTk; if not, write to the Free Software Foundation,
00022 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00023 //  
00024 //  Copyright 2004, The University of Texas at Austin
00025 //
00026 //============================================================================
00027 
00028 //============================================================================
00029 //
00030 //This software developed by Applied Research Laboratories at the University of
00031 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00032 //Department of Defense. The U.S. Government retains all rights to use,
00033 //duplicate, distribute, disclose, or release this software. 
00034 //
00035 //Pursuant to DoD Directive 523024 
00036 //
00037 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00038 //                           release, distribution is unlimited.
00039 //
00040 //=============================================================================
00041 
00042 #include <iostream>
00043 #include <iomanip>
00044 #include <sstream>
00045 #include "gps_constants.hpp"
00046 
00052 namespace gpstk
00053 {
00054    // forward declarations
00055    class SatID;
00056 //   std::istream& operator<<(std::istream& s, SatID& p);
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          systemCompass,
00073          systemMixed,
00074          systemUserDefined,
00075          systemUnknown
00076       };
00077 
00079       SatID() { id=-1; system=systemGPS; }
00080 
00084       SatID(int p, SatelliteSystem s) { id=p; system=s; }
00085 
00086       // operator=, copy constructor and destructor built by compiler
00087 
00089       static std::string convertSatelliteSystemToString(SatelliteSystem s)
00090       {
00091          switch(s)
00092          {
00093             case systemGPS:     return "GPS";           break;
00094             case systemGalileo: return "Galileo";       break;
00095             case systemGlonass: return "GLONASS";       break;
00096             case systemGeosync: return "Geostationary"; break;
00097             case systemLEO:     return "LEO";           break;
00098             case systemTransit: return "Transit";       break;
00099             case systemCompass: return "Compass";       break;
00100             case systemMixed:   return "Mixed";         break;
00101             case systemUserDefined:   return "UserDefined";         break;
00102             case systemUnknown: return "Unknown";       break;
00103             default:            return "??";            break;
00104          };
00105       }
00106 
00108       void dump(std::ostream& s) const
00109       {
00110          s << convertSatelliteSystemToString(system) << " " << id;
00111       }
00112 
00114       bool operator==(const SatID& right) const
00115       { return ((system == right.system) && (id == right.id)); }
00116 
00118       bool operator!=(const SatID& right) const
00119       { return !(operator==(right)); }
00120 
00122       bool operator<(const SatID& right) const
00123       {
00124          if (system==right.system)
00125             return (id<right.id);
00126          return (system<right.system);
00127       }
00128 
00130       bool operator>(const SatID& right) const
00131       {  return (!operator<(right) && !operator==(right)); }
00132 
00134       bool operator<=(const SatID& right) const
00135       { return (operator<(right) || operator==(right)); }
00136 
00138       bool operator>=(const SatID& right) const
00139       { return !(operator<(right)); }
00140 
00145       bool isValid() const
00146       {
00147          switch(system)
00148          {
00149             case systemGPS: return (id > 0 && id <= MAX_PRN_GPS);
00150             //case systemGalileo:
00151             //case systemGlonass:
00152             //case systemGeosync:
00153             //case systemLEO:
00154             //case systemTransit:
00155             default: return (id > 0 && id < 100);
00156          }
00157       }
00158 
00159       int id;                   
00160       SatelliteSystem system;   
00161 
00162    }; // class SatID
00163 
00164    namespace StringUtils
00165    {
00166       inline std::string asString(const SatID& p)
00167       {
00168          std::ostringstream oss;
00169          p.dump(oss);
00170          return oss.str();
00171       }
00172    }
00173 
00175    inline std::ostream& operator<<(std::ostream& s, const SatID& p)
00176    {
00177       p.dump(s);
00178       return s;
00179    }
00180 
00181 } // namespace gpstk
00182 
00183 #endif

Generated on Thu May 23 03:31:12 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1