bvbus

package module
v0.0.0-...-2ed80af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoDirection Direction = 0
	Tour        Direction = 1
	Retour      Direction = 2

	Unknown           DOW = 0
	WeekDays          DOW = 1
	SaturdayAndSunday DOW = 2
	Saturday          DOW = 3
	Sunday            DOW = 4
)
View Source
const (
	EarthRadius = 6371000.0
	ToRadians   = math.Pi / 180.0
)
View Source
const (
	StationStr = "Staţia:"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BusName

type BusName = string

type BusStops

type BusStops struct {
	Busses    map[BusName]map[Direction][]StationName                            // map of bus name, direction and station names (including terminals)
	Terminals map[BusName]map[Direction][]StationName                            // map of bus name, direction and terminal station names
	Stations  map[StationName]map[Direction][]BusName                            // map of station name, direction and display name of the busses
	Schedules map[BusName]map[Direction]map[StationName]map[DOW][]HoursAndMinute // map of bus name, direction, station names, day of the week and slice of schedules
	// contains filtered or unexported fields
}

func NewBusStopsKeeper

func NewBusStopsKeeper() BusStops

func (*BusStops) AddBusToSchedule

func (b *BusStops) AddBusToSchedule(bus BusName, direction Direction, station StationName, dow DOW, hour, minute int)

func (*BusStops) AddBusToStation

func (b *BusStops) AddBusToStation(name StationName, direction Direction, bus BusName)

func (*BusStops) AddStation

func (b *BusStops) AddStation(name StationName, direction Direction) string

func (*BusStops) AddStop

func (b *BusStops) AddStop(bus BusName, direction Direction, stop StationName)

func (*BusStops) AddTerminal

func (b *BusStops) AddTerminal(bus BusName, direction Direction, terminal StationName)

func (*BusStops) AddTerminals

func (b *BusStops) AddTerminals(lineName string, direction Direction, from string)

func (*BusStops) ForTerminals

func (b *BusStops) ForTerminals(lineName string, direction Direction, from string)

func (*BusStops) HasTerminals

func (b *BusStops) HasTerminals(bus BusName, direction Direction) bool
type BussesAndLinks struct {
	Busses []BusName              `json:"busses,omitempty"`
	Links  []StationNameAndWeight `json:"links,omitempty"`
}

type BussesWithTerminalsAndStations

type BussesWithTerminalsAndStations struct {
	Terminals []StationName                            `json:"terminals,omitempty"`
	Stations  map[StationName]map[DOW][]HoursAndMinute `json:"stations,omitempty"`
}

type DOW

type DOW int

func (*DOW) Find

func (d *DOW) Find(from string)

func (DOW) String

func (d DOW) String() string

type Direction

type Direction int

func (*Direction) Find

func (d *Direction) Find(routeName string) string

func (Direction) Reverse

func (d Direction) Reverse() Direction

func (Direction) String

func (d Direction) String() string

type Graph

type Graph struct {
	Nodes map[string]map[Direction]*Stop
	// contains filtered or unexported fields
}

func (*Graph) AddEdge

func (g *Graph) AddEdge(s1, s2 *Stop, duration int)

func (*Graph) AddNode

func (g *Graph) AddNode(s *Stop) error

func (*Graph) GetShortestPath

func (g *Graph) GetShortestPath(from, to string) *Result

type HoursAndMinute

type HoursAndMinute struct {
	Hour   int `json:"h"`
	Minute int `json:"m"`
}

func (*HoursAndMinute) MinutesBetween

func (h *HoursAndMinute) MinutesBetween(h2 *HoursAndMinute) int

type LatLong

type LatLong struct {
	Lat float64 // The field value must be a valid WGS 84 latitude.
	Lon float64 // The field value must be a valid WGS 84 longitude value from -180 to 180.
}

func (*LatLong) DistanceToCoordinate

func (l *LatLong) DistanceToCoordinate(lat, lon float64) float64

type Path

type Path struct {
	Stop     *Stop
	Duration int
}

type Result

type Result struct {
	Solutions []Solution
}

type Solution

type Solution struct {
	Start    *Stop
	End      *Stop
	Stops    []*Stop    `json:"stops"`
	Duration int        `json:"durations"`
	Busses   [][]string `json:"busses"`
}

type StationName

type StationName = string

type StationNameAndWeight

type StationNameAndWeight struct {
	Station StationName `json:"station"`
	Weight  int         `json:"weight"`
}

type StationsAndBusses

type StationsAndBusses struct {
	Stations map[StationName]map[Direction]*BussesAndLinks             `json:"stations"`
	Busses   map[BusName]map[Direction]*BussesWithTerminalsAndStations `json:"busses"`
}

type Stop

type Stop struct {
	Name      string
	Direction Direction
	Busses    []string // TODO : using a map will facilitate finding the common elements
	Links     []Path
}

type StopQueue

type StopQueue struct {
	Paths []Path
	// contains filtered or unexported fields
}

func (*StopQueue) Dequeue

func (s *StopQueue) Dequeue() *Path

func (*StopQueue) Enqueue

func (s *StopQueue) Enqueue(p Path)

func (*StopQueue) IsEmpty

func (s *StopQueue) IsEmpty() bool

func (*StopQueue) NewQueue

func (s *StopQueue) NewQueue() *StopQueue

func (*StopQueue) Size

func (s *StopQueue) Size() int

type TopoGraph

type TopoGraph[key comparable] struct {
	// contains filtered or unexported fields
}

func NewTopoGraph

func NewTopoGraph[key comparable]() *TopoGraph[key]

func (*TopoGraph[key]) AddEdge

func (g *TopoGraph[key]) AddEdge(from key, to key) error

func (*TopoGraph[key]) AddNode

func (g *TopoGraph[key]) AddNode(node key)

func (*TopoGraph[key]) ContainsNode

func (g *TopoGraph[key]) ContainsNode(node key) bool

func (*TopoGraph[key]) Sort

func (g *TopoGraph[key]) Sort(node key) ([]key, error)

type WeightKeys

type WeightKeys struct {
	Station string
	Pair    string
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL