ComputeIURAWeights.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ComputeIURAWeights.cpp 1325 2008-07-29 14:33:43Z 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 ). 2006, 2007, 2008
00028 //
00029 //============================================================================
00030 
00031 
00032 #include "ComputeIURAWeights.hpp"
00033 
00034 
00035 namespace gpstk
00036 {
00037 
00038       // Index initially assigned to this class
00039    int ComputeIURAWeights::classIndex = 6000000;
00040 
00041 
00042       // Returns an index identifying this object.
00043    int ComputeIURAWeights::getIndex() const
00044    { return index; }
00045 
00046 
00047       // Returns a string identifying this object.
00048    std::string ComputeIURAWeights::getClassName() const
00049    { return "ComputeIURAWeights"; }
00050 
00051 
00052 
00053       /* Returns a satTypeValueMap object, adding the new data generated
00054        * when calling this object.
00055        *
00056        * @param gData     Data object holding the data.
00057        */
00058    satTypeValueMap& ComputeIURAWeights::Process( const DayTime& time,
00059                                                  satTypeValueMap& gData )
00060       throw(ProcessingException)
00061    {
00062 
00063       try
00064       {
00065 
00066             // By default set the wight as a very small value
00067          double weight(0.000001);
00068 
00069          SatIDSet satRejectedSet;
00070 
00071                // Loop through all the satellites
00072          satTypeValueMap::iterator it;
00073          for( it = gData.begin(); it != gData.end(); ++it )
00074          {
00075 
00076             try
00077             {
00078 
00079                   // Try to extract the weight value
00080                if( pBCEphemeris != NULL )
00081                {
00082                   weight = getWeight( ((*it).first), time, pBCEphemeris );
00083                }
00084                else
00085                {
00086 
00087                   if( pTabEphemeris != NULL )
00088                   {
00089                      weight = getWeight( ((*it).first), time, pTabEphemeris );
00090                   }
00091                }
00092             }
00093             catch(...)
00094             {
00095 
00096                   // If some value is missing, then schedule this
00097                   // satellite for removal
00098                satRejectedSet.insert( (*it).first );
00099 
00100                continue;
00101 
00102             }
00103 
00104                // If everything is OK, then get the new value inside
00105                // the GDS structure
00106             (*it).second[TypeID::weight] = weight;
00107 
00108          }  // End of 'for( it = gData.begin(); it != gData.end(); ++it )'
00109 
00110 
00111             // Remove satellites with missing data
00112          gData.removeSatID(satRejectedSet);
00113 
00114          return gData;
00115 
00116       }
00117       catch(Exception& u)
00118       {
00119             // Throw an exception if something unexpected happens
00120          ProcessingException e( getClassName() + ":"
00121                                 + StringUtils::asString( getIndex() ) + ":"
00122                                 + u.what() );
00123 
00124          GPSTK_THROW(e);
00125 
00126       }
00127 
00128    }  // End of method 'ComputeIURAWeights::Process()'
00129 
00130 
00131 
00132       /* Method to set the default ephemeris to be used with GNSS
00133        * data structures.
00134        *
00135        * @param ephem     EphemerisStore object to be used
00136        */
00137    ComputeIURAWeights& ComputeIURAWeights::setDefaultEphemeris(
00138                                                    XvtStore<SatID>& ephem )
00139    {
00140 
00141          // Let's check what type ephem belongs to
00142       if( dynamic_cast<GPSEphemerisStore*>(&ephem) )
00143       {
00144          pBCEphemeris = dynamic_cast<GPSEphemerisStore*>(&ephem);
00145          pTabEphemeris = NULL;
00146       }
00147       else
00148       {
00149          pBCEphemeris = NULL;
00150          pTabEphemeris = dynamic_cast<TabularEphemerisStore*>(&ephem);
00151       }
00152 
00153       return (*this);
00154 
00155    }  // End of method 'ComputeIURAWeights::setDefaultEphemeris()'
00156 
00157 
00158 
00159       /* Method to really get the weight of a given satellite.
00160        *
00161        * @param sat           Satellite
00162        * @param time          Epoch
00163        * @param preciseEph    Precise ephemerisStore object to be used
00164        */
00165    double ComputeIURAWeights::getWeight( const SatID& sat,
00166                                          const DayTime& time,
00167                                     const TabularEphemerisStore* preciseEph )
00168       throw(InvalidWeights)
00169    {
00170 
00171       try
00172       {
00173             // Look if this satellite is present in ephemeris
00174          preciseEph->getXvt(sat, time);
00175       }
00176       catch(...)
00177       {
00178          InvalidWeights eWeight("Satellite not found.");
00179          GPSTK_THROW(eWeight);
00180       }
00181 
00182          // An URA of 0.1 m is assumed for all satellites, 
00183          // so sigma = 0.1*0.1 = 0.01 m^2
00184       return 100.0;
00185 
00186    }  // End of method 'ComputeIURAWeights::getWeight()'
00187 
00188 
00189 
00190       /* Method to really get the weight of a given satellite.
00191        *
00192        * @param sat       Satellite
00193        * @param time      Epoch
00194        * @param bcEph     Broadcast EphemerisStore object to be used
00195        */
00196    double ComputeIURAWeights::getWeight( const SatID& sat,
00197                                          const DayTime& time,
00198                                          const GPSEphemerisStore* bcEph )
00199       throw(InvalidWeights)
00200    {
00201 
00202          // Set by default a very big value
00203       int iura(1000000);
00204 
00205       double sigma(1000000.0);
00206 
00207       EngEphemeris engEph;
00208 
00209       try
00210       {
00211             // Look if this satellite is present in ephemeris
00212          engEph = bcEph->findEphemeris(sat, time);
00213 
00214             // If so, get the IURA
00215          iura = engEph.getAccFlag();
00216 
00217       }
00218       catch(...)
00219       {
00220          InvalidWeights eWeight("Satellite not found.");
00221          GPSTK_THROW(eWeight);
00222       }
00223 
00224          // Compute and return the weight
00225       sigma = gpstk::ura2nominalAccuracy(iura);
00226 
00227       return ( 1.0 / (sigma*sigma) );
00228 
00229    }  // End of method 'ComputeIURAWeights::getWeight()'
00230 
00231 
00232 
00233 }  // End of namespace gpstk

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