businfo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BusInfo

type BusInfo interface {
	GetPositions(request *GetPositionsRequest) (*GetPositionsResponse, error)
	GetRouteDetails(routeID, date string) (*GetRouteDetailsResponse, error)
	GetRoutes() (*GetRoutesResponse, error)
	GetSchedule(routeID, date string, includeVariations bool) (*GetScheduleResponse, error)
	GetScheduleAtStop(stopID, date string) (*GetScheduleAtStopResponse, error)
	GetStops(request *GetStopsRequest) (*GetStopsResponse, error)
}

BusInfo defines the methods available in the WMATA "Bus Route and Stop Methods" API

type BusPosition

type BusPosition struct {
	BlockNumber string `json:"BlockNumber" xml:"BlockNumber"`
	DateTime    string `json:"DateTime" xml:"DateTime"`
	Deviation   int    `json:"Deviation" xml:"Deviation"`
	// Deprecated: DirectionNumber response field is deprecated, use DirectionText
	DirectionNumber int     `json:"DirectionNum" xml:"DirectionNum"`
	DirectionText   string  `json:"DirectionText" xml:"DirectionText"`
	Latitude        float64 `json:"Lat" xml:"Lat"`
	Longitude       float64 `json:"Lon" xml:"Lon"`
	RouteID         string  `json:"RouteID" xml:"RouteID"`
	TripEndTime     string  `json:"TripEndTime" xml:"TripEndTime"`
	TripDestination string  `json:"TripHeadsign" xml:"TripHeadsign"`
	TripID          string  `json:"TripID" xml:"TripID"`
	TripStartTime   string  `json:"TripStartTime" xml:"TripStartTime"`
	VehicleID       string  `json:"VehicleID" xml:"VehicleID"`
}

type Direction

type Direction struct {
	// Deprecated: DirectionNumber response field is deprecated, use DirectionText
	DirectionNumber string       `json:"DirectionNum" xml:"DirectionNum"`
	DirectionText   string       `json:"DirectionText" xml:"DirectionText"`
	Shapes          []ShapePoint `json:"Shape" xml:"Shape>ShapePoint"`
	Stops           []Stop       `json:"Stops" xml:"Stops>Stop"`
	TripDestination string       `json:"TripHeadsign" xml:"TripHeadsign"`
}

type GetPositionsRequest

type GetPositionsRequest struct {
	RouteID   string
	Latitude  float64
	Longitude float64
	Radius    float64
}

GetPositionsRequest wraps a request to the "Bus Position" service

type GetPositionsResponse

type GetPositionsResponse struct {
	XMLName      xml.Name      `json:"-" xml:"http://www.wmata.com BusPositionsResp"`
	BusPositions []BusPosition `json:"BusPositions" xml:"BusPositions>BusPosition"`
}

type GetRouteDetailsResponse

type GetRouteDetailsResponse struct {
	XMLName    xml.Name  `json:"-" xml:"http://www.wmata.com RouteDetailsInfo"`
	Direction0 Direction `json:"Direction0" xml:"Direction0"`
	Direction1 Direction `json:"Direction1" xml:"Direction1"`
	Name       string    `json:"Name" xml:"Name"`
	RouteID    string    `json:"RouteID" xml:"RouteID"`
}

type GetRoutesResponse

type GetRoutesResponse struct {
	XMLName xml.Name `json:"-" xml:"http://www.wmata.com RoutesResp"`
	Routes  []Route  `json:"Routes" xml:"Routes>Route"`
}

type GetScheduleAtStopResponse

type GetScheduleAtStopResponse struct {
	XMLName          xml.Name          `json:"-" xml:"http://www.wmata.com StopScheduleInfo"`
	ScheduleArrivals []ScheduleArrival `json:"ScheduleArrivals" xml:"ScheduleArrivals>StopScheduleArrival"`
	StopInfo         Stop              `json:"Stop" xml:"Stop"`
}

type GetScheduleResponse

type GetScheduleResponse struct {
	XMLName    xml.Name `json:"-" xml:"http://www.wmata.com RouteScheduleInfo"`
	Direction0 []Trip   `json:"Direction0" xml:"Direction0>Trip"`
	Direction1 []Trip   `json:"Direction1" xml:"Direction1>Trip"`
	Name       string   `json:"Name" xml:"Name"`
}

type GetStopsRequest

type GetStopsRequest struct {
	Latitude  float64
	Longitude float64
	Radius    float64
}

