00001 #pragma ident "$Id: EphComp.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
00026
00027 #include <iostream>
00028 #include <iomanip>
00029 #include <string>
00030 #include <map>
00031
00032 #include "DayTime.hpp"
00033
00034 #include "RinexEphemerisStore.hpp"
00035 #include "SP3EphemerisStore.hpp"
00036
00037 #include "CommandOption.hpp"
00038 #include "CommandOptionParser.hpp"
00039
00044 using namespace std;
00045
00046 int main(int argc, char *argv[])
00047 {
00048 try
00049 {
00050 gpstk::CommandOptionNoArg
00051 helpOption('h', "help", "Print help usage");
00052 gpstk::CommandOptionWithNumberArg
00053 prnOption('s', "prn", "Which SV to compare");
00054 gpstk::CommandOptionWithAnyArg
00055 sp3Files('p', "precise", "SP3 file",true),
00056 bceFiles('b', "broadcast", "RINEX nav file",true);
00057
00058 string appDesc("Computes diferences between broadcast and precise ephemerides.");
00059 gpstk::CommandOptionParser cop(appDesc);
00060 cop.parseOptions(argc, argv);
00061
00062 if (helpOption.getCount() || cop.hasErrors())
00063 {
00064 if (cop.hasErrors())
00065 cop.dumpErrors(cout);
00066 cop.displayUsage(cout);
00067 exit(0);
00068 }
00069
00070
00071 gpstk::SP3EphemerisStore SP3EphList;
00072 SP3EphList.loadFiles(sp3Files.getValue());
00073
00074
00075 gpstk::RinexEphemerisStore BCEphList;
00076 BCEphList.loadFiles(bceFiles.getValue());
00077
00078 int prn=13;
00079 if (prnOption.getCount())
00080 prn = gpstk::StringUtils::asInt((prnOption.getValue())[0]);
00081
00082
00083 gpstk::DayTime te(BCEphList.getFinalTime());
00084 gpstk::DayTime t(BCEphList.getInitialTime());
00085
00086 gpstk::Xvt SP3PVT,BCPVT;
00087 while (t < te)
00088 {
00089 t += 15.0;
00090 try
00091 {
00092
00093 SP3PVT = SP3EphList.getPrnXvt(prn,t);
00094 BCPVT = BCEphList.getPrnXvt(prn,t);
00095 cout << fixed << t
00096 << " " << setw(2) << prn
00097 << setprecision(6)
00098 << " " << setw(13) << BCPVT.x[0]-SP3PVT.x[0]
00099 << " " << setw(13) << BCPVT.x[1]-SP3PVT.x[1]
00100 << " " << setw(13) << BCPVT.x[2]-SP3PVT.x[2]
00101 << scientific
00102 << " " << setw(13) << BCPVT.dtime-SP3PVT.dtime
00103 << fixed
00104 << " " << setw(13) << BCPVT.v[0]-SP3PVT.v[0]
00105 << " " << setw(13) << BCPVT.v[1]-SP3PVT.v[1]
00106 << " " << setw(13) << BCPVT.v[2]-SP3PVT.v[2]
00107 << scientific
00108 << " " << setw(13) << BCPVT.ddtime-SP3PVT.ddtime
00109 << endl;
00110 }
00111 catch (gpstk::EphemerisStore::NoEphemerisFound& e)
00112 {
00113 cerr << t << " " << e << endl;
00114 continue;
00115 }
00116
00117 }
00118 }
00119 catch (gpstk::Exception& e)
00120 {
00121 cout << e;
00122 exit(-1);
00123 }
00124 catch (...)
00125 {
00126 cout << "Caught an unknown exception" << endl;
00127 exit(-1);
00128 }
00129
00130 return 0;
00131 }