Documentation ¶
Overview ¶
Package routing offers an algorithm to find the fastest route in a public transportation network.
The cornerstone of the package is the Timetable type which contains all information of the public transportation network.
Users of this package have to define Stops – physical locations where vehicles stop. A stop must have an Id and a list of departure events. All events consist of a departure time, a reference to the line they belong to, and information about the travel time to the next stop and which stop this is. The list of stops is used to create a timetable. This timetable can then be queried for shortest routes.
The departure times are given in the format "15:04" (resp. "HH:MM"). Queries always contain a real date and time (time.Time type). The departure times are then interpreted to take place at the certain date. In order to simulate timetables spanning more than one day, departure times can also be given four hours bigger than 23 o'clock, e.g. 26:34 means 02:34 on the second day.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TimeRegex = regexp.MustCompile("^([0-9]+):?([0-5][0-9])$")
TimeRegex is used to validate time strings.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
Connection is the result of a route computation. It contains the arrival time as well a slice of legs which describe the lines that have to be taken at certain stations in order to reach the target station.
type Event ¶
Event describes the departure of a certain line's vehicle at a station. The segment property points to the line segment that describes the journey to the next stop after the event's stop.
type Leg ¶
Leg is a part of a journey during which there is no change of lines. A leg has the first stop, a last stop and a line.
type Line ¶
Line represents a line in a public transportation network. It consists of an Id, which should be unique among all lines. Variants of lines (e.g. additional stops in the rush hour) should be modeled with additional lines.
type Stop ¶
Stop is a physical stop where a public transport vehicle stops and lets passengers enter and exit. The Id of the stop must be unique.
type Time ¶
type Time string
Time is a string data type that can be interpreted as simple time (without date). The time string should always match the TimeRegex, otherwise a panic may be risen.
Examples: 12:04, 14:34, 28:23 are all valid times
func CreateTime ¶
CreateTime creates a time string from a given hour and minute.
type Timetable ¶
type Timetable struct {
// contains filtered or unexported fields
}
Timetable contains all routing information in a public transport network. Timetables should be created with the NewTimetable function.
func NewTimetable ¶
NewTimetable creates a new timetable containing the passed stops. The stops contain all relevant information about the transport network (arrivals, departures, and lines).