Changeset 1218 in ntrip for trunk/BNC/RTCM
- Timestamp:
- Nov 19, 2008, 2:56:05 PM (16 years ago)
- Location:
- trunk/BNC/RTCM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/RTCM/GPSDecoder.h
r1184 r1218 27 27 28 28 #include <iostream> 29 #include <vector> 30 #include <string> 29 31 #include <QPointer> 30 32 #include <QList> … … 121 123 class GPSDecoder { 122 124 public: 123 virtual t_irc Decode(char* buffer, int bufLen) = 0; 125 virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg) = 0; 124 126 125 127 virtual ~GPSDecoder() { -
trunk/BNC/RTCM/RTCM2Decoder.cpp
r1167 r1218 42 42 #include <sstream> 43 43 #include <iomanip> 44 #include <set> 44 45 45 46 #include "../bncutils.h" … … 64 65 65 66 RTCM2Decoder::~RTCM2Decoder() { 66 for (t_ pairMap::iterator ii = _ephPair.begin(); ii != _ephPair.end(); ii++) {67 for (t_listMap::iterator ii = _ephList.begin(); ii != _ephList.end(); ii++) { 67 68 delete ii->second; 68 69 } … … 104 105 105 106 // 106 t_irc RTCM2Decoder::Decode(char* buffer, int bufLen) { 107 t_irc RTCM2Decoder::Decode(char* buffer, int bufLen, vector<string>& errmsg) { 108 109 errmsg.clear(); 107 110 108 111 _buffer.append(buffer, bufLen); … … 165 168 if (_msg2021.valid()) { 166 169 decoded = true; 167 translateCorr2Obs(); 170 translateCorr2Obs(errmsg); 168 171 } 169 172 } … … 182 185 183 186 184 voidRTCM2Decoder::storeEph(const gpsephemeris& gpseph) {187 bool RTCM2Decoder::storeEph(const gpsephemeris& gpseph, string& storedPRN, vector<int>& IODs) { 185 188 t_ephGPS eph; eph.set(&gpseph); 186 189 187 storeEph(eph); 188 } 189 190 191 voidRTCM2Decoder::storeEph(const t_ephGPS& gpseph) {190 return storeEph(eph, storedPRN, IODs); 191 } 192 193 194 bool RTCM2Decoder::storeEph(const t_ephGPS& gpseph, string& storedPRN, vector<int>& IODs) { 192 195 t_ephGPS* eph = new t_ephGPS(gpseph); 193 196 194 197 string prn = eph->prn(); 195 198 196 t_ pairMap::iterator ip = _ephPair.find(prn);197 if (ip == _eph Pair.end() ) {198 ip = _eph Pair.insert(pair<string, t_ephPair*>(prn, new t_ephPair)).first;199 } 200 t_eph Pair* pair= ip->second;201 202 if ( !pair->eph || eph->isNewerThan(pair->eph) ) {203 delete pair->oldEph; 204 pair->oldEph = pair->eph;205 pair->eph = eph;206 207 return; 199 t_listMap::iterator ip = _ephList.find(prn); 200 if (ip == _ephList.end() ) { 201 ip = _ephList.insert(pair<string, t_ephList*>(prn, new t_ephList)).first; 202 } 203 t_ephList* ephList = ip->second; 204 205 bool stored = ephList->store(eph); 206 207 if ( stored ) { 208 storedPRN = eph->prn(); 209 ephList->getIODs(IODs); 210 return true; 208 211 } 209 212 210 213 delete eph; 214 215 return false; 211 216 } 212 217 213 218 214 void RTCM2Decoder::translateCorr2Obs() { 219 void RTCM2Decoder::translateCorr2Obs(vector<string>& errmsg) { 215 220 216 221 if ( !_msg03.validMsg || !_msg2021.valid() ) { … … 248 253 const RTCM2_2021::HiResCorr* corr = icorr->second; 249 254 255 // beg test 256 if ( corr->PRN >= 200 ) { 257 continue; 258 } 259 // end test 260 261 250 262 ostringstream oPRN; oPRN.fill('0'); 251 263 … … 255 267 string PRN(oPRN.str()); 256 268 257 t_pairMap::const_iterator ieph = _ephPair.find(PRN); 258 const t_eph* eph0 = 0; 259 const t_eph* eph1 = 0; 260 261 if ( ieph != _ephPair.end() ) { 262 eph0 = ieph->second->eph; 263 eph1 = ieph->second->oldEph; 264 } 265 266 if ( !eph0 && !eph1 ) { 269 t_listMap::const_iterator ieph = _ephList.find(PRN); 270 271 if ( ieph == _ephList.end() ) { 272 errmsg.push_back("missing eph for " + PRN); 267 273 continue; 268 274 } … … 277 283 p_obs new_obs = 0; 278 284 285 // missing IOD 286 vector<string> missingIOD; 287 vector<string> hasIOD; 279 288 for (unsigned ii = 0; ii < 4; ii++) { 280 289 int IODcorr = 0; … … 312 321 } 313 322 314 eph = 0; 315 if ( eph0 && eph0->IOD() == IODcorr ) 316 eph = eph0; 317 else if ( eph1 && eph1->IOD() == IODcorr ) 318 eph = eph1; 319 if ( eph && corr ) { 323 eph = ieph->second->getEph(IODcorr); 324 325 if ( eph ) { 326 ostringstream msg; 327 msg << obsT << ':' << setw(3) << eph->IOD(); 328 hasIOD.push_back(msg.str()); 329 330 320 331 int GPSWeek_tot; 321 332 double GPSWeeks_tot; … … 372 383 } 373 384 } 385 else if ( IODcorr != 0 ) { 386 ostringstream msg; 387 msg << obsT << ':' << setw(3) << IODcorr; 388 missingIOD.push_back(msg.str()); 389 } 374 390 } // loop over frequencies 375 391 392 // Error report 393 if ( missingIOD.size() ) { 394 ostringstream missingIODstr; 395 396 copy(missingIOD.begin(), missingIOD.end(), ostream_iterator<string>(missingIODstr, " ")); 397 398 errmsg.push_back("missing eph for " + PRN + " , IODs " + missingIODstr.str()); 399 } 400 401 // Store new observation 376 402 if ( new_obs ) { 377 403 _obsList.push_back( new_obs ); 378 } 379 } 380 } 404 405 ///ostringstream hasIODstr; 406 ///copy(hasIOD.begin(), hasIOD.end(), ostream_iterator<string>(hasIODstr, " ")); 407 ///errmsg.push_back("decoded PRN " + PRN + " : " + hasIODstr.str()); 408 } 409 } 410 } -
trunk/BNC/RTCM/RTCM2Decoder.h
r1167 r1218 27 27 28 28 #include <map> 29 #include <vector> 30 #include <list> 29 31 30 32 #include "GPSDecoder.h" … … 39 41 RTCM2Decoder(const std::string& ID); 40 42 virtual ~RTCM2Decoder(); 41 virtual t_irc Decode(char* buffer, int bufLen); 43 virtual t_irc Decode(char* buffer, int bufLen, std::vector<std::string>& errmsg); 42 44 43 voidstoreEph(const gpsephemeris& gpseph);44 voidstoreEph(const t_ephGPS& gpseph);45 bool storeEph(const gpsephemeris& gpseph, std::string& storedPRN, std::vector<int>& IODs); 46 bool storeEph(const t_ephGPS& gpseph, std::string& storedPRN, std::vector<int>& IODs); 45 47 46 48 t_irc getStaCrd(double& xx, double& yy, double& zz); 47 49 48 t_irc getStaCrd(double& xx, double& yy, double& zz, 50 t_irc getStaCrd(double& xx, double& yy, double& zz, 49 51 double& dx1, double& dy1, double& dz1, 50 52 double& dx2, double& dy2, double& dz2); … … 56 58 private: 57 59 58 class t_eph Pair{60 class t_ephList { 59 61 public: 60 t_ephPair() { 61 eph = 0; 62 oldEph = 0; 62 t_ephList() {} 63 64 ~t_ephList() { 65 for (std::list<t_eph*>::iterator ii = _eph.begin(); ii != _eph.end(); ii++) { 66 delete (*ii); 67 } 68 } 69 70 bool store(t_eph* eph) { 71 if ( _eph.size() == 0 ) { 72 _eph.push_back(eph); 73 return true; 74 } 75 76 std::list<t_eph*>::iterator ii = _eph.begin(); 77 while (ii != _eph.end()) { 78 if ( eph->IOD() == (*ii)->IOD() ) { 79 return false; 80 } 81 if ( ! eph->isNewerThan(*ii) ) { 82 break; 83 } 84 ++ii; 85 } 86 87 if ( ii == _eph.begin() && _eph.size() == MAXSIZE) { 88 return false; 89 } 90 91 _eph.insert(ii, eph); 92 93 while ( _eph.size() > MAXSIZE ) { 94 delete _eph.front(); 95 _eph.pop_front(); 96 } 97 98 return true; 63 99 } 64 100 65 ~t_ephPair() { 66 delete eph; 67 delete oldEph; 101 const t_eph* getEph(int IOD) const { 102 for (std::list<t_eph*>::const_iterator ii = _eph.begin(); ii != _eph.end(); ii++) { 103 if ( (*ii)->IOD() == IOD ) { 104 return (*ii); 105 } 106 } 107 return 0; 68 108 } 69 70 t_eph* eph; 71 t_eph* oldEph; 109 110 void getIODs(std::vector<int>& IODs) const { 111 IODs.clear(); 112 for (std::list<t_eph*>::const_iterator ii = _eph.begin(); ii != _eph.end(); ii++) { 113 IODs.push_back((*ii)->IOD()); 114 } 115 } 116 117 static const unsigned MAXSIZE = 3; 118 119 std::list<t_eph*> _eph; 72 120 }; 73 121 74 void translateCorr2Obs(); 122 void translateCorr2Obs(std::vector<std::string>& errmsg); 75 123 76 124 std::string _ID; … … 86 134 rtcm2::RTCM2_22 _msg22; 87 135 rtcm2::RTCM2_2021 _msg2021; 88 std::map<std::string, t_eph Pair*> _ephPair;136 std::map<std::string, t_ephList*> _ephList; 89 137 90 typedef std::map<std::string, t_eph Pair*> t_pairMap;138 typedef std::map<std::string, t_ephList*> t_listMap; 91 139 }; 92 140
Note:
See TracChangeset
for help on using the changeset viewer.