Documentation
¶
Overview ¶
Package goefa implements a go (golang) client library to access data of public transport companies which provide an EFA interface. You can search a stop, get its next departures or request a trip.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Departure ¶
type Departure struct { CountDown int // minutes until departure MapLink string // link to map Platform string // platform code PlatformName string // platform name StopID int // ID of the stop StopName string // name of the stop Lat int64 // Latitude Lng int64 // Longitude DateTime time.Time // Timestamp of departure ServingLine ServingLine // Line }
Departure represents a single departure for a specific stop.
type EFATime ¶
EFATime implements UnmarshalXML to support unmarshalling EFAs XML DateTime type directly into a time.Time compatible type
func (*EFATime) UnmarshalXML ¶
UnmarshalXML is a custom XML decoding method for EFATime
type MeansOfTransport ¶
type MeansOfTransport struct { Name string `xml:"name,attr"` Number string `xml:"symbol,attr"` MotType MotType `xml:"motType,attr"` }
MeansOfTransport represents the Means of Transportation
type Provider ¶
Provider represents a public transport company that provides access to its EFA instance. Use providers.json to store a list of known providers.
func NewProvider ¶
NewProvider returns a new Provider with custom settings
func (*Provider) Departures ¶
Departures performs a stateless dm_request for the corresponding stopID and returns an array of Departures. Use time.Now() as the second argument in order to get the very next departures. The third argument determines how many results will be returned by EFA.
func (*Provider) FindStop ¶
FindStop queries the EFA StopFinder API of the corresponding provider and returns an array of matched stops (or only the identified one) or an error in case somthing went wrong.
type Response ¶
type Response struct { XMLName xml.Name `xml:"itdRequest"` Client string `xml:"client,attr"` ClientIP string `xml:"clientIP,attr"` Language string `xml:"language,attr"` LengthUnit string `xml:"lengthUnit,attr"` Now string `xml:"now,attr"` NowWD int `xml:"nowID,attr"` ServerID string `xml:"serverID,attr"` SessionID int `xml:"sessionID,attr"` Version string `xml:"version,attr"` VirtDir string `xml:"virtDir,attr"` VersionInfo struct { AppVersion string `xml:"ptKernel>appVersion"` DataFormat string `xml:"ptKernel>dataFormat"` DataBuild string `xml:"ptKernel>dataBuild"` } `xml:"itdVersionInfo"` }
Response is the basic API response for all EFA requests
type Route ¶
type Route struct { Trips []*Trip OriginID int DestinationID int DepartureTime time.Time ArrivalTime time.Time }
Route is a route between two stops, including all necessary transfers
type ServingLine ¶
type ServingLine struct { // ROP int `xml:"ROP,attr"` // STT int `xml:"displayName,attr"` // TTB int `xml:"TTB,attr"` // Compound int `xml:"compound,attr"` // Code int `xml:"code,attr"` // Index string `xml:"index,attr"` Number string `xml:"number,attr"` Direction string `xml:"direction,attr"` DestStopID int `xml:"destID,attr"` MotType MotType `xml:"motType,attr"` }
ServingLine holds the data for a public transportation line