SimpleIURAWeight.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: SimpleIURAWeight.cpp 1889 2009-05-11 15:47:23Z afarris $"
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. 2006
00028 //
00029 //============================================================================
00030 
00031 
00032 
00033 #include "SimpleIURAWeight.hpp"
00034 
00035 using namespace std;
00036 namespace gpstk
00037 {
00038 
00039     // Compute and return a vector with the weights for the given satellites
00040     // @param time           Epoch weights will be computed for
00041     // @param Satellites     Vector of satellites
00042     // @param bcEph          Satellite broadcast ephemeris
00043     //
00044     // @return
00045     //  Number of satellites with valid weights
00046     //
00047     // NOTE: Method isValid() will return false if some satellite does not have a
00048     // valid weight.
00049     //
00050     int SimpleIURAWeight::getWeights(DayTime& time, Vector<SatID>& Satellites, GPSEphemerisStore& bcEph) throw(InvalidWeights)
00051     {
00052         int N = Satellites.size();
00053         // We need at least one satellite
00054         if (N == 0)
00055         {
00056             InvalidWeights eWeight("At least one satellite is needed to compute weights.");
00057             GPSTK_THROW(eWeight);
00058         }
00059 
00060         int i, iura;
00061         double sigma;
00062         // Some std::vectors to hold temporal values (do not confuse with gpstk::Vector)
00063         vector<double> vWeight;
00064         vector<SatID> vAvailableSV;
00065         vector<SatID> vRejectedSV;
00066         EngEphemeris engEph;
00067         bool validFlag = true;
00068 
00069         for (i=0; i<N; i++)
00070         {
00071             try
00072             {
00073                 engEph = bcEph.findEphemeris(Satellites(i), time);
00074                 iura = engEph.getAccFlag();
00075             }
00076             catch(...)
00077             {
00078                 // If there are problems, we skip this satellite
00079                 vRejectedSV.push_back(Satellites(i));
00080                 validFlag = false;      // Validity flag is set to false
00081                 continue;
00082             }
00083             sigma = gpstk::ura2nominalAccuracy(iura);
00084             vWeight.push_back( 1.0 / (sigma*sigma) );
00085             vAvailableSV.push_back(Satellites(i));
00086         }
00087 
00088         valid = validFlag;
00089         weightsVector = vWeight;
00090         availableSV = vAvailableSV;
00091         rejectedSV = vRejectedSV;
00092 
00093         return (int)(availableSV.size());
00094 
00095     }
00096 
00097 
00098     // Compute and return a vector with the weights for the given satellites
00099     // @param time           Epoch weights will be computed for
00100     // @param Satellites     Vector of satellites
00101     // @param preciseEph     Satellite precise ephemeris
00102     //
00103     // @return
00104     //  Number of satellites with valid weights
00105     //
00106     // NOTE: Method isValid() will return false if some satellite does not have a
00107     // valid weight.
00108     //
00109     // NOTE: This method assigns an URA of 0.1 m to all satellites.
00110     //
00111     int SimpleIURAWeight::getWeights(DayTime& time, Vector<SatID>& Satellites, TabularEphemerisStore& preciseEph) throw(InvalidWeights)
00112     {
00113         int N = Satellites.size();
00114         // We need at least one satellite
00115         if (N == 0)
00116         {
00117             InvalidWeights eWeight("At least one satellite is needed to compute weights.");
00118             GPSTK_THROW(eWeight);
00119         }
00120 
00121         int i;
00122         // Some std::vectors to hold temporal values (do not confuse with gpstk::Vector)
00123         vector<double> vWeight;
00124         vector<SatID> vAvailableSV;
00125         vector<SatID> vRejectedSV;
00126         bool validFlag = true;
00127 
00128         for (i=0; i<N; i++)
00129         {
00130             try
00131             {
00132                 preciseEph.getXvt(Satellites(i), time);
00133             }
00134             catch(...)
00135             {
00136                 // If the satellite is not available, we skip it
00137                 vRejectedSV.push_back(Satellites(i));
00138                 validFlag = false;      // Validity flag is set to false
00139                 continue;
00140             }
00141             // An URA of 0.1 m is assumed for all satellites, so sigma=0.1*0.1= 0.01 m^2
00142             vWeight.push_back( 100.0 );
00143             vAvailableSV.push_back(Satellites(i));
00144         }
00145 
00146         valid = validFlag;
00147         weightsVector = vWeight;
00148         availableSV = vAvailableSV;
00149         rejectedSV = vRejectedSV;
00150 
00151         return (int)(availableSV.size());
00152 
00153     }
00154 
00155 
00156 
00157   
00158 }
00159 

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