gtfs_rt_nyct
Types
pub type Date {
Date(year: Int, month: Int, day: Int)
}
Constructors
-
Date(year: Int, month: Int, day: Int)
A selector for an entity in a GTFS feed.
pub type EntitySelector {
EntitySelector(
agency_id: option.Option(String),
route_id: option.Option(String),
trip: option.Option(TripDescriptor),
stop_id: option.Option(String),
mercury_entity_selector: option.Option(MercuryEntitySelector),
)
}
Constructors
-
EntitySelector( agency_id: option.Option(String), route_id: option.Option(String), trip: option.Option(TripDescriptor), stop_id: option.Option(String), mercury_entity_selector: option.Option(MercuryEntitySelector), )Arguments
- agency_id
-
The GTFS-ID for the agency that correlated to the route_id or stop_id (e.g. MTASBWY). MTA agency IDs are MNR for Metro North Railroad, MTASBWY for subway, MTA NYCT or MTABC for buses, and LI for Long Island Rail Road.
- route_id
-
Format is the GTFS-ID for the route without the agency prefix (e.g. G)
- trip
-
Not currently used in the dedicated alerts feed. Coming soon for railroad trips.
- stop_id
-
Format is the GTFS-ID for the route without the agency prefix (e.g. L03)
A definition (or update) of an entity in the transit feed.
pub type FeedEntity {
FeedEntity(id: String, data: FeedEntityData)
}
Constructors
-
FeedEntity(id: String, data: FeedEntityData)Arguments
- id
-
The ids are used only to provide incrementality support. The id should be unique within a FeedMessage. Consequent FeedMessages may contain FeedEntities with the same id. In case of a DIFFERENTIAL update the new FeedEntity with some id will replace the old FeedEntity with the same id (or delete it - see is_deleted below). The actual GTFS entities (e.g. stations, routes, trips) referenced by the feed must be specified by explicit selectors (see EntitySelector below for more info).
pub type FeedEntityData {
TripUpdate(
trip: TripDescriptor,
stop_time_updates: List(StopTimeUpdate),
)
VehiclePosition(
trip: TripDescriptor,
current_stop_sequence: option.Option(Int),
current_status: VehicleStopStatus,
timestamp: UnixTime,
stop_id: String,
)
Alert(
active_periods: List(TimeRange),
informed_entities: List(EntitySelector),
header_text: TranslatedString,
description_text: option.Option(TranslatedString),
mercury_alert: option.Option(MercuryAlert),
)
}
Constructors
-
TripUpdate( trip: TripDescriptor, stop_time_updates: List(StopTimeUpdate), )Realtime update of the progress of a vehicle along a trip. Depending on the value of ScheduleRelationship, a TripUpdate can specify:
- A trip that proceeds along the schedule.
- A trip that proceeds along a route but has no fixed schedule.
- A trip that have been added or removed with regard to schedule.
The updates can be for future, predicted arrival/departure events, or for past events that already occurred. Normally, updates should get more precise and more certain (see uncertainty below) as the events gets closer to current time. Even if that is not possible, the information for past events should be precise and certain. In particular, if an update points to time in the past but its update’s uncertainty is not 0, the client should conclude that the update is a (wrong) prediction and that the trip has not completed yet.
Note that the update can describe a trip that is already completed. To this end, it is enough to provide an update for the last stop of the trip. If the time of that is in the past, the client will conclude from that that the whole trip is in the past (it is possible, although inconsequential, to also provide updates for preceding stops). This option is most relevant for a trip that has completed ahead of schedule, but according to the schedule, the trip is still proceeding at the current time. Removing the updates for this trip could make the client assume that the trip is still proceeding. Note that the feed provider is allowed, but not required, to purge past updates - this is one case where this would be practically useful.
Arguments
- trip
-
The Trip that this message applies to. There can be at most one TripUpdate entity for each actual trip instance. If there is none, that means there is no prediction information available. It does not mean that the trip is progressing according to schedule.
- stop_time_updates
-
Updates to StopTimes for the trip (both future, i.e., predictions, and in some cases, past ones, i.e., those that already happened). The updates must be sorted by stop_sequence, and apply for all the following stops of the trip up to the next specified one.
Example 1: For a trip with 20 stops, a StopTimeUpdate with arrival delay and departure delay of 0 for stop_sequence of the current stop means that the trip is exactly on time.
Example 2: For the same trip instance, 3 StopTimeUpdates are provided:
- delay of 5 min for stop_sequence 3
- delay of 1 min for stop_sequence 8
- delay of unspecified duration for stop_sequence 10 This will be interpreted as:
- stop_sequences 3,4,5,6,7 have delay of 5 min.
- stop_sequences 8,9 have delay of 1 min.
- stop_sequences 10,… have unknown delay.
-
VehiclePosition( trip: TripDescriptor, current_stop_sequence: option.Option(Int), current_status: VehicleStopStatus, timestamp: UnixTime, stop_id: String, )Realtime positioning information for a given vehicle.
Arguments
- trip
-
The Trip that this vehicle is serving. Can be empty or partial if the vehicle can not be identified with a given trip instance.
- current_stop_sequence
-
The stop sequence index of the current stop. The meaning of current_stop_sequence (i.e., the stop that it refers to) is determined by current_status.
- current_status
-
If current_status is missing IN_TRANSIT_TO is assumed.
- stop_id
-
Identifies the current stop. The value must be the same as in stops.txt in the corresponding GTFS feed.
-
Alert( active_periods: List(TimeRange), informed_entities: List(EntitySelector), header_text: TranslatedString, description_text: option.Option(TranslatedString), mercury_alert: option.Option(MercuryAlert), )An alert, indicating some sort of incident in the public transit network.
Arguments
- active_periods
-
Time when the alert should be shown to the user. If missing, the alert will be shown as long as it appears in the feed. If multiple ranges are given, the alert will be shown during all of them.
- informed_entities
-
Entities whose users we should notify of this alert.
- header_text
-
A headline to describe the high-level impacts of a disruption. Headlines are capped at 160 characters.
Each headline is published with two translations:
- “en” headlines contain brackets around objects the MTA represents with symbology such as a route bullet or ADA icon. (e.g. ”Delays on the [F] [G] trains.”)
- “en-html” headlines contain both brackets for symbology and HTML to allow for basic formatting paragraphs, links, and other text styling.
- description_text
-
Provides full details of a disruption’s impacts. Details do not have a character limit. Description_text is published with two translations:
- “en” description_text contains plain text with brackets around objects the MTA represents with symbology such as a route bullet or ADA icon. (e.g. ”Delays on the [F] [G] trains.”)
- “en-html” description_text contains both brackets for symbology and HTML to allow for basic formatting paragraphs, links, and other text styling.
- mercury_alert
-
Mercury-specific alert information
Metadata about a feed, included in feed messages.
pub type FeedHeader {
FeedHeader(
gtfs_realtime_version: String,
timestamp: UnixTime,
nyct: NyctHeader,
)
}
Constructors
-
FeedHeader( gtfs_realtime_version: String, timestamp: UnixTime, nyct: NyctHeader, )Arguments
- gtfs_realtime_version
-
Version of the feed specification. The current version is 2.0. Valid versions are “2.0”, “1.0”.
- timestamp
-
This timestamp identifies the moment when the content of this feed has been created (in server time).
- nyct
-
NYCT Subway extensions for the feed header
The contents of a feed message. A feed is a continuous stream of feed messages. Each message in the stream is obtained as a response to an appropriate HTTP GET request. A realtime feed is always defined with relation to an existing GTFS feed. All the entity ids are resolved with respect to the GTFS feed. Note that “required” and “optional” as stated in this file refer to Protocol Buffer cardinality, not semantic cardinality. See reference.md at https://github.com/google/transit/tree/master/gtfs-realtime for field semantic cardinality.
pub type FeedMessage {
FeedMessage(header: FeedHeader, entity: List(FeedEntity))
}
Constructors
-
FeedMessage(header: FeedHeader, entity: List(FeedEntity))Arguments
- header
-
Metadata about this feed and feed message.
- entity
-
Contents of the feed.
This is an extension to the Alert that contains Mercury-specific information
pub type MercuryAlert {
MercuryAlert(
created_at: UnixTime,
updated_at: UnixTime,
alert_type: String,
station_alternatives: List(
#(EntitySelector, TranslatedString),
),
display_before_active: Int,
human_readable_active_period: option.Option(TranslatedString),
clone_id: option.Option(String),
)
}
Constructors
-
MercuryAlert( created_at: UnixTime, updated_at: UnixTime, alert_type: String, station_alternatives: List(#(EntitySelector, TranslatedString)), display_before_active: Int, human_readable_active_period: option.Option(TranslatedString), clone_id: option.Option(String), )Arguments
- created_at
-
Time when the message was created in Mercury (not to be confused with active_period start time.
- updated_at
-
Time when the message was last updated in Mercury.
- alert_type
-
The service status category for the alert (e.g. “Delays”).
While there are a standard set of service status categories, the MTA may add/remove/change them so data consumers should treat this as a free text field.
- station_alternatives
-
An array of station alternatives for some planned work messages. Each station has an affectedEntity with agencyId and stopId and a notes object consisting of TranslatedStrings
- display_before_active
-
Number of seconds before the active_period start time that the MTA sets a message to appear on our homepage to give customers advance notice of a planned service change. The value for service alerts is 0 and the default value for planned work messages is 3600.
- human_readable_active_period
-
A human-readable summary of the dates and times when a planned service change impacts customers.
- clone_id
-
If the message was duplicated from a previous message, this is the id of the original message.
This is an extension to the EntitySelector used for Mercury-specific entity information
pub type MercuryEntitySelector {
MercuryEntitySelector(sort_order: String)
}
Constructors
-
MercuryEntitySelector(sort_order: String)Arguments
- sort_order
-
Priority of the affected entity. Format is GTFS-ID:Priority (e.g. MTASBWY:G:16. Priority and NyctBusPriority enums are used to determine the priority number based on the alert type. Priority is in ascending order.
NYCT Subway extensions for the feed header
pub type NyctHeader {
NyctHeader(
version: String,
trip_replacement_periods: List(TripReplacementPeriod),
)
}
Constructors
-
NyctHeader( version: String, trip_replacement_periods: List(TripReplacementPeriod), )Arguments
- version
-
Version of the NYCT Subway extensions The current version is 1.0
- trip_replacement_periods
-
For the NYCT Subway, the GTFS-realtime feed replaces any scheduled trip within the trip_replacement_period. This feed is a full dataset, it contains all trips starting in the trip_replacement_period. If a trip from the static GTFS is not found in the GTFS-realtime feed, it should be considered as cancelled. The replacement period can be different for each route, so here is a list of the routes where the trips in the feed replace all scheduled trips within the replacement period.
NYCT Subway extensions for the stop time update
pub type NyctStopTimeUpdate {
NyctStopTimeUpdate(
scheduled_track: option.Option(String),
actual_track: option.Option(String),
)
}
Constructors
-
NyctStopTimeUpdate( scheduled_track: option.Option(String), actual_track: option.Option(String), )Arguments
- scheduled_track
-
Provides the planned station arrival track. The following is the Manhattan track configurations: 1: southbound local 2: southbound express 3: northbound express 4: northbound local
In the Bronx (except Dyre Ave line) M: bi-directional express (in the AM express to Manhattan, in the PM express away).
The Dyre Ave line is configured: 1: southbound 2: northbound 3: bi-directional
- actual_track
-
This is the actual track that the train is operating on and can be used to determine if a train is operating according to its current schedule (plan).
The actual track is known only shortly before the train reaches a station, typically not before it leaves the previous station. Therefore, the NYCT feed sets this field only for the first station of the remaining trip.
Different actual and scheduled track is the result of manually rerouting a train off it scheduled path. When this occurs, prediction data may become unreliable since the train is no longer operating in accordance to its schedule. The rules engine for the ‘countdown’ clocks will remove this train from all schedule stations.
pub type NyctTripDescriptor {
NyctTripDescriptor(
train_id: option.Option(String),
is_assigned: Bool,
)
}
Constructors
-
NyctTripDescriptor( train_id: option.Option(String), is_assigned: Bool, )Arguments
- train_id
-
The nyct_train_id is meant for internal use only. It provides an easy way to associated GTFS-realtime trip identifiers with NYCT rail operations identifier
The ATS office system assigns unique train identification (Train ID) to each train operating within or ready to enter the mainline of the monitored territory. An example of this is 06 0123+ PEL/BBR and is decoded as follows:
The first character represents the trip type designator. 0 identifies a scheduled revenue trip. Other revenue trip values that are a result of a change to the base schedule include; [= reroute], [/ skip stop], [$ turn train] also known as shortly lined service.
The second character 6 represents the trip line i.e. number 6 train The third set of characters identify the decoded origin time. The last character may be blank “on the whole minute” or + “30 seconds”
Note: Origin times will not change when there is a trip type change. This is followed by a three character “Origin Location” / “Destination Location”
- is_assigned
-
This trip has been assigned to a physical train. If true, this trip is already underway or most likely will depart shortly.
Train Assignment is a function of the Automatic Train Supervision (ATS) office system used by NYCT Rail Operations to monitor and track train movements. ATS provides the ability to “assign” the nyct_train_id attribute when a physical train is at its origin terminal. These assigned trips have the is_assigned field set in the TripDescriptor.
When a train is at a terminal but has not been given a work program it is declared unassigned and is tagged as such. Unassigned trains can be moved to a storage location or assigned a nyct_train_id when a determination for service is made.
Timing information for a single predicted event (either arrival or departure). Timing consists of delay and/or estimated time, and uncertainty.
- delay should be used when the prediction is given relative to some existing schedule in GTFS.
- time should be given whether there is a predicted schedule or not. If both time and delay are specified, time will take precedence (although normally, time, if given for a scheduled trip, should be equal to scheduled time in GTFS + delay).
Uncertainty applies equally to both time and delay. The uncertainty roughly specifies the expected error in true delay (but note, we don’t yet define its precise statistical meaning). It’s possible for the uncertainty to be 0, for example for trains that are driven under computer timing control.
pub type StopTimeEvent {
StopTimeEvent(time: UnixTime)
}
Constructors
-
StopTimeEvent(time: UnixTime)Arguments
- time
-
Event as absolute time.
Realtime update for arrival and/or departure events for a given stop on a trip. Updates can be supplied for both past and future events. The producer is allowed, although not required, to drop past events.
pub type StopTimeUpdate {
StopTimeUpdate(
arrival: option.Option(StopTimeEvent),
departure: option.Option(StopTimeEvent),
stop_id: String,
nyct: NyctStopTimeUpdate,
)
}
Constructors
-
StopTimeUpdate( arrival: option.Option(StopTimeEvent), departure: option.Option(StopTimeEvent), stop_id: String, nyct: NyctStopTimeUpdate, )Arguments
- stop_id
-
Must be the same as in stops.txt in the corresponding GTFS feed.
A time interval. The interval is considered active at time ‘t’ if ‘t’ is greater than or equal to the start time and less than the end time.
pub type TimeRange {
TimeRange(
start: option.Option(UnixTime),
end: option.Option(UnixTime),
)
}
Constructors
-
TimeRange( start: option.Option(UnixTime), end: option.Option(UnixTime), )Arguments
- start
-
Start time. If missing, the interval starts at minus infinity.
- end
-
End time. If missing, the interval ends at plus infinity.
An internationalized message containing per-language versions of a snippet of text or a URL. One of the strings from a message will be picked up. The resolution proceeds as follows:
- If the UI language matches the language code of a translation, the first matching translation is picked.
- If a default UI language (e.g., English) matches the language code of a translation, the first matching translation is picked.
- If some translation has an unspecified language code, that translation is picked.
pub type TranslatedString {
TranslatedString(translations: List(Translation))
}
Constructors
-
TranslatedString(translations: List(Translation))Arguments
- translations
-
Must contain at least one translation. At most one translation is allowed to have an unspecified language tag.
pub type Translation {
Translation(text: String, language: option.Option(String))
}
Constructors
-
Translation(text: String, language: option.Option(String))Arguments
- text
-
A UTF-8 string containing the message.
- language
-
BCP-47 language code. Can be omitted if the language is unknown or if no i18n is done at all for the feed. At most one translation is allowed to have an unspecified language tag.
pub type TripDescriptor {
TripDescriptor(
trip_id: String,
start_date: option.Option(Date),
route_id: String,
nyct: NyctTripDescriptor,
)
}
Constructors
-
TripDescriptor( trip_id: String, start_date: option.Option(Date), route_id: String, nyct: NyctTripDescriptor, )
pub type TripReplacementPeriod {
TripReplacementPeriod(
route_id: option.Option(String),
replacement_period: UnixTime,
)
}
Constructors
-
TripReplacementPeriod( route_id: option.Option(String), replacement_period: UnixTime, )Arguments
- route_id
-
The replacement period is for this route
- replacement_period
-
The start time is omitted, the end time is currently now + 30 minutes for all routes of the A division
POSIX/Unix time (ie number of seconds since January 1st 1970 00:00:00 UTC).
pub type UnixTime {
UnixTime(Int)
}
Constructors
-
UnixTime(Int)
pub type VehicleStopStatus {
Incoming
Stopped
InTransit
}
Constructors
-
IncomingThe vehicle is just about to arrive at the stop (on a stop display, the vehicle symbol typically flashes).
-
StoppedThe vehicle is standing at the stop.
-
InTransitThe vehicle has departed and is in transit to the next stop.
Values
pub fn feed_message_decoder() -> decode.Decoder(FeedMessage)