SeismicStationList.cpp

Go to the documentation of this file.
00001 #include "SeismicStationList.h"
00002 #include "StationLexer.hpp"
00003 #include "StationParser.hpp"
00004 #include <fstream>
00005 using namespace std;
00006 using namespace antlr;
00007 SeismicStationList::SeismicStationList()
00008 {
00009 }
00010 
00011 SeismicStationList::~SeismicStationList()
00012 {
00013 }
00014 
00015 void SeismicStationList::GetData(const std::string filename)
00016 {
00017                 ifstream infile(filename.c_str());
00018         
00019 
00020         if (infile)
00021         {
00022                 StationLexer lexer(infile);
00023                 StationParser parser(lexer);
00024                 parser.stationfile();
00025                 for (unsigned int i = 0; i < parser.Stationnames.size(); ++i)
00026                 {
00027                         cout << "Working on file " << parser.Stationnames.at(i) << endl;
00028                         try
00029                         {
00030                           SeismicDataComp CurrentStation;
00031                            CurrentStation.GetData(parser.Stationnames.at(i)); 
00032                                 if (parser.HasLatLong.at(i))
00033                                 {
00034                                         CurrentStation.SetStLo(parser.Longitudes.at(i));
00035                                         CurrentStation.SetStLa(parser.Latitudes.at(i));
00036                                 }
00037                                 StationList.push_back(CurrentStation);
00038                         }
00039                         catch(ANTLRException& e)
00040                         {
00041                                 cerr << "File " << parser.Stationnames.at(i) << " not found !" << endl;
00042                         }
00043                 }
00044         }
00045         else
00046         {
00047                 throw ("File not found: " +filename);
00048         }
00049 }
00050 
00051 void SeismicStationList::WriteList(const std::string filename)
00052 {
00053         ofstream outfile(filename.c_str());
00054         for (tseiscompvector::iterator CurrentStation = StationList.begin(); CurrentStation != StationList.end(); CurrentStation++)
00055         {
00056                 outfile << CurrentStation->GetName();
00057                 outfile <<  setfill(' ') << setw(15) <<resetiosflags(ios::fixed);       
00058                 outfile << CurrentStation->GetStLo() << " ";
00059                 outfile <<  setfill(' ') << setw(15) <<resetiosflags(ios::fixed);
00060                 outfile << CurrentStation->GetStLa();
00061                 outfile << endl;                
00062         }
00063 }
00064 
00065 void SeismicStationList::WriteAllData()
00066 {
00067         for (tseiscompvector::iterator CurrentStation = StationList.begin(); CurrentStation != StationList.end(); CurrentStation++)
00068                 CurrentStation->WriteBack();
00069 }

Generated on Fri Jul 4 15:30:21 2008 for GPLIB++ by  doxygen 1.5.5