00001
00002
00003
00004
00005
00006
00007 #ifndef ROUTEPLANNINGV2_TRANSITNETWORK_H_
00008 #define ROUTEPLANNINGV2_TRANSITNETWORK_H_
00009
00010 #include <gtest/gtest.h>
00011 #include <unordered_map>
00012 #include <unordered_set>
00013 #include <string>
00014 #include <utility>
00015 #include <vector>
00016 #include "./RoadNetwork.h"
00017 #include "./NodeExpanded.h"
00018 #include "./TransitParser.h"
00019 #include "./LiveConnection.h"
00020
00021 using std::string;
00022 using std::unordered_set;
00023 using std::unordered_map;
00024 using std::pair;
00025 using std::vector;
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class TransitNetworkExpanded : public Graph
00036 {
00037 public:
00038 TransitNetworkExpanded();
00039 TransitNetworkExpanded(const TransitNetworkExpanded& orig);
00040 virtual ~TransitNetworkExpanded();
00041 FRIEND_TEST(TransitNetworkTest, parseFromGTFSFiles);
00042 FRIEND_TEST(TransitNetworkTest, computeShortestPathTransit);
00043
00044 void parseFromGTFSFiles(const string& folderName, char validWeekday,
00045 int transferTimeInSeconds);
00046
00047
00048
00049 void addEdgeWithTimeDifference(int startId, int endId);
00050
00051 void addNodeOfTrip(NodeExpanded node, int tripId);
00052
00053 void addStop(const Stop& newStop);
00054 size_t getNumStops();
00055
00056
00057 bool getStopNodeIds(const string& stopName, vector<int>* stopNodeIds) const;
00058
00059 const vector<int>& getStopNodeIds(int stopId);
00060
00061 void getStopsStartingWith(const string& prefix,
00062 vector<string>* stopNames) const;
00063
00064 string getStopName(int stopId);
00065
00066 Stop* getStop(int stopId);
00067
00068 int getStopId(const string& stopName);
00069
00070 int getTripId(int nodeId);
00071
00072
00073 void getStartNodeIds(int stopId, const Time& startTime,
00074 vector<int>* startNodeIds);
00075 int getVerbosity();
00076 void setVerbosity(int verbosity);
00077 void getConnections(int nodeId, bool isStartNode, Time arrivalTime,
00078 vector<LiveConnection>* outConnections);
00079
00080
00081
00082 private:
00083
00084
00085 FRIEND_TEST(TransitNetworkTest, parseCalendarFile);
00086 void parseCalendarFile(const string& calendarFileName,
00087 char validWeekDay,
00088 unordered_set<string>* validServiceIds);
00089
00090 FRIEND_TEST(TransitNetworkTest, parseTripsFile);
00091 void parseTripsFile(const string& tripFileName,
00092 const unordered_set<string>& validServiceIds,
00093 unordered_map<string, int>* tripIdNameToTripId);
00094
00095 FRIEND_TEST(TransitNetworkTest, parseStopsFile);
00096 void parseStopsFile(const string& stopFileName,
00097 vector<Stop>* stops,
00098 unordered_map<string, int>* stopIdNameToId);
00099
00100
00101
00102
00103 FRIEND_TEST(TransitNetworkTest, parseFrequenciesFile);
00104 void parseFrequenciesFile(const string& frequencyFileName,
00105 unordered_map<string, vector<TransitParser::TripFrequency> >*
00106 tripIdNameToFrequencies);
00107 FRIEND_TEST(TransitNetworkTest, parseStopTimesFile);
00108 void parseStopTimesFile(const string& stopTimesFile,
00109 const unordered_map<string, int>& stopIdNameToId,
00110 const unordered_map<string, vector<TransitParser::TripFrequency> >&
00111 tripIdNameToFrequencies,
00112 const unordered_map<string, int>& tripIdNameToTripId,
00113 int transferTimeInSeconds);
00114
00115 FRIEND_TEST(TransitNetworkTest, addTrip);
00116
00117
00118 void addTrip(const vector<TransitParser::TripNode>& trip,
00119 const TransitParser::TripFrequency& frequency,
00120 vector<vector<int> >* stopIdToNodeIds,
00121 int tripId);
00122 void addTransferEdges(const vector<vector<int> >&
00123 stopIdsToNodeIds);
00124 vector<Stop> _stops;
00125
00126
00127 vector<int> _tripIds;
00128
00129
00130
00131 int _verbosity;
00132 };
00133 #endif // ROUTEPLANNINGV2_TRANSITNETWORK_H_