00001
00002
00003
00004 #ifndef ROUTEPLANNING_TRANSITPARSER_H_
00005 #define ROUTEPLANNING_TRANSITPARSER_H_
00006 #include <string>
00007 #include <vector>
00008 #include <unordered_set>
00009 #include <unordered_map>
00010 #include "./NodeExpanded.h"
00011 #include "./CsvParser.h"
00012 using std::string;
00013 using std::vector;
00014 using std::unordered_set;
00015 using std::unordered_map;
00016
00017
00018
00019
00020
00021
00022
00023 struct Stop
00024 {
00025 int stopId;
00026 string stopName;
00027 double latitude;
00028 double longitude;
00029 vector<int> nodeIdsSortedByTime;
00030 Stop(int stopId, const string& stopName, double latitude, double longitude);
00031 };
00032 class TransitParser {
00033 public:
00034
00035
00036
00037 struct TripNode
00038 {
00039
00040
00041
00042 TripNode(const string& GTFSTimeString, int stopId, NodeType type);
00043 int stopId;
00044 int secondsSinceDay;
00045 NodeType type;
00046 };
00047
00048
00049
00050 struct TripFrequency
00051 {
00052 char startHour;
00053 char startMinute;
00054 char startSecond;
00055 char endHour;
00056 char endMinute;
00057 char endSecond;
00058 int intervalInSeconds;
00059 TripFrequency();
00060 TripFrequency(char startHour, char startMinute, char startSecond,
00061 char endHour, char endMinute, char endSecond,
00062 int intervalInSeconds);
00063 };
00064 struct Trip
00065 {
00066 int tripId;
00067 vector <TripNode> nodes;
00068 vector<TripFrequency> frequencies;
00069 };
00070
00071 TransitParser(int verbosity);
00072 void parseCalendarFile(const string& calendarFileName,
00073 char validWeekDay,
00074 unordered_set<string>* validServiceIds);
00075 void parseTripsFile(const string& tripFileName,
00076 const unordered_set<string>& validServiceIds,
00077 unordered_map<string, int>* tripIdNameToTripId);
00078 void parseStopsFile(const string& stopFileName,
00079 vector<Stop>* stops,
00080 unordered_map<string, int>* stopIdNameToId);
00081 void parseFrequenciesFile(const string& frequencyFileName,
00082 unordered_map<string,
00083 vector<TripFrequency> >*
00084 tripIdNameToFrequencies);
00085 void parseStopTimesFile(const string& stopTimesFile,
00086 const unordered_map<string, int>& stopIdNameToId,
00087 const unordered_map<string, vector<TripFrequency> >&
00088 tripIdNameToFrequencies,
00089 const unordered_map<string, int>& tripIdNameToTripId,
00090 int transferTimeInSeconds,
00091 vector<Trip>* parsedTrips);
00092
00093 private:
00094 int _verbosity;
00095
00096 };
00097
00098 #endif // ROUTEPLANNING_TRANSITPARSER_H_
00099