00001 #pragma ident "$Id: PhaseCodeAlignment.cpp 1915 2009-05-25 11:49:54Z architest $"
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "PhaseCodeAlignment.hpp"
00032
00033
00034 namespace gpstk
00035 {
00036
00037
00038 int PhaseCodeAlignment::classIndex = 4400000;
00039
00040
00041
00042 int PhaseCodeAlignment::getIndex() const
00043 { return index; }
00044
00045
00046
00047 std::string PhaseCodeAlignment::getClassName() const
00048 { return "PhaseCodeAlignment"; }
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 PhaseCodeAlignment::PhaseCodeAlignment( const TypeID& phase,
00059 const TypeID& code,
00060 const double wavelength,
00061 bool useArc )
00062 : phaseType(phase), codeType(code), useSatArcs(useArc),
00063 watchCSFlag(TypeID::CSL1)
00064 {
00065
00066
00067 setPhaseWavelength(wavelength);
00068
00069 setIndex();
00070
00071 }
00072
00073
00074
00075
00076
00077
00078
00079 PhaseCodeAlignment& PhaseCodeAlignment::setPhaseWavelength(double wavelength)
00080 {
00081
00082
00083 if (wavelength > 0.0)
00084 {
00085 phaseWavelength = wavelength;
00086 }
00087 else
00088 {
00089 phaseWavelength = 0.1069533781421467;
00090 }
00091
00092 return (*this);
00093
00094 }
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 satTypeValueMap& PhaseCodeAlignment::Process( const DayTime& epoch,
00105 satTypeValueMap& gData )
00106 throw(ProcessingException)
00107 {
00108
00109 try
00110 {
00111
00112 SatIDSet satRejectedSet;
00113
00114
00115 for( satTypeValueMap::iterator it = gData.begin();
00116 it != gData.end();
00117 ++it )
00118 {
00119
00120
00121 std::map<SatID, alignData>::const_iterator itDat(
00122 svData.find( (*it).first ) );
00123 if( itDat == svData.end() )
00124 {
00125
00126
00127 alignData aData;
00128
00129 svData[ (*it).first ] = aData;
00130
00131 }
00132
00133
00134
00135 bool csflag(false);
00136
00137
00138
00139 if(useSatArcs)
00140 {
00141
00142 double arcN(0.0);
00143
00144 try
00145 {
00146
00147
00148 arcN = (*it).second(TypeID::satArc);
00149
00150 }
00151 catch(...)
00152 {
00153
00154
00155
00156 satRejectedSet.insert( (*it).first );
00157
00158 continue;
00159
00160 }
00161
00162
00163
00164 if( svData[(*it).first].arcNumber != arcN )
00165 {
00166
00167
00168 csflag = true;
00169
00170
00171 svData[(*it).first].arcNumber = arcN;
00172 }
00173
00174 }
00175 else
00176 {
00177
00178 double flag(0.0);
00179
00180 try
00181 {
00182
00183
00184 flag = (*it).second(watchCSFlag);
00185
00186 }
00187 catch(...)
00188 {
00189
00190
00191
00192 satRejectedSet.insert( (*it).first );
00193
00194 continue;
00195
00196 }
00197
00198
00199 if( flag > 0.0)
00200 {
00201
00202 csflag = true;
00203 }
00204
00205 }
00206
00207
00208
00209
00210 if(csflag)
00211 {
00212
00213
00214 double diff( (*it).second(codeType) - (*it).second(phaseType) );
00215
00216
00217 diff = diff/phaseWavelength;
00218
00219
00220 diff = std::floor(diff);
00221
00222
00223 svData[(*it).first].offset = diff * phaseWavelength;
00224
00225 }
00226
00227
00228
00229 (*it).second[phaseType] = (*it).second[phaseType]
00230 + svData[(*it).first].offset;
00231
00232 }
00233
00234
00235 gData.removeSatID(satRejectedSet);
00236
00237 return gData;
00238
00239 }
00240 catch(Exception& u)
00241 {
00242
00243 ProcessingException e( getClassName() + ":"
00244 + StringUtils::asString( getIndex() ) + ":"
00245 + u.what() );
00246
00247 GPSTK_THROW(e);
00248
00249 }
00250
00251 }
00252
00253
00254
00255
00256
00257
00258
00259
00260 gnssSatTypeValue& PhaseCodeAlignment::Process(gnssSatTypeValue& gData)
00261 throw(ProcessingException)
00262 {
00263
00264 try
00265 {
00266
00267 Process(gData.header.epoch, gData.body);
00268
00269 return gData;
00270
00271 }
00272 catch(Exception& u)
00273 {
00274
00275 ProcessingException e( getClassName() + ":"
00276 + StringUtils::asString( getIndex() ) + ":"
00277 + u.what() );
00278
00279 GPSTK_THROW(e);
00280
00281 }
00282
00283 }
00284
00285
00286
00287
00288
00289
00290
00291
00292 gnssRinex& PhaseCodeAlignment::Process(gnssRinex& gData)
00293 throw(ProcessingException)
00294 {
00295
00296 try
00297 {
00298
00299 Process(gData.header.epoch, gData.body);
00300
00301 return gData;
00302
00303 }
00304 catch(Exception& u)
00305 {
00306
00307 ProcessingException e( getClassName() + ":"
00308 + StringUtils::asString( getIndex() ) + ":"
00309 + u.what() );
00310
00311 GPSTK_THROW(e);
00312
00313 }
00314
00315 }
00316
00317
00318
00319 }