00001 #pragma ident "$Id: PCSmoother.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 "PCSmoother.hpp"
00033
00034
00035 namespace gpstk
00036 {
00037
00038
00039 int PCSmoother::classIndex = 2450000;
00040
00041
00042
00043 int PCSmoother::getIndex() const
00044 { return index; }
00045
00046
00047
00048 std::string PCSmoother::getClassName() const
00049 { return "PCSmoother"; }
00050
00051
00052
00053
00054
00055
00056
00057
00058 satTypeValueMap& PCSmoother::Process(satTypeValueMap& gData)
00059 throw(ProcessingException)
00060 {
00061
00062 try
00063 {
00064
00065 double codeObs(0.0);
00066 double phaseObs(0.0);
00067 double flagObs1(0.0);
00068 double flagObs2(0.0);
00069
00070 SatIDSet satRejectedSet;
00071
00072
00073 satTypeValueMap::iterator it;
00074 for (it = gData.begin(); it != gData.end(); ++it)
00075 {
00076
00077 try
00078 {
00079
00080
00081 codeObs = (*it).second(codeType);
00082 phaseObs = (*it).second(phaseType);
00083
00084 }
00085 catch(...)
00086 {
00087
00088
00089
00090 satRejectedSet.insert( (*it).first );
00091
00092 continue;
00093
00094 }
00095
00096 try
00097 {
00098
00099
00100 flagObs1 = (*it).second(csFlag1);
00101
00102 }
00103 catch(...)
00104 {
00105
00106
00107
00108 flagObs1 = 0.0;
00109
00110 }
00111
00112 try
00113 {
00114
00115
00116 flagObs2 = (*it).second(csFlag2);
00117
00118 }
00119 catch(...)
00120 {
00121
00122
00123
00124 flagObs2 = 0.0;
00125
00126 }
00127
00128
00129 (*it).second[resultType] = getSmoothing( (*it).first,
00130 codeObs,
00131 phaseObs,
00132 flagObs1,
00133 flagObs2 );
00134
00135 }
00136
00137
00138 gData.removeSatID(satRejectedSet);
00139
00140 return gData;
00141
00142 }
00143 catch(Exception& u)
00144 {
00145
00146 ProcessingException e( getClassName() + ":"
00147 + StringUtils::asString( getIndex() ) + ":"
00148 + u.what() );
00149
00150 GPSTK_THROW(e);
00151
00152 }
00153
00154 }
00155
00156
00157
00158
00159
00160
00161
00162 PCSmoother& PCSmoother::setMaxWindowSize(const int& maxSize)
00163 {
00164
00165
00166 if (maxSize > 1)
00167 {
00168 maxWindowSize = maxSize;
00169 }
00170 else
00171 {
00172 maxWindowSize = 1;
00173 }
00174
00175 return (*this);
00176
00177 }
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 double PCSmoother::getSmoothing( const SatID& sat,
00190 const double& code,
00191 const double& phase,
00192 const double& flag1,
00193 const double& flag2 )
00194 {
00195
00196
00197 if ( (flag1!=0.0) || (flag2!=0.0) )
00198 {
00199
00200 SmoothingData[sat].previousCode = code;
00201 SmoothingData[sat].previousPhase = phase;
00202 SmoothingData[sat].windowSize = 1;
00203
00204
00205 return code;
00206
00207 }
00208
00209
00210 double smoothedCode(0.0);
00211
00212
00213 ++SmoothingData[sat].windowSize;
00214 if (SmoothingData[sat].windowSize > maxWindowSize)
00215 {
00216 SmoothingData[sat].windowSize = maxWindowSize;
00217 }
00218
00219
00220
00221
00222
00223
00224
00225
00226 smoothedCode = ( code +
00227 ((static_cast<double>(SmoothingData[sat].windowSize)) - 1.0) *
00228 (SmoothingData[sat].previousCode +
00229 (phase - SmoothingData[sat].previousPhase) ) ) /
00230 (static_cast<double>(SmoothingData[sat].windowSize));
00231
00232
00233 SmoothingData[sat].previousCode = smoothedCode;
00234 SmoothingData[sat].previousPhase = phase;
00235
00236 return smoothedCode;
00237
00238 }
00239
00240
00241 }