00001 #pragma ident "$Id: FileSpecTest.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 <cstdio>
00027
00028 #include "FileSpec.hpp"
00029 #include "FileHunter.hpp"
00030 #include "DayTime.hpp"
00031
00037 using namespace std;
00038
00039 main()
00040 {
00041 try
00042 {
00043 cout << "Please make sure you've run genFileSpecTestDirs.pl before beginning." << endl;
00044 cout << "push enter to continue" << endl;
00045 getchar();
00046
00047 int i;
00048 #ifndef _WIN32
00049 gpstk::FileHunter moo("fstest/ADMS%3n/RINEXOBS/S%2n%t%03jA.%02yO");
00050 #else
00051 gpstk::FileHunter moo("fstest\\ADMS%3n\\RINEXOBS\\S%2n%t%03jA.%02yO");
00052 #endif
00053 moo.dump(cout);
00054
00055 gpstk::DayTime start = gpstk::DayTime(2001, 51, (double)0);
00056 gpstk::DayTime end = gpstk::DayTime(2001, 53, (double)0);
00057 cout << "All files should be between " << start << " and " << end << " ascending. " << endl;
00058 vector<string> vs = moo.find(start,
00059 end,
00060 gpstk::FileSpec::ascending);
00061 for(i = 0; i < vs.size(); i++)
00062 {
00063 cout << "search1 " << vs[i] << endl;
00064 }
00065
00066 cout << endl;
00067 cout << "All files should be between " << start << " and " << end << " descending. " << endl;
00068 vs = moo.find(start,
00069 end,
00070 gpstk::FileSpec::descending);
00071 for(i = 0; i < vs.size(); i++)
00072 {
00073 cout << "2 " << vs[i] << endl;
00074 }
00075
00076 cout << endl;
00077 cout << "All files ascending order" << endl;
00078 vs = moo.find(gpstk::DayTime::BEGINNING_OF_TIME,
00079 gpstk::DayTime::END_OF_TIME,
00080 gpstk::FileSpec::ascending);
00081 for(i = 0; i < vs.size(); i++)
00082 {
00083 cout << "search3 " << vs[i] << endl;
00084 }
00085
00086 cout << endl;
00087 vector<string> stationFilter;
00088 stationFilter.push_back("85402");
00089 moo.setFilter(gpstk::FileSpec::station, stationFilter);
00090 cout << "All files from 85402 descending order" << endl;
00091 vs = moo.find(gpstk::DayTime::BEGINNING_OF_TIME,
00092 gpstk::DayTime::END_OF_TIME,
00093 gpstk::FileSpec::descending);
00094 for(i = 0; i < vs.size(); i++)
00095 {
00096 cout << "search4 " << vs[i] << endl;
00097 }
00098
00099
00100 cout << " version search shoudl return the highest number " << endl;
00101 moo.newHunt("%1v");
00102 moo.dump(cout);
00103 vs = moo.find();
00104 for(i = 0; i < vs.size(); i++)
00105 {
00106 cout << "version search " << vs[i] << endl;
00107 }
00108 cout << endl;
00109 }
00110 catch (gpstk::Exception& e)
00111 {
00112 cout << e << endl;
00113 return -1;
00114 }
00115
00116
00117
00118
00119 cout << "testing FileSpec extraction functions" << endl;
00120 gpstk::FileSpec boo("ADMS%3n/RINEXOBS/S%2n%t%03jA.%02yO");
00121 boo.dump(cout);
00122 gpstk::DayTime now;
00123 gpstk::FileSpec::FSTStringMap fstsMap;
00124 fstsMap[gpstk::FileSpec::station] = string("85408");
00125 fstsMap[gpstk::FileSpec::selected] = string("1");
00126 string filename = boo.toString(now, fstsMap);
00127 cout << filename << endl;
00128 cout << "station " << boo.extractField(filename, gpstk::FileSpec::station) << endl;
00129 cout << "daytime " << boo.extractDayTime(filename) << endl;
00130
00131 boo.newSpec("ADMS402/RINEXOBS/S%2n%t%03jA.%02yO");
00132 boo.dump(cout);
00133
00134 return 0;
00135
00136 }