RequireObservables.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: RequireObservables.cpp 1460 2008-11-18 15:41:23Z ckiesch $"
00002 
00008 //============================================================================
00009 //
00010 //  This file is part of GPSTk, the GPS Toolkit.
00011 //
00012 //  The GPSTk is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU Lesser General Public License as published
00014 //  by the Free Software Foundation; either version 2.1 of the License, or
00015 //  any later version.
00016 //
00017 //  The GPSTk is distributed in the hope that it will be useful,
00018 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //  GNU Lesser General Public License for more details.
00021 //
00022 //  You should have received a copy of the GNU Lesser General Public
00023 //  License along with GPSTk; if not, write to the Free Software Foundation,
00024 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 //
00026 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008
00027 //
00028 //============================================================================
00029 
00030 
00031 #include "RequireObservables.hpp"
00032 
00033 
00034 namespace gpstk
00035 {
00036 
00037       // Index initially assigned to this class
00038    int RequireObservables::classIndex = 1200000;
00039 
00040 
00041       // Returns an index identifying this object.
00042    int RequireObservables::getIndex() const
00043    { return index; }
00044 
00045 
00046       // Returns a string identifying this object.
00047    std::string RequireObservables::getClassName() const
00048    { return "RequireObservables"; }
00049 
00050 
00051 
00052       /* Method to add a set of TypeID's to be required.
00053        *
00054        * @param typeSet    Set of TypeID's to be required.
00055        */
00056    RequireObservables& RequireObservables::addRequiredType(TypeIDSet& typeSet)
00057    {
00058 
00059       requiredTypeSet.insert( typeSet.begin(),
00060                               typeSet.end() );
00061 
00062       return (*this);
00063 
00064    }  // End of method 'RequireObservables::addRequiredType()'
00065 
00066 
00067 
00068       // Returns a satTypeValueMap object, filtering the target observables.
00069       //
00070       // @param gData     Data object holding the data.
00071       //
00072    satTypeValueMap& RequireObservables::Process(satTypeValueMap& gData)
00073       throw(ProcessingException)
00074    {
00075 
00076       try
00077       {
00078 
00079          SatIDSet satRejectedSet;
00080 
00081             // Loop through all the satellites
00082          for ( satTypeValueMap::iterator satIt = gData.begin();
00083                satIt != gData.end();
00084                ++satIt )
00085          {
00086 
00087 
00088                // Check all the indicated TypeID's
00089             for ( TypeIDSet::const_iterator typeIt = requiredTypeSet.begin();
00090                   typeIt != requiredTypeSet.end();
00091                   ++typeIt )
00092             {
00093 
00094 
00095                   // Try to find required type
00096                typeValueMap::iterator it( (*satIt).second.find(*typeIt) );
00097 
00098                   // Now, check if this TypeID exists in this data structure
00099                if ( it == (*satIt).second.end() )
00100                {
00101                      // If we couldn't find type, then schedule this
00102                      // satellite for removal
00103                   satRejectedSet.insert( (*satIt).first );
00104 
00105                      // It is not necessary to keep looking
00106                   typeIt = requiredTypeSet.end();
00107                   --typeIt;
00108                }
00109 
00110             }
00111 
00112          }
00113 
00114             // Let's remove satellites without all TypeID's
00115          gData.removeSatID(satRejectedSet);
00116 
00117          return gData;
00118 
00119       }
00120       catch(Exception& u)
00121       {
00122             // Throw an exception if something unexpected happens
00123          ProcessingException e( getClassName() + ":"
00124                                 + StringUtils::asString( getIndex() ) + ":"
00125                                 + u.what() );
00126 
00127          GPSTK_THROW(e);
00128 
00129       }
00130 
00131    }  // End of 'RequireObservables::Process()'
00132 
00133 
00134 } // End of namespace gpstk

Generated on Tue May 22 03:31:00 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1