Documentation
¶
Index ¶
- Constants
- Variables
- type BusTimeClient
- type BusTimeService
- type DeparturesResponse
- type DeparturesResponseTrain
- type DetailLevel
- type Distances
- type ErrorCondition
- type Extensions
- type Feed
- type FeedsClient
- type FeedsService
- type FramedVehicleJourneyRef
- type HTTPClient
- type LIRRClient
- type LIRRService
- type MonitoredCall
- type MonitoredStopVisit
- type MonitoredVehicleJourney
- type OnwardCall
- type OnwardCalls
- type OtherError
- type ServiceDelivery
- type Siri
- type SituationRef
- type StopMonitoringDelivery
- type StopMonitoringResponse
- type VehicleLocation
- type VehicleMonitoringDelivery
Constants ¶
View Source
const LIRRDepartureURL = "https://traintime.lirr.org/api/Departure"
View Source
const (
StopMonitoringURL = "http://bustime.mta.info/api/siri/stop-monitoring.json"
)
Variables ¶
View Source
var ( ErrAPIKeyRequired = fmt.Errorf("API key required") ErrAPIKeyNotAuthorized = fmt.Errorf("API key not authorized") ErrClientRequired = fmt.Errorf("client required") )
View Source
var ( SubwayFeeds []Feed = []Feed{ Feed123456S, FeedACEHS, FeedNQRW, FeedBDFM, FeedL, FeedSIR, FeedG, FeedJZ, Feed7, } AllFeeds []Feed = append(SubwayFeeds, FeedLIRR, FeedMNR) AllAlerts []Feed = []Feed{ AlertsAll, AlertsSubway, AlertsBus, AlertsLIRR, AlertsMNR, } )
Functions ¶
This section is empty.
Types ¶
type BusTimeClient ¶
type BusTimeClient struct {
// contains filtered or unexported fields
}
func NewBusTimeClient ¶
func NewBusTimeClient(client HTTPClient, apiKey, userAgent string) (*BusTimeClient, error)
func (*BusTimeClient) GetStopMonitoring ¶
func (c *BusTimeClient) GetStopMonitoring(stopID string) (*StopMonitoringResponse, error)
func (*BusTimeClient) GetStopMonitoringWithDetailLevel ¶
func (c *BusTimeClient) GetStopMonitoringWithDetailLevel(stopID string, detailLevel DetailLevel) (*StopMonitoringResponse, error)
type BusTimeService ¶
type BusTimeService interface { GetStopMonitoring(stopID string) (*StopMonitoringResponse, error) GetStopMonitoringWithDetailLevel(stopID string, detailLevel DetailLevel) (*StopMonitoringResponse, error) }
type DeparturesResponse ¶
type DeparturesResponse struct { Location string `json:"LOC"` // The three-letter code for that station, e.g.: JAM Time string `json:"TIME"` // The date and time the feed was returned at in mm/dd/yyyy hh:mm:ss format (24-hr time) Trains []DeparturesResponseTrain `json:"TRAINS"` // Countdown items for each arriving train }
type DeparturesResponseTrain ¶
type DeparturesResponseTrain struct { ScheduledTime string `json:"SCHED"` // The scheduled date and time the train is supposed to arrive at the station in mm/dd/yyyy hh:mm:ss format (24-hr time) TrainID string `json:"TRAIN_ID"` // The train number. These are typically 1-4 digit train numbers you can find in the timetables or as the train_id’s in the GTFS feeds, though since this feed shows inserts, they can be up to 8 alphanumeric characters long. RunDate string `json:"RUN_DATE"` // E.g.: "2019-12-14", Destination string `json:"DEST"` // The three-letter station code of the final stop on that train. Stops []string `json:"STOPS"` // The three-letter station codes of all remaining stops that train is supposed to make. If the countdown is showing at the final destination, the field will be blank for “discharge only” trains. NOTE: Hillside stops are not shown in this field. Track string `json:"TRACK"` // The track and platform the train is supposed to depart from. May be blank at terminals when the track is not yet posted. Direction string `json:"DIR"` // The direction the train is travelling (E = eastbound, W = westbound) HSF bool `json:"HSF"` // Indicates whether or not the train will stop at Hillisde (true = train stops, false = train does not stop) JAM *bool `json:"JAM"` // Indicates whether or not the train will stop at Jamaica (ture = train stops, false = train will pass through Jamaica but not stop, null = train won’t pass through Jamaica). ETA string `json:"ETA"` // The estimated arrival time of that train, updated to account for all reported schedule deviations. Returned in mm/dd/yyyy hh:mm:ss format (24-hr time). The difference between this time and the ScheduledTime is how late or early the train is. Countdown int `json:"CD"` // The number of seconds between now and the time the train is supposed to arrive (a countdown field). }
DeparturesResponseTrain - part of DeparturesResponse
type DetailLevel ¶
type DetailLevel string
type Distances ¶
type Distances struct { // The distance of the stop from the beginning of the trip/route CallDistanceAlongRoute float64 // The distance from the vehicle to the stop along the route, in meters DistanceFromCall float64 // The distance displayed in the UI, see below for an additional note PresentableDistance string // The number of stops on the vehicle's current trip until the stop in question, starting from 0 StopsFromCall int }
type ErrorCondition ¶
type ErrorCondition struct { OtherError OtherError Description string }
type Extensions ¶
type Extensions struct { // The MTA Bus Time extensions to show distance of the vehicle from the stop Distances Distances }
type Feed ¶
type Feed string
const ( Feed123456S Feed = "nyct/gtfs" // Red FeedACEHS Feed = "nyct/gtfs-ace" // Blue, Franklin Ave. Shuttle FeedNQRW Feed = "nyct/gtfs-nqrw" // Yellow FeedBDFM Feed = "nyct/gtfs-bdfm" // Orange FeedL Feed = "nyct/gtfs-l" FeedSIR Feed = "nyct/gtfs-si" // StatenIslandRailway FeedG Feed = "nyct/gtfs-g" FeedJZ Feed = "nyct/gtfs-jz" // Brown Feed7 Feed = "nyct/gtfs-7" FeedLIRR Feed = "lirr/gtfs-lirr" // Long Island Rail Road FeedMNR Feed = "mnr/gtfs-mnr" // Metro-North Railroad AlertsAll Feed = "camsys/all-alerts" // All Service Alerts AlertsSubway Feed = "camsys/subway-alerts" // Subway Alerts AlertsBus Feed = "camsys/bus-alerts" // Bus Alerts AlertsLIRR Feed = "camsys/lirr-alerts" // Long Island Rail Road Alerts AlertsMNR Feed = "camsys/mnr-alerts" // Metro-North Railroad Alerts FeedURL = "https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/" )
type FeedsClient ¶
type FeedsClient struct {
// contains filtered or unexported fields
}
FeedsClient provides MTA GTFS-Realtime data Implements FeedsService interface.
func NewFeedsClient ¶
func NewFeedsClient(client HTTPClient, apiKey, userAgent string) (*FeedsClient, error)
NewFeedsClient creates new FeedsClient
func (*FeedsClient) GetFeedMessage ¶
func (f *FeedsClient) GetFeedMessage(feedID Feed) (*gtfs.FeedMessage, error)
GetFeedMessage sends request to MTA server to get latest GTFS-Realtime data from specified feed
type FeedsService ¶
type FeedsService interface {
GetFeedMessage(feedID Feed) (*gtfs.FeedMessage, error)
}
type FramedVehicleJourneyRef ¶
type LIRRClient ¶
type LIRRClient struct {
// contains filtered or unexported fields
}
func NewLIRRClient ¶
func NewLIRRClient(client HTTPClient, userAgent string) (*LIRRClient, error)
NewLIRRClient creates new LIRRClient
func (*LIRRClient) Departures ¶
func (lc *LIRRClient) Departures(locationCode string) (*DeparturesResponse, error)
Departures gets train departures from specified station locationCode – three-letter code for the station, for example:
"NYK" for NY-Penn Station "ATL" for Brooklyn-Atlantic Term "HVL" for Hicksville
Full list of codes: https://github.com/errornil/mta/blob/master/lirr.md
type LIRRService ¶
type LIRRService interface {
Departures(locationCode string) (*DeparturesResponse, error)
}
type MonitoredCall ¶
type MonitoredCall struct { // The GTFS stop ID of the stop prefixed by agency_id StopPointRef string // The ordinal value of the visit of this vehicle to this stop, always 1 in this implementation VisitNumber int // Predicted arrival times in ISO8601 format ExpectedArrivalTime string // Predicted departure times in ISO8601 format ExpectedDepartureTime string // SIRI container for extensions to the standard Extensions Extensions ArrivalProximityText string DistanceFromStop int NumberOfStopsAway int StopPointName []string }
type MonitoredStopVisit ¶
type MonitoredStopVisit struct { // The timestamp of the last real-time update from the particular vehicle RecordedAtTime string // A complete MonitoredVehicleJourney element MonitoredVehicleJourney MonitoredVehicleJourney }
type MonitoredVehicleJourney ¶
type MonitoredVehicleJourney struct { // The 'fully qualified' route name (GTFS agency ID + route ID) for the trip the vehicle is serving. // Not intended to be customer-facing LineRef string // The GTFS direction for the trip the vehicle is serving DirectionRef string // A compound element uniquely identifying the trip the vehicle is serving FramedVehicleJourneyRef FramedVehicleJourneyRef // The GTFS Shape_ID, prefixed by GTFS Agency ID JourneyPatternRef string // The GTFS route_short_name PublishedLineName []string // GTFS Agency_ID OperatorRef string // The GTFS stop ID for the first stop on the trip the vehicle is serving, prefixed by Agency ID OriginRef string // The GTFS stop ID for the last stop on the trip the vehicle is serving, prefixed by Agency ID DestinationRef string // The GTFS trip_headsign for the trip the vehicle is serving DestinationName []string // If a bus has not yet departed, OriginAimedDepartureTime indicates the scheduled departure time of that bus from that terminal in ISO8601 format OriginAimedDepartureTime string // SituationRef, present only if there is an active service alert covering this call SituationRef []SituationRef // Always true Monitored bool // The most recently recorded or inferred coordinates of this vehicle VehicleLocation *VehicleLocation // Vehicle bearing: 0 is East, increments counter-clockwise Bearing float64 // Indicator of whether the bus is making progress (i.e. moving, generally), // not moving (with value noProgress), // laying over before beginning a trip (value layover), // or serving a trip prior to one which will arrive (prevTrip). ProgressRate string // Optional indicator of vehicle progress status. // Set to "layover" when the bus is in a layover waiting for its next trip to start at a terminal, // and/or "prevTrip" when the bus is currently serving the previous trip // and the information presented 'wraps around' to the following scheduled trip ProgressStatus []string // Optional indicator of whether the bus occupancy is deemed to be "full", "seatsAvailable" or "standingAvailable". // If bus occupancy information is not available, this indicator is not shown (aka hidden.) Occupancy string // The vehicle ID, preceded by the GTFS agency ID VehicleRef string // Depending on the system's level of confidence, the GTFS block_id the bus is serving. // Please see "Transparency of Block vs. Trip-Level Assignment" section below BlockRef string // Call data about a particular stop // In StopMonitoring, it is the stop of interest; // in VehicleMonitoring it is the next stop the bus will make. MonitoredCall *MonitoredCall // The collection of calls that a vehicle is going to make OnwardCalls *OnwardCalls }
type OnwardCall ¶
type OnwardCall struct { // The GTFS stop ID of the stop StopPointRef string // The ordinal value of the visit of this vehicle to this stop, always 1 in this implementation VisitNumber int // The GTFS stop name of the stop StopPointName []string Extensions Extensions ExpectedArrivalTime string ArrivalProximityText string DistanceFromStop int NumberOfStopsAway int }
type OnwardCalls ¶
type OnwardCalls struct {
OnwardCalls []OnwardCall
}
type OtherError ¶
type OtherError struct {
ErrorText string
}
type ServiceDelivery ¶
type ServiceDelivery struct { // The timestamp on the MTA Bus Time server at the time the request was fulfilled ResponseTimestamp string // SIRI container for VehicleMonitoring response data StopMonitoringDelivery []StopMonitoringDelivery VehicleMonitoringDelivery []VehicleMonitoringDelivery }
type Siri ¶
type Siri struct {
ServiceDelivery ServiceDelivery
}
type SituationRef ¶
type SituationRef struct { // SituationRef, present only if there is an active service alert covering this call SituationSimpleRef string }
type StopMonitoringDelivery ¶
type StopMonitoringDelivery struct { // Required by the SIRI spec ResponseTimestamp string // The time until which the response data is valid until ValidUntil string // SIRI container for data about a particular vehicle service the selected stop MonitoredStopVisit []MonitoredStopVisit }
type StopMonitoringResponse ¶
type StopMonitoringResponse struct {
Siri Siri
}
type VehicleLocation ¶
type VehicleMonitoringDelivery ¶
type VehicleMonitoringDelivery struct { // Required by the SIRI spec ResponseTimestamp string ErrorCondition ErrorCondition }
Click to show internal directories.
Click to hide internal directories.