00001 #pragma ident "$Id: ProblemSatFilter.cpp 2528 2011-03-10 16:57:48Z yanweignss $"
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 "ProblemSatFilter.hpp"
00032 #include <fstream>
00033 #include "StringUtils.hpp"
00034
00035
00036 namespace gpstk
00037 {
00038
00039 using namespace std;
00040
00041
00042 int ProblemSatFilter::classIndex = 1100000;
00043
00044
00045
00046 int ProblemSatFilter::getIndex() const
00047 { return index; }
00048
00049
00050
00051 std::string ProblemSatFilter::getClassName() const
00052 { return "ProblemSatFilter"; }
00053
00054
00055
00056
00057
00058
00059
00060
00061 satTypeValueMap& ProblemSatFilter::Process( const DayTime& epoch,
00062 satTypeValueMap& gData )
00063 throw(ProcessingException)
00064 {
00065
00066 try
00067 {
00068
00069 SatIDSet satRejectedSet;
00070
00071
00072 satTypeValueMap::iterator it;
00073 for (it = gData.begin(); it != gData.end(); ++it)
00074 {
00075 if( isBadSat(epoch,it->first)) satRejectedSet.insert(it->first);
00076 }
00077
00078
00079 gData.removeSatID(satRejectedSet);
00080
00081 return gData;
00082
00083 }
00084 catch(Exception& u)
00085 {
00086
00087 ProcessingException e( getClassName() + ":"
00088 + StringUtils::asString( getIndex() ) + ":"
00089 + u.what() );
00090
00091 GPSTK_THROW(e);
00092
00093 }
00094
00095 }
00096
00097
00098
00099
00100
00101
00102
00103 gnssRinex& ProblemSatFilter::Process(gnssRinex& gData)
00104 throw(ProcessingException)
00105 {
00106
00107 try
00108 {
00109
00110 Process(gData.header.epoch, gData.body);
00111
00112 return gData;
00113
00114 }
00115 catch(Exception& u)
00116 {
00117
00118 ProcessingException e( getClassName() + ":"
00119 + StringUtils::asString( getIndex() ) + ":"
00120 + u.what() );
00121
00122 GPSTK_THROW(e);
00123
00124 }
00125
00126 }
00127
00128
00129 int ProblemSatFilter::loadSatelliteProblemFile(const string& crxFile)
00130 {
00131 ifstream istrm(crxFile.c_str());
00132 if(istrm.bad()) return -1;
00133
00134 string buffer;
00135
00136
00137 for(int i=0;i<6;i++) getline(istrm,buffer);
00138
00139 long counter(0);
00140
00141 while( getline(istrm,buffer) )
00142 {
00143 string data(buffer);
00144 StringUtils::stripTrailing(data);
00145
00146 StringUtils::strip(buffer);
00147 if (buffer.length()<1) break;
00148
00149
00150 int satellite(0), problem(0), action(0);
00151 stringstream ss(data);
00152 ss >> satellite >> problem >> action;
00153
00154 int s[6]={0.0};
00155 for(int i=0;i<6;i++) ss >> s[i];
00156
00157 DayTime startEpoch(s[0],s[1],s[2],s[3],s[4],double(s[5]));
00158 DayTime endEpoch(startEpoch);
00159 if( data.length()>70 )
00160 {
00161 for(int i=0;i<6;i++) ss >> s[i];
00162 endEpoch.setYMDHMS(s[0],s[1],s[2],s[3],s[4],double(s[5]));
00163 }
00164
00165 int spiltFlag = 0;
00166
00167 string temp = StringUtils::stripLeading(data);
00168 if(temp[0]=='+') spiltFlag = 1;
00169 if(temp[0]=='-') spiltFlag =-1;
00170
00171
00172 if( std::abs(satellite) <= 32 )
00173 {
00174 SatID sat(std::abs(satellite),SatID::systemGPS);
00175
00176 SatDataMap::iterator it = satDataMap.find(sat);
00177 if(it==satDataMap.end())
00178 {
00179 satDataMap[sat] = SatDataList();
00180 }
00181
00182 SatDataList& satDataList = satDataMap[sat];
00183
00184 SatData satData;
00185 satData.spiltFlag = spiltFlag;
00186 satData.problemFlag = problem;
00187 satData.actionFlag = action;
00188 satData.startEpoch = startEpoch;
00189 satData.endEpoch = endEpoch;
00190
00191 satDataList.push_back(satData);
00192 }
00193
00194 counter++;
00195 }
00196
00197
00198 istrm.close();
00199
00200 return 0;
00201 }
00202
00203 bool ProblemSatFilter::isBadSat(const DayTime& time,const SatID& sat)
00204 {
00205 SatDataMap::iterator it = satDataMap.find(sat);
00206 if( it == satDataMap.end() ) return false;
00207
00208 SatDataList& dataList = satDataMap[sat];
00209
00210 for( SatDataList::iterator itt = dataList.begin();
00211 itt != dataList.end();
00212 ++itt)
00213 {
00214 if( time >= itt->startEpoch && time <= itt->endEpoch )
00215 {
00216 if( (itt->actionFlag == 2) ||
00217 (itt->problemFlag== 1) ||
00218 (itt->problemFlag== 2) ||
00219 (itt->problemFlag== 3) ) { return true; }
00220
00221 }
00222
00223 }
00224
00225 return false;
00226
00227 }
00228
00229 }