Documentation
¶
Index ¶
- Constants
- Variables
- func Distance(lat1 float64, lng1 float64, lat2 float64, lng2 float64, unit ...string) float64
- func GetTripFromTransfer(r *RoutingData, round map[uint64]StopArrival, destination uint64) (*fptf.Trip, uint64)
- func GetTripFromTrip(r *RoutingData, round map[uint64]StopArrival, arrival StopArrival) (*fptf.Trip, uint64)
- type Arc
- type Bifrost
- func (b *Bifrost) AddBifrostData(fileName string)
- func (b *Bifrost) AddGtfs(directory string) error
- func (b *Bifrost) AddOSM(path string) error
- func (b *Bifrost) ConnectStopsToVertices()
- func (b *Bifrost) DistanceMs(from kdtree.Point, to kdtree.Point) uint32
- func (b *Bifrost) LoadData(load *LoadOptions) error
- func (b *Bifrost) MergeData(other *RoutingData)
- func (b *Bifrost) NewRounds() *Rounds
- func (b *Bifrost) ReconstructJourney(destKey uint64, lastRound int, rounds *Rounds) *fptf.Journey
- func (b *Bifrost) Route(rounds *Rounds, origins []SourceLocation, dest *fptf.Location, onlyWalk bool, ...) (*fptf.Journey, error)
- func (b *Bifrost) RouteOnlyWalk(rounds *Rounds, origins []SourceKey, destKey uint64, debug bool) (*fptf.Journey, error)
- func (b *Bifrost) RouteUsingKeys(rounds *Rounds, origins []SourceKey, destKey uint64, debug bool) (*fptf.Journey, error)
- func (b *Bifrost) WriteBifrostData(fileName string)
- type GeoPoint
- type LoadOptions
- type Progress
- type Rounds
- type Route
- type RouteInformation
- type RoutingData
- type Service
- type SourceKey
- type SourceLocation
- type StopArrival
- type StopContext
- type StopRoutePair
- type Stopover
- type Trip
- type TripInformation
- type Vertex
Constants ¶
const ( TripIdTransfer = 0xffffffff TripIdNoChange = 0xfffffffe TripIdOrigin = 0xfffffffd ArrivalTimeNotReached uint64 = 0xffffffffffffffff )
const DayInMs uint32 = 24 * 60 * 60 * 1000
Variables ¶
var DefaultBifrost = &Bifrost{
TransferLimit: 4,
TransferPaddingMs: 0,
WalkingSpeed: 0.8 * 0.001,
MaxWalkingMs: 60 * 1000 * 15,
MaxStopsConnectionSeconds: 60 * 1000 * 5,
}
Functions ¶
func GetTripFromTransfer ¶
func GetTripFromTransfer(r *RoutingData, round map[uint64]StopArrival, destination uint64) (*fptf.Trip, uint64)
func GetTripFromTrip ¶
func GetTripFromTrip(r *RoutingData, round map[uint64]StopArrival, arrival StopArrival) (*fptf.Trip, uint64)
Types ¶
type Bifrost ¶
type Bifrost struct {
TransferLimit int
TransferPaddingMs uint64 // only search for trips, padded a bit after transitioning
WalkingSpeed float64 // in meters per ms
MaxWalkingMs uint32 // duration of walks not allowed to be higher than this when transferring
MaxStopsConnectionSeconds uint32 // max length of added arcs between stops and street graph in deciseconds
Data *RoutingData
}
func (*Bifrost) AddBifrostData ¶
AddBifrostData Adds cached bifrost data file to the Bifrost data. Used by LoadOptions, generated by WriteBifrostData
func (*Bifrost) ConnectStopsToVertices ¶
func (b *Bifrost) ConnectStopsToVertices()
ConnectStopsToVertices connects stops to street graph using knn and the Bifrost parameters.
func (*Bifrost) DistanceMs ¶
func (*Bifrost) LoadData ¶
func (b *Bifrost) LoadData(load *LoadOptions) error
LoadData loads the data from a given bifrost cache if it exists. Otherwise it will generate the data from given GTFS and street CSV files. After generating the data it will write the data to a bifrost cache.
func (*Bifrost) MergeData ¶
func (b *Bifrost) MergeData(other *RoutingData)
func (*Bifrost) ReconstructJourney ¶
func (*Bifrost) RouteOnlyWalk ¶
func (*Bifrost) RouteUsingKeys ¶
func (*Bifrost) WriteBifrostData ¶
type GeoPoint ¶
func (*GeoPoint) Dimensions ¶
type LoadOptions ¶
type Progress ¶
type Rounds ¶
type Rounds struct {
Rounds []map[uint64]StopArrival
MarkedStops map[uint64]bool
MarkedStopsForTransfer map[uint64]bool
EarliestArrivals map[uint64]uint64
Queue map[uint32]uint32
}
func (*Rounds) NewSession ¶
func (r *Rounds) NewSession()
func (*Rounds) ResetRounds ¶
func (r *Rounds) ResetRounds()
type RouteInformation ¶
type RouteInformation struct {
ShortName string
}
type RoutingData ¶
type RoutingData struct {
MaxTripDayLength uint32 `json:"maxTripDayLength"` // number of days to go backwards in time (for trips that end after midnight or multiple days later than the start)
Services []*Service `json:"services"`
Routes []*Route `json:"routes"`
StopToRoutes [][]StopRoutePair `json:"stopToRoutes"`
Trips []*Trip `json:"trips"`
StreetGraph [][]Arc `json:"streetGraph"`
Reorders map[uint64][]uint32 `json:"reorders"`
// for reconstructing journeys after routing
Vertices []Vertex `json:"vertices"`
StopsIndex map[string]uint64 `json:"stopsIndex"` // gtfs stop id -> vertex index
NodesIndex map[int64]uint64 `json:"nodesIndex"` // csv vertex id -> vertex index
GtfsRouteIndex []uint32 `json:"gtfsRouteIndex"` // route index -> gtfs route index
RouteInformation []*RouteInformation `json:"routeInformation"`
TripInformation []*TripInformation `json:"tripInformation"`
TripToRoute []uint32 `json:"tripToRoute"` // trip index -> route index
// for finding vertices by location. points are GeoPoint
VertexTree *kdtree.KDTree `json:"-"`
}
func MergeData ¶
func MergeData(a *RoutingData, b *RoutingData) *RoutingData
MergeData merges two RoutingData structs. It only concatenates the vertices and edges. Use ConnectStopsToVertices to connect stops to the street graph. IMPORTANT: This algorithm may change and re-use the data from both structs. Also note, that using multiple transit feeds may break things like the stops index due to duplicate stop ids. Multiple street graphs are not supported as there is no way of connecting them. todo: fix stops index for multiple transit feeds todo: add support for multiple street graphs
func (*RoutingData) EnsureSliceLengths ¶
func (r *RoutingData) EnsureSliceLengths()
func (*RoutingData) GetFptfStop ¶
func (r *RoutingData) GetFptfStop(stop uint64) *fptf.StopStation
func (*RoutingData) GetTime ¶
func (r *RoutingData) GetTime(ms uint64) fptf.TimeNullable
func (*RoutingData) PrintStats ¶
func (r *RoutingData) PrintStats()
func (*RoutingData) RebuildVertexTree ¶
func (r *RoutingData) RebuildVertexTree()
type StopArrival ¶
type StopArrival struct {
Arrival uint64 // arrival time in unix ms
Trip uint32 // trip id, 0xffffffff specifies a transfer, 0xfffffffe specifies no change compared to previous round
EnterKey uint64 // stop sequence key in route for trips, vertex key for transfers
Departure uint64 // departure day for trips, departure time in unix ms for transfers
}
type StopContext ¶
type StopRoutePair ¶
type Stopover ¶
type Stopover struct {
Arrival uint32 // ms time since start of day
Departure uint32 // ms time since start of day
}
func (Stopover) ArrivalAtDay ¶
func (Stopover) DepartureAtDay ¶
type TripInformation ¶
type TripInformation struct {
Headsign string
}