⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rinexeditor.cpp

📁 GPS数据预处理软件
💻 CPP
📖 第 1 页 / 共 4 页
字号:
               Cmds[i].type = REditCmd::INVALID;            }            break;         default: break;      }   }      // require an input file name   if(Inputfiles.size() == 0) iret -= 1;      // sort on begin time (header) and add path   else {      if(Inputfiles.size() > 1)         sortRinexObsFiles(Inputfiles);      if(!InputDir.empty()) {         for(i=0; i<Inputfiles.size(); i++) {            InputFile = InputDir + string("/") + Inputfiles[i];            Inputfiles[i] = InputFile;         }      }   }         // now iterate over the list in reverse, deleting INVALID commands.   deque<REditCmd>::iterator jt,it=Cmds.begin();   while(it != Cmds.end()) {      if(it->type == REditCmd::INVALID) {         //if(REDebug) it->Dump(*oflog,string("Erase this INVALID command:"));         it = Cmds.erase(it);      }      else it++;   }      // sort on time   sort(Cmds.begin(),Cmds.end(),REditCmdLessThan());      // iterate over the command list, make sure first OF command has no time tag   it = Cmds.begin();   if(OutputFile.empty()) {      while(it != Cmds.end()) {         if(it->type==REditCmd::OF) {            if(OutputFile.empty()) {               OutputFile = it->field;            //if(REDebug) it->Dump(*oflog,string("Let this command set begin time"));               BegTime = it->time;               it->time = DayTime::BEGINNING_OF_TIME;            }         }         else { IVLast=true; break; }         it++;      }   }   if(OutputFile.empty()) {   // error      iret -= 2;   }   else if(!OutputDir.empty()) OutputFile = OutputDir + string("/") + OutputFile;   if(iret) return iret;      // iterate again, ensure that - commands have corresponding +   deque<REditCmd> newCmds;   it = Cmds.begin();   while(it != Cmds.end()) {      if(it->sign == -1) {         if(REDebug) it->Dump(*oflog,string("This one needs a +"));         flag=false;         if(it != Cmds.begin()) {            jt = it;            bool last=((--jt)==Cmds.begin());            while(1) {               if(jt->type==it->type && jt->SV==it->SV && jt->field==it->field) {                  if(REDebug) jt->Dump(*oflog,string("Is this the one ?"));                  flag = true;                  break;               }               if(last) break;               last = (--jt==Cmds.begin());            }         }         if(!flag) {            REditCmd re(*it);            re.sign = 1;            re.time = BegTime;            newCmds.push_back(re);            if(REDebug) re.Dump(*oflog,string("Add this new command:"));         }      }      it++;   }      // add new commands and sort again   it = newCmds.begin();   while(it != newCmds.end()) {      if(REDebug) it->Dump(*oflog,string("this is a new command:"));      Cmds.push_back(*it);      it++;   }   sort(Cmds.begin(),Cmds.end(),REditCmdLessThan());   if(REDebug)      for(it=Cmds.begin(); it != Cmds.end(); it++)         it->Dump(*oflog,string("final"));      // have to set the IVTable flag...   if(!IVTable) for(it=Cmds.begin(); it != Cmds.end(); it++) {      if(it->type==REditCmd::DS || it->type==REditCmd::DA || it->type==REditCmd::DS ||         it->type==REditCmd::DO || it->type==REditCmd::AO || it->type==REditCmd::DD)            { IVTable = true; break; }   }   return 0;}catch(Exception& e) { GPSTK_RETHROW(e); }catch(exception& e) { Exception E("std except: "+string(e.what())); GPSTK_THROW(E); }catch(...) { Exception e("Unknown exception"); GPSTK_THROW(e); }}//------------------------------------------------------------------------------------// leading -'s are okvoid RinexEditor::AddCommand(string cmd) throw(Exception){try {   REditCmd r(cmd,oflog);   if(r.valid()) Cmds.push_back(r);}catch(Exception& e) { GPSTK_RETHROW(e); }catch(exception& e) { Exception E("std except: "+string(e.what())); GPSTK_THROW(E); }catch(...) { Exception e("Unknown exception"); GPSTK_THROW(e); }}//------------------------------------------------------------------------------------// Adds valid commands to C and removes from args; leading -'s are okvoid RinexEditor::AddCommandLine(vector<string>& args) throw(Exception){try {   if(args.size()==0) return;   //if(REDebug) *oflog << "\nBefore stripping RE cmds, there are (" << args.size()   //<< ") tokens." << endl;   // ver 3.3 preprocess args to allow new-style input, e.g. --IF <file>   // e.g. --HD f; --HDp <program> or --HD p<program>; --DS +...; or --DS+ ...   static vector<string> CommandLineLabels;   if(CommandLineLabels.size() == 0) {      for(map<REditCmd::TYPE,string>::iterator jt=REditCmd::typeLabel.begin();         jt!=REditCmd::typeLabel.end();         jt++)            CommandLineLabels.push_back("--" + jt->second);      CommandLineLabels.push_back("--HDp");      CommandLineLabels.push_back("--HDr");      CommandLineLabels.push_back("--HDo");      CommandLineLabels.push_back("--HDa");      CommandLineLabels.push_back("--HDx");      CommandLineLabels.push_back("--HDm");      CommandLineLabels.push_back("--HDn");      CommandLineLabels.push_back("--HDc");      CommandLineLabels.push_back("--DA+");      CommandLineLabels.push_back("--DA-");      CommandLineLabels.push_back("--DS+");      CommandLineLabels.push_back("--DS-");      CommandLineLabels.push_back("--DD+");      CommandLineLabels.push_back("--DD-");      CommandLineLabels.push_back("--SL+");      CommandLineLabels.push_back("--SL-");      CommandLineLabels.push_back("--BD+");      CommandLineLabels.push_back("--BD-");   }   vector<string>::iterator it=args.begin();   while(it != args.end()) {      string str(*it);      if(str == string("--HDf")) *it = "-HDf";      else if(str == string("--HDdc")) *it = "-HDdc";      else if(str == string("--BZ")) *it = "-BZ";      else if(index(CommandLineLabels,str) != -1) {         it = args.erase(it);         if(it == args.end()) break;         str.erase(0,1);         str += *it;         *it = str;      }      it++;   }   // process args   it = args.begin();   while(it != args.end()) {      REditCmd r(*it,oflog);      if(r.valid()) {         Cmds.push_back(r); //if(REDebug) *oflog << "Erase command " << *it << endl;         it = args.erase(it);      }      else {         //if(REDebug) *oflog << "Its not an RE command: " << *it << endl;         it++;      }   }   //if(REDebug) *oflog << "\nAfter stripping RE cmds, tokens (" << args.size()   //<< ") are:" << endl;   //if(REDebug) for(unsigned int j=0; j<args.size(); j++) *oflog << args[j] << endl;   //if(REDebug) *oflog << "End of RE cmds, tokens" << endl;}catch(Exception& e) { GPSTK_RETHROW(e); }catch(exception& e) { Exception E("std except: "+string(e.what())); GPSTK_THROW(E); }catch(...) { Exception e("Unknown exception"); GPSTK_THROW(e); }}//------------------------------------------------------------------------------------// NB does not fill optional records, even when -HDf (EditObs will).int RinexEditor::EditHeader(RinexObsHeader& RHInput, RinexObsHeader& RHOutput)   throw(Exception){try {      // save the input header   RHIn = RHOutput = RHInput;      // get the obstypes   ObsTypes = RHInput.obsTypeList;      // iterate over the list (in reverse), applying, then deleting, AO, DO      // and DS<SV> commands   deque<REditCmd>::iterator it=Cmds.begin();   while(it != Cmds.end()) {      if(it->type==REditCmd::AO || it->type==REditCmd::DO) {         //if(REDebug) it->Dump(*oflog,string("Apply and Erase this AO/DO command:"));         RinexObsHeader::RinexObsType rot=RinexObsHeader::convertObsType(it->field);         vector<RinexObsHeader::RinexObsType>::iterator jt;         jt = find(ObsTypes.begin(),ObsTypes.end(),rot);         if(jt != ObsTypes.end() && it->type==REditCmd::DO) {            ObsTypes.erase(jt);         }         if(jt == ObsTypes.end() && it->type==REditCmd::AO) {            ObsTypes.push_back(rot);         }         it = Cmds.erase(it);      }      else if(it->type==REditCmd::DS            && it->time==DayTime::BEGINNING_OF_TIME) {         //if(REDebug) it->Dump(*oflog,string("Apply and Erase this DS command:"));         if(index(DelSV,it->SV) == -1) DelSV.push_back(it->SV);         it = Cmds.erase(it);      }      else it++;   }   RHOutput.obsTypeList = ObsTypes;      // fill records in output header   DayTime currtime;   time_t timer;   struct tm *tblock;   timer = time(NULL);   tblock = localtime(&timer);   currtime.setYMDHMS(1900+tblock->tm_year,1+tblock->tm_mon,      tblock->tm_mday,tblock->tm_hour,tblock->tm_min,tblock->tm_sec);   RHOutput.date = currtime.printf("%04Y/%02m/%02d %02H:%02M:%02S");   { // figure out system -- anything else will be up to caller      bool gps=true,glo=true,tra=true,geo=true;      if(find(DelSV.begin(),DelSV.end(),RinexSatID(-1,SatID::systemGPS))                  != DelSV.end()) gps=false;      if(find(DelSV.begin(),DelSV.end(),RinexSatID(-1,SatID::systemGlonass))                  != DelSV.end()) glo=false;      if(find(DelSV.begin(),DelSV.end(),RinexSatID(-1,SatID::systemTransit))                  != DelSV.end()) tra=false;      if(find(DelSV.begin(),DelSV.end(),RinexSatID(-1,SatID::systemGeosync))                  != DelSV.end()) geo=false;      if(!glo && !tra && !geo) RHOutput.system.system = RinexSatID::systemGPS;      if(!gps && !tra && !geo) RHOutput.system.system = RinexSatID::systemGlonass;      if(!gps && !glo && !geo) RHOutput.system.system = RinexSatID::systemTransit;      if(!gps && !glo && !tra) RHOutput.system.system = RinexSatID::systemGeosync;   }   if(HDDeleteOldComments) {      RHOutput.commentList.clear();      RHOutput.valid ^= RinexObsHeader::commentValid;   }   if(!HDProgram.empty()) RHOutput.fileProgram = HDProgram;   if(!HDPosition.empty() && numWords(HDPosition,';') >= 3) {      double x = asDouble(stripFirstWord(HDPosition,';'));      double y = asDouble(stripFirstWord(HDPosition,';'));      double z = asDouble(stripFirstWord(HDPosition,';'));      RHOutput.antennaPosition = Triple(x,y,z);   }   if(!HDRunBy.empty()) RHOutput.fileAgency = HDRunBy;   if(!HDObserver.empty()) RHOutput.observer = HDObserver;   if(!HDAgency.empty()) RHOutput.agency = HDAgency;   if(!HDMarker.empty()) RHOutput.markerName = HDMarker;   if(!HDNumber.empty()) {      RHOutput.markerNumber = HDNumber;      RHOutput.valid |= RinexObsHeader::markerNumberValid;   }   if(HDComments.size()) RHOutput.commentList.insert(RHOutput.commentList.end(),      HDComments.begin(),HDComments.end());   RHOutput.commentList.push_back(string("Edited by GPSTK Rinex Editor ver ") +      RinexEditVersion+string(" on ") + RHOutput.date);   RHOutput.valid |= RinexObsHeader::commentValid;      // invalidate header records   if(IVTable && (RHOutput.valid & RinexObsHeader::numSatsValid))      RHOutput.valid ^= RinexObsHeader::numSatsValid;   if(IVTable && (RHOutput.valid & RinexObsHeader::prnObsValid))      RHOutput.valid ^= RinexObsHeader::prnObsValid;   if(IVLast && (RHOutput.valid & RinexObsHeader::lastTimeValid))      RHOutput.valid ^= RinexObsHeader::lastTimeValid;   if(IVInterval && (RHOutput.valid & RinexObsHeader::intervalValid))      RHOutput.valid ^= RinexObsHeader::intervalValid;   RHOut = RHOutput;  // save this header; if(FillOptionalHeader) mod RHOut in EditObs   return 0;}catch(Exception& e) { GPSTK_RETHROW(e); }catch(exception& e) { Exception E("std except: "+string(e.what())); GPSTK_THROW(E); }catch(...) { Exception e("Unknown exception"); GPSTK_THROW(e); }}//------------------------------------------------------------------------------------// will fill header (after writing) when -HDf found.// Return -2 error//        -1 time limit exceeded//         0 DO NOT write the output obs ROOut//         1 DO NOT write the output obs ROOut, but close and re-open the output file//         2 DO write the output obs ROOut//         3 DO write the output obs ROOut, but first close and re-open output fileint RinexEditor::EditObs(RinexObsData& ROIn, RinexObsData& ROOut) throw(Exception){try {      // check that stored input header is valid...but do only once!   //if(!RHIn.valid() || !RHOut.valid()) return -2;   bool NewFile=false;      // test time limits      // TD some comment blocks have blank epochs...   if(ROIn.time-BegTime < -TimeTol) return 0;   if(ROIn.time-EndTime >  TimeTol) return -1;      // when embedded comments found, just copy and go on   if(ROIn.epochFlag != 0 && ROIn.epochFlag != 1) {      ROOut = ROIn;      return 2;   }      // decimate the data   if(Decimate > 0.0) {         // if BegTime is unset, make it the first of the week      if(BegTime == DayTime::BEGINNING_OF_TIME)         BegTime.setGPSfullweek(ROIn.time.GPSfullweek(),0.0);      double dt=fabs(ROIn.time - BegTime);      dt -= Decimate*long(0.5+dt/Decimate);      if(fabs(dt) > TimeTol) return 0;   }      // scan command list, updating current, onetime command lists,      // delete-SV list, Skip, NewFile      // delete the command after processing it   double dt;   while(Cmds.size() > 0) {      dt = Cmds[0].time - ROIn.time;      if(dt < -TimeTol || fabs(dt) < TimeTol) {  // commands in present and past         if(REDebug) Cmds[0].Dump(*oflog,               Cmds[0].time.printf("%4Y/%2m/%2d %2H:%2M:%.4f")               + string(": Process (now) : "));         switch(Cmds[0].type) {            case REditCmd::DA:               if(Cmds[0].sign > 0) Skip=true;               if(Cmds[0].sign < 0) Skip=false;               break;            case REditCmd::OF:               OutputFile = Cmds[0].field;               if(!OutputDir.empty()) OutputFile = OutputDir + string("/")                  + OutputFile;               NewFile = true;               break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -