petest.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: petest.cpp 1895 2009-05-12 19:34:29Z afarris $"
00002 
00003 //============================================================================
00004 //
00005 //  This file is part of GPSTk, the GPS Toolkit.
00006 //
00007 //  The GPSTk is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU Lesser General Public License as published
00009 //  by the Free Software Foundation; either version 2.1 of the License, or
00010 //  any later version.
00011 //
00012 //  The GPSTk is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU Lesser General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU Lesser General Public
00018 //  License along with GPSTk; if not, write to the Free Software Foundation,
00019 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 //  Copyright 2009, The University of Texas at Austin
00022 //
00023 //============================================================================
00024 
00025 #include <iostream>
00026 #include <iomanip>
00027 #include <string>
00028 #include <map>
00029 
00030 #include "DayTime.hpp"
00031 #include "SP3Stream.hpp"
00032 #include "SP3Data.hpp"
00033 #include "SP3Header.hpp"
00034 #include "SP3EphemerisStore.hpp"
00035 #include "SatID.hpp"
00036 
00042 using namespace std;
00043 using namespace gpstk;
00044 
00045 int main(int argc, char *argv[])
00046 {
00047    if (argc<2) {
00048       cout << "Usage: petest <SP3-format files ...>\n";
00049       return -1;
00050    }
00051 
00052    try
00053    {
00054 
00055       bool firstEpochFound=true;
00056       DayTime firstTime;
00057       DayTime lastTime;
00058       SatID firstSat;
00059          
00060       int i,ip,it,nf=0,np=0,nt=0;
00061       SP3EphemerisStore EphList;
00062       for(i=1; i<argc; i++) {
00063          SP3Header header;
00064          SP3Data data;
00065          
00066          // you can't open, close, and reopen a file w/o abort on second open...
00067          SP3Stream pefile;
00068          pefile.exceptions(ifstream::failbit);
00069          cout << "Reading SP3 file " << argv[i] << "." << endl;
00070          pefile.open(argv[i],ios::in);
00071 
00072          pefile >> header;
00073          data.version = header.version;
00074          
00075          //cout << "Dump header:\n";
00076          //header.dump(cout);
00077          //cout << endl;
00078 
00079          ip = it = 0;
00080          DayTime t(DayTime::BEGINNING_OF_TIME);
00081 
00082          while(pefile >> data) {
00083             if (firstEpochFound)
00084             {  
00085                firstSat = data.sat;
00086                firstTime = data.time;
00087                lastTime = firstTime;
00088                
00089                firstEpochFound=false;
00090             }
00091 
00092             if (data.time > lastTime) lastTime = data.time;
00093             
00094             if(data.time > t) {
00095                //cout << "Epoch " << data.time << endl;
00096                t = data.time;
00097                it++; nt++;
00098             }
00099             //data.dump(cout);
00100             ip++; np++;
00101          }
00102          cout << "\nDone with file " << argv[i] << ": read "
00103               << ip << " P/V records and " << it << " epochs." << endl;
00104          pefile.close();
00105          nf++;
00106 
00107          // add to store
00108          EphList.loadFile(string(argv[i]));
00109       }
00110       
00111       cout << "\nDone with " << nf << " files: read "
00112            << np << " P/V records and " << nt << " epochs." << endl;
00113 
00114       //EphList.dump(2);
00115 
00116       unsigned long ref;
00117       // choose a time tag within the data....
00118       DayTime tt = firstTime + (lastTime-firstTime)/2.;
00119       SatID tsat = firstSat;
00120       Xvt PVT;
00121       for(i=0; i<300; i++) {
00122          tt += 30.0;
00123          PVT = EphList.getXvt(tsat,tt);
00124 
00125          if (true) 
00126             cout << "LI " << tt << " P " << fixed
00127                  << setw(13) << setprecision(6) << PVT.x[0] << " "
00128                  << setw(13) << setprecision(6) << PVT.x[1] << " "
00129                  << setw(13) << setprecision(6) << PVT.x[2] << " "
00130                  << setw(13) << setprecision(6) << PVT.dtime
00131                  << " V "
00132                  << setw(13) << setprecision(6) << PVT.v[0] << " "
00133                  << setw(13) << setprecision(6) << PVT.v[1] << " "
00134                  << setw(13) << setprecision(6) << PVT.v[2] << " "
00135                  << setw(13) << setprecision(6) << PVT.ddtime
00136                  << endl;
00137       }
00138       
00139    }
00140    catch (Exception& e)
00141    {
00142       cout << e;
00143       exit(-1);
00144    }
00145    catch (...)
00146    {
00147       cout << "Caught an unknown exception" << endl;
00148       exit(-1);
00149    }
00150 
00151    return 0;
00152 }

Generated on Wed Feb 8 03:31:01 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1