00001 #pragma ident "$Id: SimpleIURAWeight.cpp 1889 2009-05-11 15:47:23Z afarris $"
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
00033 #include "SimpleIURAWeight.hpp"
00034
00035 using namespace std;
00036 namespace gpstk
00037 {
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 int SimpleIURAWeight::getWeights(DayTime& time, Vector<SatID>& Satellites, GPSEphemerisStore& bcEph) throw(InvalidWeights)
00051 {
00052 int N = Satellites.size();
00053
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
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
00079 vRejectedSV.push_back(Satellites(i));
00080 validFlag = 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
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 int SimpleIURAWeight::getWeights(DayTime& time, Vector<SatID>& Satellites, TabularEphemerisStore& preciseEph) throw(InvalidWeights)
00112 {
00113 int N = Satellites.size();
00114
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
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
00137 vRejectedSV.push_back(Satellites(i));
00138 validFlag = false;
00139 continue;
00140 }
00141
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