NablaOp.cpp

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

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