DeltaOp.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: DeltaOp.cpp 2619 2011-05-26 03:36:15Z yanweignss $"
00002 
00009 //============================================================================
00010 //
00011 //  This file is part of GPSTk, the GPS Toolkit.
00012 //
00013 //  The GPSTk is free software; you can redistribute it and/or modify
00014 //  it under the terms of the GNU Lesser General Public License as published
00015 //  by the Free Software Foundation; either version 2.1 of the License, or
00016 //  any later version.
00017 //
00018 //  The GPSTk is distributed in the hope that it will be useful,
00019 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 //  GNU Lesser General Public License for more details.
00022 //
00023 //  You should have received a copy of the GNU Lesser General Public
00024 //  License along with GPSTk; if not, write to the Free Software Foundation,
00025 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 //
00027 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008
00028 //
00029 //============================================================================
00030 
00031 
00032 #include "DeltaOp.hpp"
00033 
00034 
00035 namespace gpstk
00036 {
00037 
00038       // Index initially assigned to this class
00039    int DeltaOp::classIndex = 7000000;
00040 
00041 
00042       // Returns an index identifying this object.
00043    int DeltaOp::getIndex() const
00044    { return index; }
00045 
00046 
00047       // Returns a string identifying this object.
00048    std::string DeltaOp::getClassName() const
00049    { return "DeltaOp"; }
00050 
00051 
00052 
00053       /* Method to add a set of data value types to be differenced.
00054        *
00055        * @param diffSet       TypeIDSet of data values to be added to the
00056        *                      ones being differenced.
00057        */
00058    DeltaOp& DeltaOp::addDiffTypeSet(const TypeIDSet& diffSet)
00059    {
00060 
00061          // Iterate over 'diffSet' and add its components to 'diffTypes'
00062       TypeIDSet::const_iterator pos;
00063       for (pos = diffSet.begin(); pos != diffSet.end(); ++pos)
00064       {
00065          diffTypes.insert(*pos);
00066       }
00067 
00068       return (*this);
00069 
00070    }  // End of method 'DeltaOp::addDiffTypeSet()'
00071 
00072 
00073 
00074       /* Returns a reference to a satTypeValueMap object after differencing
00075        * data type values given in 'diffTypes' field with respect to
00076        * reference station data in 'refData' field.
00077        *
00078        * @param gData      Data object holding the data.
00079        */
00080    satTypeValueMap& DeltaOp::Process(satTypeValueMap& gData)
00081       throw(ProcessingException)
00082    {
00083 
00084       try
00085       {
00086 
00087          SatIDSet satRejectedSet;
00088 
00089             // Loop through all the satellites in the station data set
00090          satTypeValueMap::iterator it;
00091          for (it = gData.begin(); it != gData.end(); ++it)
00092          {
00093 
00094                // Let's find if the same satellite is present in refData
00095             satTypeValueMap::const_iterator itref;
00096             itref = refData.find((*it).first);
00097 
00098                // If we found the satellite, let's proceed with the differences
00099             if (itref != refData.end())
00100             {
00101 
00102                   // We must compute the difference for all the types in
00103                   // 'diffTypes' set
00104                TypeIDSet::const_iterator itType;
00105                for( itType = diffTypes.begin();
00106                     itType != diffTypes.end();
00107                     ++itType )
00108                {
00109 
00110                   double value1(0.0);
00111                   double value2(0.0);
00112 
00113                   try
00114                   {
00115 
00116                         // Let's try to compute the difference
00117                      value1 = gData((*it).first)(*itType);
00118                      value2 = refData((*it).first)(*itType);
00119 
00120                         // Get difference into data structure
00121                      gData((*it).first)((*itType)) =  value1 - value2;
00122 
00123                   }
00124                   catch(...)
00125                   {
00126 
00127                         // If some value is missing, then schedule this
00128                         // satellite for removal
00129                      satRejectedSet.insert( (*it).first );
00130 
00131                         // Skip this value if problems arise
00132                      continue;
00133 
00134                   }
00135 
00136                }  // End of 'for( itType = diffTypes.begin(); ...'
00137 
00138                   // update CSFlag
00139                if(updateCSFlag)
00140                {
00141                   double CSValue1 = gData[it->first][TypeID::CSL1] 
00142                                    +refData[it->first][TypeID::CSL1];
00143                   double CSValue2 = gData[it->first][TypeID::CSL2] 
00144                                    +refData[it->first][TypeID::CSL2];
00145 
00146 
00147                   gData[it->first][TypeID::CSL1] = (CSValue1 > 0.0) ? 1.0 : 0.0;
00148                   
00149                   gData[it->first][TypeID::CSL2] = (CSValue2 > 0.0) ? 1.0 : 0.0;
00150 
00151                }  // End of 'if(updateCSFlag)'
00152 
00153             }
00154             else
00155             {
00156 
00157                   // If we didn't find the same satellite in both sets, mark
00158                   // it for deletion
00159                satRejectedSet.insert( (*it).first );
00160 
00161                continue;
00162 
00163             }  // End of 'if (itref != refData.end())'
00164 
00165          }  // End of 'for (it = gData.begin(); it != gData.end(); ++it)'
00166 
00167             // If ordered so, delete the missing satellites
00168          if (deleteMissingSats)
00169          {
00170             gData.removeSatID(satRejectedSet);
00171          }
00172 
00173          return gData;
00174 
00175       }
00176       catch(Exception& u)
00177       {
00178             // Throw an exception if something unexpected happens
00179          ProcessingException e( getClassName() + ":"
00180                                 + StringUtils::asString( getIndex() ) + ":"
00181                                 + u.what() );
00182 
00183          GPSTK_THROW(e);
00184 
00185       }
00186 
00187    }  // End of method 'DeltaOp::Process()'
00188 
00189 
00190 
00191 }  // End of namespace gpstk

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