00001 #pragma ident "$Id: EclipsedSatFilter.cpp 1325 2008-07-29 14:33:43Z 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 "EclipsedSatFilter.hpp"
00032
00033
00034 namespace gpstk
00035 {
00036
00037
00038 int EclipsedSatFilter::classIndex = 1100000;
00039
00040
00041
00042 int EclipsedSatFilter::getIndex() const
00043 { return index; }
00044
00045
00046
00047 std::string EclipsedSatFilter::getClassName() const
00048 { return "EclipsedSatFilter"; }
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 EclipsedSatFilter& EclipsedSatFilter::setConeAngle(const double angle)
00059 {
00060
00061 if( (angle >= 0.0) && (angle < 90.0) )
00062 {
00063
00064 coneAngle = angle;
00065 }
00066
00067 return (*this);
00068
00069 }
00070
00071
00072
00073
00074
00075
00076
00077
00078 EclipsedSatFilter& EclipsedSatFilter::setPostShadowPeriod(
00079 const double pShTime)
00080 {
00081
00082 if( pShTime >= 0.0 )
00083 {
00084 postShadowPeriod = pShTime;
00085 }
00086
00087 return (*this);
00088
00089 }
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 satTypeValueMap& EclipsedSatFilter::Process( const DayTime& epoch,
00100 satTypeValueMap& gData )
00101 throw(ProcessingException)
00102 {
00103
00104 try
00105 {
00106
00107 SatIDSet satRejectedSet;
00108
00109
00110
00111 double threshold( std::cos(PI - coneAngle/2.0*DEG_TO_RAD) );
00112
00113
00114 SunPosition sunPosition;
00115 Triple sunPos(sunPosition.getPosition(epoch));
00116
00117
00118 Triple svPos(0.0, 0.0, 0.0);
00119
00120
00121 satTypeValueMap::iterator it;
00122 for (it = gData.begin(); it != gData.end(); ++it)
00123 {
00124
00125 if( ( (*it).second.find(TypeID::satX) == (*it).second.end() ) ||
00126 ( (*it).second.find(TypeID::satY) == (*it).second.end() ) ||
00127 ( (*it).second.find(TypeID::satZ) == (*it).second.end() ) )
00128 {
00129
00130
00131
00132 satRejectedSet.insert( (*it).first );
00133 continue;
00134 }
00135 else
00136 {
00137
00138 svPos[0] = (*it).second[TypeID::satX];
00139 svPos[1] = (*it).second[TypeID::satY];
00140 svPos[2] = (*it).second[TypeID::satZ];
00141 }
00142
00143
00144 Triple rk( svPos.unitVector() );
00145
00146
00147 Triple ri( sunPos.unitVector() );
00148
00149
00150 double cosAngle(ri.dot(rk));
00151
00152
00153 if(cosAngle <= threshold)
00154 {
00155
00156 satRejectedSet.insert( (*it).first );
00157
00158
00159 shadowEpoch[(*it).first] = epoch;
00160
00161 continue;
00162 }
00163 else
00164 {
00165
00166
00167 if( shadowEpoch.find( (*it).first ) != shadowEpoch.end() )
00168 {
00169
00170
00171 if( std::abs( ( epoch - shadowEpoch[(*it).first] ) ) <=
00172 postShadowPeriod )
00173 {
00174
00175 satRejectedSet.insert( (*it).first );
00176 }
00177 else
00178 {
00179
00180 shadowEpoch.erase( (*it).first );
00181 }
00182 }
00183 }
00184
00185 }
00186
00187
00188 gData.removeSatID(satRejectedSet);
00189
00190 return gData;
00191
00192 }
00193 catch(Exception& u)
00194 {
00195
00196 ProcessingException e( getClassName() + ":"
00197 + StringUtils::asString( getIndex() ) + ":"
00198 + u.what() );
00199
00200 GPSTK_THROW(e);
00201
00202 }
00203
00204 }
00205
00206
00207
00208
00209
00210
00211
00212 gnssRinex& EclipsedSatFilter::Process(gnssRinex& gData)
00213 throw(ProcessingException)
00214 {
00215
00216 try
00217 {
00218
00219 Process(gData.header.epoch, gData.body);
00220
00221 return gData;
00222
00223 }
00224 catch(Exception& u)
00225 {
00226
00227 ProcessingException e( getClassName() + ":"
00228 + StringUtils::asString( getIndex() ) + ":"
00229 + u.what() );
00230
00231 GPSTK_THROW(e);
00232
00233 }
00234
00235 }
00236
00237
00238 }