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

📄 timetable.cpp

📁 gpstk1.5的有关内容 对于刚刚接触gps有一定的帮助 很有用的啊
💻 CPP
📖 第 1 页 / 共 3 页
字号:
#pragma ident "$Id: Timetable.cpp 286 2006-11-08 02:21:51Z ocibu $"//============================================================================////  This file is part of GPSTk, the GPS Toolkit.////  The GPSTk is free software; you can redistribute it and/or modify//  it under the terms of the GNU Lesser General Public License as published//  by the Free Software Foundation; either version 2.1 of the License, or//  any later version.////  The GPSTk is distributed in the hope that it will be useful,//  but WITHOUT ANY WARRANTY; without even the implied warranty of//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//  GNU Lesser General Public License for more details.////  You should have received a copy of the GNU Lesser General Public//  License along with GPSTk; if not, write to the Free Software Foundation,//  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA//  //  Copyright 2004, The University of Texas at Austin////============================================================================//============================================================================////This software developed by Applied Research Laboratories at the University of//Texas at Austin, under contract to an agency or agencies within the U.S. //Department of Defense. The U.S. Government retains all rights to use,//duplicate, distribute, disclose, or release this software. ////Pursuant to DoD Directive 523024 //// DISTRIBUTION STATEMENT A: This software has been approved for public //                           release, distribution is unlimited.////=============================================================================/** * @file Timetable.cpp * Compute reference satellites time table for program DDBase. *///------------------------------------------------------------------------------------// TD Timetable.cpp  handle week rollover in TimeTable() and ReadTimeTable()// TD Timetable.cpp  check logic// TD Timetable.cpp  check output messages// TD Timetable.cpp  add several limits as input parameters// TD Timetable.cpp  4. edit TTab, removing segments that do not create gaps//------------------------------------------------------------------------------------// includes// system// GPSTk// Geomatics#include "DDid.hpp"#include "index.hpp"// DDBase#include "DDBase.hpp"//------------------------------------------------------------------------------------double RotatedAntennaElevation(double elevation, double azimuth); // ElevationMask.cpp//------------------------------------------------------------------------------------using namespace std;using namespace gpstk;//------------------------------------------------------------------------------------// Segment structure used in deducing time table// functions implemented in Timetable.cppclass TTSegment {public:   std::string site1,site2;   gpstk::GSatID sat;   int start,end;    // starting and ending counts   int first,last;   // counts to actually use in timetable   int length;       // length (in data points)   double minelev;   // minimum elevation in this segment   double maxelev;   // maximum elevation in this segment   TTSegment(void) : start(-1),length(0),minelev(0.0),maxelev(0.0) {}   double metric(void) const   { return (double(length)/100.0 + 100.0*(minelev+maxelev)/90.0); }   //bool operator<(const TTSegment& right) const   //{ return (metric() < right.metric()); }   //bool operator>(const TTSegment& right) const   //{ return (metric() > right.metric()); }   void findElev(void);   friend ostream& operator<<(ostream& s, const TTSegment& t);   friend bool increasingMetricSort(const TTSegment& left, const TTSegment& right);   friend bool decreasingMetricSort(const TTSegment& left, const TTSegment& right);   friend bool startSort(const TTSegment& left, const TTSegment& right);};//------------------------------------------------------------------------------------// local datalist<TTSegment> TimeTable;    // satellite time tablemap<SDid,SDData> SDmap;       // map of SD data - not full single differences//------------------------------------------------------------------------------------// prototypes -- this module onlyint ReadTimeTable(void);int ComputeBaselineTimeTable(const string& bl);int TTComputeSingleDifferences(const string& bl, const double ElevLimit);int TimeTableAlgorithm(list<TTSegment>& TTS, list<TTSegment>& TTab);bool startSort(const TTSegment& left, const TTSegment& right);bool increasingMetricSort(const TTSegment& left, const TTSegment& right);bool decreasingMetricSort(const TTSegment& left, const TTSegment& right);//------------------------------------------------------------------------------------// Find the entry in the timetable which applies to the baseline given in sdid and// the time tt. Set the satellite in sdid to the reference satellite, and set the// time tt to the time (in the future) when the reference will change again.// return 0 on success, 1 on failure.int QueryTimeTable(SDid& sdid, DayTime& tt){try {      // loop over the timetable, looking for a match : baseline and time   list<TTSegment>::iterator ttit;   for(ttit=TimeTable.begin(); ttit != TimeTable.end(); ttit++) {      if(((ttit->site1 == sdid.site1 && ttit->site2 == sdid.site2) ||          (ttit->site1 == sdid.site2 && ttit->site2 == sdid.site1)   ) &&         FirstEpoch+CI.DataInterval*ttit->first <= tt                  &&         FirstEpoch+CI.DataInterval*ttit->last  >= tt)      {                                                  // success         sdid.sat = ttit->sat;         tt = FirstEpoch+CI.DataInterval*ttit->last;         return 0;      }   }   return 1;      // failure}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); }}    //------------------------------------------------------------------------------------// Find the start and stop counts in the timetable which applies to the given baselineint QueryTimeTable(string baseline, int& beg, int& end){try {   string site1=StringUtils::word(baseline,0,'-');   string site2=StringUtils::word(baseline,1,'-');   beg = end = -1;      // loop over the timetable, looking for a match in baseline   list<TTSegment>::iterator ttit;   for(ttit=TimeTable.begin(); ttit != TimeTable.end(); ttit++) {      if((ttit->site1 == site1 && ttit->site2 == site2) ||         (ttit->site1 == site2 && ttit->site2 == site1)   )      {                                                  // success         if(beg == -1 || ttit->first < beg) beg = ttit->first;         if(end == -1 || ttit->last  > end) end = ttit->last;      }   }   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); }}//------------------------------------------------------------------------------------int Timetable(void){try {   if(CI.Verbose) oflog << "BEGIN Timetable()" << endl;   int ib,iret;   list<TTSegment>::iterator ttit;   if(CI.TimeTableFile.size() > 0) {      iret = ReadTimeTable();   }   else if(CI.RefSat.id != -1) {         // user says use this sat only      // loop over baselines      for(ib=0; ib<Baselines.size(); ib++) {         TTSegment ts;         ts.site1 = StringUtils::word(Baselines[ib],0,'-');         ts.site2 = StringUtils::word(Baselines[ib],1,'-');         ts.sat = CI.RefSat;         ts.start = ts.first = 0;         ts.end = ts.last = maxCount;         ts.minelev = ts.maxelev = 0.0;         ts.length = ts.end - ts.start + 1;         TimeTable.push_back(ts);         iret = 0;      }   }   else {      // loop over baselines      for(ib=0; ib<Baselines.size(); ib++) {         iret = ComputeBaselineTimeTable(Baselines[ib]);         if(iret) break;      }  // end loop over baselines   }   if(iret == 0) {      // write out timetable to log      // REF site site sat week use_first use_last data_start data_end      DayTime tt;      GSatID sat;      oflog << "Here is the time table (" << TimeTable.size() << ")" << endl;      if(CI.Screen)         cout << "Time table (" << TimeTable.size() << "):" << endl;      oflog << "# " << Title << endl;      oflog << "# REF site site sat week use_first use_last data_start data_end\n";      if(CI.Screen)         cout << "# REF site site sat week use_first use_last data_start data_end\n";      for(ttit=TimeTable.begin(); ttit != TimeTable.end(); ttit++) {         oflog << "REF " << ttit->site1 << " " << ttit->site2 << " " << ttit->sat;         if(CI.Screen)            cout << "REF " << ttit->site1 << " " << ttit->site2 << " " << ttit->sat;         tt = FirstEpoch + CI.DataInterval * ttit->first;         oflog << tt.printf(" %4F %10.3g");        // TD week rollover!         if(CI.Screen)            cout << tt.printf(" %4F %10.3g");        // TD week rollover!         tt = FirstEpoch + CI.DataInterval * ttit->last;         oflog << tt.printf(" %10.3g");         if(CI.Screen)            cout << tt.printf(" %10.3g");         tt = FirstEpoch + CI.DataInterval * ttit->start;         oflog << tt.printf(" %10.3g");         if(CI.Screen)            cout << tt.printf(" %10.3g");         tt = FirstEpoch + CI.DataInterval * ttit->end;         oflog << tt.printf(" %10.3g");         if(CI.Screen)            cout << tt.printf(" %10.3g");         // TD? ttit->minelev, ttit->maxelev, ttit->length, ttit->metric()         oflog << " " << fixed << setw(4) << setprecision(1) << ttit->minelev;         if(CI.Screen)            cout << " " << fixed << setw(4) << setprecision(1) << ttit->minelev;         oflog << " " << fixed << setw(4) << setprecision(1) << ttit->maxelev;         if(CI.Screen)            cout << " " << fixed << setw(4) << setprecision(1) << ttit->maxelev;         // write the number of counts for this ref         oflog << " " << setw(5) << ttit->length;         if(CI.Screen)            cout << " " << setw(5) << ttit->length;         oflog << endl;         if(CI.Screen)            cout << endl;         // for next time         sat = ttit->sat;      }      oflog << "End of time table." << endl;      if(CI.Screen)         cout << "End of time table." << endl;   }   return iret;   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); }}   // end Timetable()//------------------------------------------------------------------------------------// Input the time table from a fileint ReadTimeTable(void){try {   int week;   double sow;   string line;   DayTime tt;   // open an input file for all timetables   if(CI.Debug) oflog << "Try to open time table file " << CI.TimeTableFile << endl;   ifstream ttifs(CI.TimeTableFile.c_str());

⌨️ 快捷键说明

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