00001 #pragma ident "$Id: DCBDataReader.cpp 3140 2012-06-18 15:03:02Z susancummins $"
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 "DCBDataReader.hpp"
00032
00033 using namespace std;
00034
00035 namespace gpstk
00036 {
00037
00038
00039
00040 void DCBDataReader::loadData()
00041 throw( FFStreamError, gpstk::StringUtils::StringException )
00042 {
00043
00044 try
00045 {
00046 allDCB.satDCB.clear();
00047 allDCB.gpsDCB.clear();
00048 allDCB.glonassDCB.clear();
00049
00050
00051 string line;
00052
00053
00054 formattedGetLine(line, true);
00055
00056
00057 for(int i=0; i<6; i++) formattedGetLine(line, true);
00058
00059
00060
00061 while(1)
00062 {
00063 formattedGetLine(line, true);
00064
00065 if(line.length() < 46) continue;
00066
00067 string sysFlag = line.substr(0,1);
00068
00069 int satPRN = StringUtils::asInt(line.substr(1,2));
00070
00071 string station = StringUtils::strip(line.substr(6,4));
00072
00073 double dcbVal = StringUtils::asDouble(line.substr(26,9));
00074 double dcbRMS = StringUtils::asDouble(line.substr(38,9));
00075
00076 if(station.length() < 4)
00077 {
00078
00079 SatID sat;
00080 if(sysFlag == "G")
00081 {
00082 sat = SatID(satPRN,SatID::systemGPS);
00083 }
00084 else if(sysFlag == "R")
00085 {
00086 sat = SatID(satPRN,SatID::systemGlonass);
00087 }
00088 else
00089 {
00090
00091
00092
00093 }
00094
00095 allDCB.satDCB[sat] = dcbVal;
00096
00097 }
00098 else
00099 {
00100 if(sysFlag == "G")
00101 {
00102 allDCB.gpsDCB[station] = dcbVal;
00103 }
00104 else if(sysFlag == "R")
00105 {
00106 allDCB.glonassDCB[station] = dcbVal;
00107 }
00108 else
00109 {
00110
00111
00112 }
00113 }
00114
00115 }
00116
00117 }
00118 catch (EndOfFile& e)
00119 {
00120
00121
00122 (*this).close();
00123
00124 return;
00125 }
00126 catch (...)
00127 {
00128
00129
00130 (*this).close();
00131
00132 return;
00133
00134 }
00135
00136
00137 }
00138
00139
00140
00141
00142 void DCBDataReader::open(const char* fn)
00143 {
00144
00145
00146 (*this).close();
00147
00148
00149 FFTextStream::open(fn, std::ios::in);
00150 loadData();
00151
00152 return;
00153
00154 }
00155
00156
00157
00158
00159
00160 void DCBDataReader::open(const string& fn)
00161 {
00162
00163
00164 (*this).close();
00165
00166
00167 FFTextStream::open(fn.c_str(), std::ios::in);
00168 loadData();
00169
00170 return;
00171 }
00172
00173
00174 double DCBDataReader::getDCB(const SatID& sat)
00175 {
00176 return allDCB.satDCB[sat];
00177 }
00178
00179
00180
00181 double DCBDataReader::getDCB(const int& prn,
00182 const SatID::SatelliteSystem& system)
00183 {
00184 SatID sat(prn,system);
00185 return allDCB.satDCB[sat];
00186 }
00187
00188
00189
00190 double DCBDataReader::getDCB(const string& station,
00191 const SatID::SatelliteSystem& system)
00192 {
00193
00194 if(system == SatID::systemGPS)
00195 {
00196 return allDCB.gpsDCB[station];
00197 }
00198 else if(system == SatID::systemGlonass)
00199 {
00200 return allDCB.glonassDCB[station];
00201 }
00202 else
00203 {
00204
00205 return 0.0;
00206 }
00207
00208 }
00209
00210
00211
00212 }
00213