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