00001 #pragma ident "$Id: ComputeIURAWeights.cpp 1325 2008-07-29 14:33:43Z architest $"
00002
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "ComputeIURAWeights.hpp"
00033
00034
00035 namespace gpstk
00036 {
00037
00038
00039 int ComputeIURAWeights::classIndex = 6000000;
00040
00041
00042
00043 int ComputeIURAWeights::getIndex() const
00044 { return index; }
00045
00046
00047
00048 std::string ComputeIURAWeights::getClassName() const
00049 { return "ComputeIURAWeights"; }
00050
00051
00052
00053
00054
00055
00056
00057
00058 satTypeValueMap& ComputeIURAWeights::Process( const DayTime& time,
00059 satTypeValueMap& gData )
00060 throw(ProcessingException)
00061 {
00062
00063 try
00064 {
00065
00066
00067 double weight(0.000001);
00068
00069 SatIDSet satRejectedSet;
00070
00071
00072 satTypeValueMap::iterator it;
00073 for( it = gData.begin(); it != gData.end(); ++it )
00074 {
00075
00076 try
00077 {
00078
00079
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
00097
00098 satRejectedSet.insert( (*it).first );
00099
00100 continue;
00101
00102 }
00103
00104
00105
00106 (*it).second[TypeID::weight] = weight;
00107
00108 }
00109
00110
00111
00112 gData.removeSatID(satRejectedSet);
00113
00114 return gData;
00115
00116 }
00117 catch(Exception& u)
00118 {
00119
00120 ProcessingException e( getClassName() + ":"
00121 + StringUtils::asString( getIndex() ) + ":"
00122 + u.what() );
00123
00124 GPSTK_THROW(e);
00125
00126 }
00127
00128 }
00129
00130
00131
00132
00133
00134
00135
00136
00137 ComputeIURAWeights& ComputeIURAWeights::setDefaultEphemeris(
00138 XvtStore<SatID>& ephem )
00139 {
00140
00141
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 }
00156
00157
00158
00159
00160
00161
00162
00163
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
00174 preciseEph->getXvt(sat, time);
00175 }
00176 catch(...)
00177 {
00178 InvalidWeights eWeight("Satellite not found.");
00179 GPSTK_THROW(eWeight);
00180 }
00181
00182
00183
00184 return 100.0;
00185
00186 }
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 double ComputeIURAWeights::getWeight( const SatID& sat,
00197 const DayTime& time,
00198 const GPSEphemerisStore* bcEph )
00199 throw(InvalidWeights)
00200 {
00201
00202
00203 int iura(1000000);
00204
00205 double sigma(1000000.0);
00206
00207 EngEphemeris engEph;
00208
00209 try
00210 {
00211
00212 engEph = bcEph->findEphemeris(sat, time);
00213
00214
00215 iura = engEph.getAccFlag();
00216
00217 }
00218 catch(...)
00219 {
00220 InvalidWeights eWeight("Satellite not found.");
00221 GPSTK_THROW(eWeight);
00222 }
00223
00224
00225 sigma = gpstk::ura2nominalAccuracy(iura);
00226
00227 return ( 1.0 / (sigma*sigma) );
00228
00229 }
00230
00231
00232
00233 }