00001 #pragma ident "$Id: petest.cpp 1895 2009-05-12 19:34:29Z afarris $"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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
00076
00077
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
00096 t = data.time;
00097 it++; nt++;
00098 }
00099
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
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
00115
00116 unsigned long ref;
00117
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 }