NablaOp.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: NablaOp.cpp 3140 2012-06-18 15:03:02Z susancummins $"
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00026 //
00027 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008, 2009, 2011
00028 //
00029 //============================================================================
00030 
00031 
00032 #include "NablaOp.hpp"
00033 
00034 
00035 namespace gpstk
00036 {
00037 
00038       // Returns a string identifying this object.
00039    std::string NablaOp::getClassName() const
00040    { return "NablaOp"; }
00041 
00042 
00043 
00044       /* Default constructor.
00045        *
00046        * By default it will difference prefitC, dx, dy, and dz data and will
00047        * take as reference satellite the one with the highest elevation.
00048        */
00049    NablaOp::NablaOp()
00050       : lookReferenceSat(true)
00051    {
00052 
00053          // Insert default types to be differenced
00054       diffTypes.insert(TypeID::prefitC);
00055       diffTypes.insert(TypeID::dx);
00056       diffTypes.insert(TypeID::dy);
00057       diffTypes.insert(TypeID::dz);
00058 
00059    }  // End of constructor 'NablaOp::NablaOp()'
00060 
00061 
00062 
00063       /* Common constructor taking as input the reference satellite
00064        * to be used.
00065        *
00066        * @param rSat    SatID of satellite to be used as reference.
00067        */
00068    NablaOp::NablaOp(const SatID& rSat)
00069       : refSat(rSat), lookReferenceSat(false)
00070    {
00071 
00072          // Insert default types to be differenced
00073       diffTypes.insert(TypeID::prefitC);
00074       diffTypes.insert(TypeID::dx);
00075       diffTypes.insert(TypeID::dy);
00076       diffTypes.insert(TypeID::dz);
00077 
00078    }  // End of constructor 'NablaOp::NablaOp()'
00079 
00080 
00081 
00082       /* Method to add a set of data value types to be differenced.
00083        *
00084        * @param diffSet    TypeIDSet of data values to be added to the
00085        *                   ones being differenced.
00086        */
00087    NablaOp& NablaOp::addDiffTypeSet(const TypeIDSet& diffSet)
00088    {
00089 
00090          // Iterate over 'diffSet' to add its elements to 'diffTypes'
00091       TypeIDSet::const_iterator pos;
00092       for(pos = diffSet.begin(); pos != diffSet.end(); ++pos)
00093       {
00094          diffTypes.insert(*pos);
00095       }
00096 
00097       return (*this);
00098 
00099    }  // End of method 'NablaOp::addDiffTypeSet()'
00100 
00101 
00102 
00103     // Returns a reference to a gnssSatTypeValue object after differencing the
00104     // data type values given in the diffTypes field with respect to reference
00105     // satellite data.
00106     //
00107     // @param gData     Data object holding the data.
00108     //
00109     satTypeValueMap& NablaOp::Process(satTypeValueMap& gData)
00110       throw(ProcessingException)
00111    {
00112 
00113       try
00114       {
00115 
00116          double maxElevation(0.0);
00117 
00118 
00119             // If configured to do so, let's look for reference satellite
00120          if (lookReferenceSat)
00121          {
00122 
00123                // Loop through all satellites in reference station data set,
00124                // looking for reference satellite
00125             satTypeValueMap::iterator it;
00126             for (it = gData.begin(); it != gData.end(); ++it)
00127             {
00128 
00129                   // The satellite with the highest elevation will usually be
00130                   // the reference satellite
00131                if ( gData((*it).first)(TypeID::elevation) > maxElevation )
00132                {
00133 
00134                   refSat = (*it).first;
00135                   maxElevation = gData((*it).first)(TypeID::elevation);
00136 
00137                }
00138 
00139             }
00140 
00141          }  // End of 'if (lookReferenceSat)'
00142 
00143 
00144             // We will use reference satellite data as reference data
00145          satTypeValueMap refData(gData.extractSatID(refSat));
00146 
00147             // We must remove reference satellite data from data set
00148          gData.removeSatID(refSat);
00149 
00150 
00151          SatIDSet satRejectedSet;
00152 
00153 
00154             // Loop through all the satellites in station data set
00155          satTypeValueMap::iterator it;
00156          for (it = gData.begin(); it != gData.end(); ++it)
00157          {
00158 
00159                // We must compute the difference for all types in
00160                // 'diffTypes' set
00161             TypeIDSet::const_iterator itType;
00162             for(itType = diffTypes.begin(); itType != diffTypes.end(); ++itType)
00163             {
00164 
00165                double value1(0.0);
00166                double value2(0.0);
00167 
00168                try
00169                {
00170 
00171                      // Let's try to compute the difference
00172                   value1 = gData((*it).first)(*itType);
00173                   value2 = refData(refSat)(*itType);
00174 
00175                      // Get difference into data structure
00176                   gData((*it).first)((*itType)) =  value1 - value2;
00177 
00178                }
00179                catch(...)
00180                {
00181 
00182                      // If some value is missing, then schedule this satellite
00183                      // for removal
00184                   satRejectedSet.insert( (*it).first );
00185 
00186                   continue;
00187 
00188                }
00189 
00190             }  // End of 'for(itType = diffTypes.begin(); ...'
00191 
00192          }  // End of 'for (it = gData.begin(); it != gData.end(); ++it)'
00193 
00194 
00195             // Remove satellites with missing data
00196          gData.removeSatID(satRejectedSet);
00197 
00198          return gData;
00199 
00200       }
00201       catch(Exception& u)
00202       {
00203             // Throw an exception if something unexpected happens
00204          ProcessingException e( getClassName() + ":"
00205                                 + u.what() );
00206 
00207          GPSTK_THROW(e);
00208 
00209       }
00210 
00211    }  // End of method 'NablaOp::Process()'
00212 
00213 
00214 
00215 }  // End of namespace gpstk

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