SatID.hpp

Go to the documentation of this file.
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 //  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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          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       // operator=, copy constructor and destructor built by compiler
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             //case systemGalileo:
00149             //case systemGlonass:
00150             //case systemGeosync:
00151             //case systemLEO:
00152             //case systemTransit:
00153             default: return (id > 0 && id < 100);
00154          }
00155       }
00156 
00157       int id;                   
00158       SatelliteSystem system;   
00159 
00160    }; // class SatID
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 } // namespace gpstk
00180 
00181 #endif

Generated on Wed Feb 8 03:31:02 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1