Package casa.lepton.walk
Class BusJourney
java.lang.Object
casa.lepton.walk.BusJourney
A bus journey along bus line paths, represented by an ordered list of paths
between bus stops having each a start and end time.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
A node in a bus journey.static interface
Interface that defines a pause duration generator to calculate pause durations at each stop node. -
Field Summary
-
Constructor Summary
ConstructorDescriptionBusJourney
(org.graphstream.graph.Graph graph, String busName, List<org.graphstream.graph.Path> lines) Create an empty bus journey. -
Method Summary
Modifier and TypeMethodDescriptionGive the name of the bus.long
Give the time when the bus arrives at the last node of the journey.long
Give the time when the bus leaves the first node of the journey.iterator
(long pauseSeed) Give an iterator over nodes that compose this journey.iterator
(BusJourney.PauseDurationGenerator pauseGenerator) Give an iterator over nodes that compose this journey.static BusJourney
loadJourney
(org.graphstream.graph.Graph graph, List<org.graphstream.graph.Path> lines, BufferedReader reader) Load a journey from an input stream which next line contains the name of the journey.
-
Field Details
-
DATE_FORMAT
The date format of the stops times.
-
-
Constructor Details
-
Method Details
-
getBusName
Give the name of the bus.- Returns:
- the name of the bus
-
getStartTime
public long getStartTime()Give the time when the bus leaves the first node of the journey.- Returns:
- the start time of the bus journey
-
getEndTime
public long getEndTime()Give the time when the bus arrives at the last node of the journey.- Returns:
- the end time of the bus journey
-
iterator
Give an iterator over nodes that compose this journey.- Parameters:
pauseSeed
- the seed used to create a random generator of pause durations- Returns:
- iterator over nodes of this journey
-
iterator
Give an iterator over nodes that compose this journey.- Parameters:
pauseGenerator
- to generate pauses durations- Returns:
- iterator over nodes of this journey
-
loadJourney
public static BusJourney loadJourney(org.graphstream.graph.Graph graph, List<org.graphstream.graph.Path> lines, BufferedReader reader) throws IOException, ParseException Load a journey from an input stream which next line contains the name of the journey. After this method, the last line of the input stream is either null or an empty line.- Parameters:
graph
- the graph that contains the nodes and edges of the lineslines
- the paths representing the bus linesreader
- input stream- Returns:
- a bus journey or null if the next line of the reader is null or empty
- Throws:
IOException
- if an error occurs while reading the input streamParseException
- if a read line has a wrong format
-