ComputeDOP.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ComputeDOP.cpp 1325 2008-07-29 14:33:43Z architest $"
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 ). 2008
00027 //
00028 //============================================================================
00029 
00030 
00031 #include "ComputeDOP.hpp"
00032 
00033 
00034 namespace gpstk
00035 {
00036 
00037       // Index initially assigned to this class
00038    int ComputeDOP::classIndex= 4800000;
00039 
00040 
00041       // Returns an index identifying this object.
00042    int ComputeDOP::getIndex() const
00043    { return index; }
00044 
00045 
00046       // Returns a string identifying this object.
00047    std::string ComputeDOP::getClassName() const
00048    { return "ComputeDOP"; }
00049 
00050 
00051 
00052       /* Returns a satTypeValueMap object, adding the new data generated when
00053        * calling this object.
00054        *
00055        * @param time      Epoch corresponding to the data.
00056        * @param gData     Data object holding the data.
00057        */
00058    satTypeValueMap& ComputeDOP::Process( const DayTime& time,
00059                                          satTypeValueMap& gData)
00060       throw(ProcessingException)
00061    {
00062 
00063       try
00064       {
00065 
00066          bool valid1(false), valid2(false); 
00067 
00068             // First, let's define a set with XYZt unknowns
00069          TypeIDSet tempSet1;
00070          tempSet1.insert(TypeID::dx);
00071          tempSet1.insert(TypeID::dy);
00072          tempSet1.insert(TypeID::dz);
00073          tempSet1.insert(TypeID::cdt);
00074 
00075             // Second, let's define a set with NEUt unknowns
00076          TypeIDSet tempSet2;
00077          tempSet2.insert(TypeID::dLat);
00078          tempSet2.insert(TypeID::dLon);
00079          tempSet2.insert(TypeID::dH);
00080          tempSet2.insert(TypeID::cdt);
00081 
00082             // Then, generate the corresponding geometry/design matrices
00083          Matrix<double> dMatrix1(gData.getMatrixOfTypes(tempSet1));
00084          Matrix<double> dMatrix2(gData.getMatrixOfTypes(tempSet2));
00085 
00086             // Afterwards, compute the appropriate extra matrices
00087          Matrix<double> AT1(transpose(dMatrix1));
00088          Matrix<double> covM1(AT1 * dMatrix1);
00089 
00090          Matrix<double> AT2(transpose(dMatrix2));
00091          Matrix<double> covM2(AT2 * dMatrix2);
00092 
00093             // Let's try to invert AT*A matrices
00094          try
00095          {
00096 
00097             covM1 = inverseChol( covM1 );
00098             valid1 = true;
00099 
00100          }
00101          catch(...)
00102          {
00103 
00104             valid1 = false;
00105          }
00106 
00107          try
00108          {
00109 
00110             covM2 = inverseChol( covM2 );
00111             valid2 = true;
00112 
00113          }
00114          catch(...)
00115          {
00116             valid2 = false;
00117          }
00118 
00119          if( valid1 )
00120          {
00121 
00122             gdop = std::sqrt(covM1(0,0)+covM1(1,1)+covM1(2,2)+covM1(3,3));
00123             pdop = std::sqrt(covM1(0,0)+covM1(1,1)+covM1(2,2));
00124             tdop = std::sqrt(covM1(3,3));
00125 
00126          }
00127          else
00128          {
00129             gdop = -1.0;
00130             pdop = -1.0;
00131             tdop = -1.0;
00132          }
00133 
00134          if( valid2 )
00135          {
00136             hdop = std::sqrt(covM2(0,0)+covM2(1,1));
00137             vdop = std::sqrt(covM2(2,2));
00138          }
00139          else
00140          {
00141             hdop = -1.0;
00142             vdop = -1.0;
00143          }
00144 
00145          return gData;
00146 
00147       }
00148       catch(Exception& u)
00149       {
00150             // Throw an exception if something unexpected happens
00151          ProcessingException e( getClassName() + ":"
00152                                 + StringUtils::asString( getIndex() ) + ":"
00153                                 + u.what() );
00154 
00155          GPSTK_THROW(e);
00156 
00157       }
00158 
00159    }  // End of method 'ComputeDOP::Process()'
00160 
00161 
00162 
00163 }  // End of namespace gpstk

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