type GetStopsResponse

type GetStopsResponse struct {
	XMLName xml.Name `json:"-" xml:"http://www.wmata.com StopsResp"`
	Stops   []Stop   `json:"Stops" xml:"Stops>Stop"`
}

type Route

type Route struct {
	Name            string `json:"Name" xml:"Name"`
	RouteID         string `json:"RouteID" xml:"RouteID"`
	LineDescription string `json:"LineDescription" xml:"LineDescription"`
}

type ScheduleArrival

type ScheduleArrival struct {
	DirectionNumber string `json:"DirectionNum" xml:"DirectionNum"`
	EndTime         string `json:"EndTime" xml:"EndTime"`
	RouteID         string `json:"RouteID" xml:"RouteID"`
	ScheduleTime    string `json:"ScheduleTime" xml:"ScheduleTime"`
	StartTime       string `json:"StartTime" xml:"StartTime"`
	TripDirection   string `json:"TripDirectionText" xml:"TripDirectionText"`
	TripDestination string `json:"TripHeadsign" xml:"TripHeadsign"`
	TripID          string `json:"TripID" xml:"TripID"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides all API methods for Bus Route and Stop Information from WMATA

func NewService

func NewService(client *wmata.Client, responseType wmata.ResponseType) *Service

NewService returns a new BusInfo Service service with a reference to an existing wmata.Client

func (*Service) GetPositions

func (busService *Service) GetPositions(request *GetPositionsRequest) (*GetPositionsResponse, error)

GetPositions retrieves the bus positions for a given route. Documentation on service structure can be found here: https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d68

func (*Service) GetRouteDetails

func (busService *Service) GetRouteDetails(routeID, date string) (*GetRouteDetailsResponse, error)

GetRouteDetails gets bus latitude and longitude by route Documentation on service structure can be found here: https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d69?

func (*Service) GetRoutes

func (busService *Service) GetRoutes() (*GetRoutesResponse, error)

GetRoutes gets a list of all bus route variants Documentation on service structure can be found here: https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6a?

func (*Service) GetSchedule

func (busService *Service) GetSchedule(routeID, date string, includeVariations bool) (*GetScheduleResponse, error)

GetSchedule gets a schedule for a route on a given date Documentation on service structure can be found here: https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6b?

func (*Service) GetScheduleAtStop

func (busService *Service) GetScheduleAtStop(stopID, date string) (*GetScheduleAtStopResponse, error)

GetScheduleAtStop gets a list of all buses scheduled to arrive at a given stop and date Documentation on service structure can be found here: https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6c?

func (*Service) GetStops

func (busService *Service) GetStops(request *GetStopsRequest) (*GetStopsResponse, error)

GetStops gets a list of nearby bus stops based on provided coordinates Documentation on service structure can be found here: https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6d?

type ShapePoint

type ShapePoint struct {
	Latitude       float64 `json:"Lat" xml:"Lat"`
	Longitude      float64 `json:"Lon" xml:"Lon"`
	SequenceNumber int     `json:"SeqNum" xml:"SeqNum"`
}

type Stop

type Stop struct {
	Latitude  float64  `json:"Lat" xml:"Lat"`
	Longitude float64  `json:"Lon" xml:"Lon"`
	Name      string   `json:"Name" xml:"Name"`
	Routes    []string `json:"Routes" xml:"Routes>string"`
	StopID    string   `json:"StopID" xml:"StopID"`
}

type StopTime

type StopTime struct {
	StopID       string `json:"StopID" xml:"StopID"`
	StopName     string `json:"StopName" xml:"StopName"`
	StopSequence int    `json:"StopSeq" xml:"StopSeq"`
	Time         string `json:"Time" xml:"Time"`
}

type Trip

type Trip struct {
	DirectionNumber string     `json:"DirectionNum" xml:"DirectionNum"`
	EndTime         string     `json:"EndTime" xml:"EndTime"`
	RouteID         string     `json:"RouteID" xml:"RouteID"`
	StartTime       string     `json:"StartTime" xml:"StartTime"`
	StopTimes       []StopTime `json:"StopTimes" xml:"StopTimes>StopTime"`
	TripDirection   string     `json:"TripDirectionText" xml:"TripDirectionText"`
	TripDestination string     `json:"TripHeadsign" xml:"TripHeadsign"`
	TripID          string     `json:"TripID" xml:"TripID"`
}

Jump to

Keyboard shortcuts

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