Skip to content

Commit d36f085

Browse files
authored
feat(rtr): add com.mbta.rtr.lightrail-vehicle-deleted, com.mbta.rtr.lightrail-vehicle-updated
Problem: Glides needs information about light rail vehicles to start doing trip assignment on its own. Further outlined here: https://www.notion.so/mbta-downtown-crossing/Glides-Trips-RTR-Inter-dependency-Problem-Statement-185f5d8d11ea80d5a7b5e8c24cb85ce7 Solution: Add com.mbta.rtr.lightrail-vehicle-information message type with all of the necessary information for Glides LRV trip assignment.
2 parents 4c580ea + 0a638f4 commit d36f085

7 files changed

+285
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
sidebar_label: rtr.lightrail-vehicle-deleted
3+
---
4+
5+
import LightRailVehicleDeleted from "@site/examples/rtr-events/LightRailVehicleDeleted.json";
6+
import EventSchemaPath from "@site/src/components/EventSchemaPath.tsx";
7+
import Examples from "@site/src/components/Examples.tsx";
8+
9+
# lightrail-vehicle-deleted
10+
11+
event type: `com.mbta.rtr.lightrail-vehicle-deleted`
12+
13+
Message from RTR indicating that a light rail vehicle has been deleted. Deleted vehicles will no longer appear in GTFS-RT feeds, and RTR will no longer publish other events for deleted vehicles.
14+
15+
RTR deletes a light rail vehicle when 30 minutes have elapsed without any messages pertaining to said vehicle.
16+
17+
Related to [RFC-25](https://github.com/mbta/technology-docs/blob/main/rfcs/accepted/0025-light-rail-trip-model.md).
18+
19+
## Data
20+
21+
Fields in the event's `data`:
22+
23+
- `vehicleId` (string): Unique identifier of the vehicle from OCS. Same `vehicleId` as [com.mbta.rtr.lightrail-vehicle-updated](com.mbta.rtr.lightrail-vehicle-updated#Data).
24+
25+
## Examples
26+
27+
<Examples
28+
examples={[
29+
{ label: "LightRailVehicleDeleted", json: LightRailVehicleDeleted },
30+
]}
31+
/>
32+
33+
## Schema
34+
35+
<EventSchemaPath event="com.mbta.rtr.lightrail-vehicle-deleted" />
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
sidebar_label: rtr.lightrail-vehicle-updated
3+
---
4+
5+
import LightRailVehicleUpdated from "@site/examples/rtr-events/LightRailVehicleUpdated.json";
6+
import EventSchemaPath from "@site/src/components/EventSchemaPath.tsx";
7+
import Examples from "@site/src/components/Examples.tsx";
8+
9+
# lightrail-vehicle-updated
10+
11+
event type: `com.mbta.rtr.lightrail-vehicle-updated`.
12+
13+
Message from RTR indicating information about the location and status of light rail vehicles provided by RTR. RTR sources this information from the OCS and/or the vehicle AVLs.
14+
15+
Related to [RFC-25](https://github.com/mbta/technology-docs/blob/main/rfcs/accepted/0025-light-rail-trip-model.md)
16+
17+
## Data
18+
19+
Fields in the event's `data`:
20+
21+
- `directionId` (integer): Direction in which the vehicle is headed. Derived from the direction in [GTFS's trips.txt](https://gtfs.org/documentation/schedule/reference/#tripstxt).
22+
- `lastAvi` (string): The last AVI code that was emitted from the vehicle. If you are internal to the MBTA, see the [RTR documentation on AVI codes](https://github.com/mbta/rtr/blob/f734e361cb7361ec0cde461add8e1e1bfc938b74/docs/avi_codes.pdf)
23+
- `vehicleId` (string): Unique identifier of the vehicle from OCS
24+
- `routeId` (string): Route that RTR thinks the vehicle is serving. See [GTFS's trips.txt](https://gtfs.org/documentation/schedule/reference/#tripstxt).
25+
- `consist` (array[string]): Array containing car numbers of the train in order
26+
- `orientation` (enum, values: ["AB", "BA"]): Whether the 'rear' or 'front' of each train is facing forward for each train in the consist. B means backward, A means forward
27+
- `nextStopId` (string): Identifier for the next stop that the vehicle is at / approaching. This will be a stop in GTFS parlance (`location_type = 0`), as opposed to a station (`location_type = 1`). See [GTFS's stops.txt documentation.](https://gtfs.org/documentation/schedule/reference/#stopstxt)
28+
- `stopStatus` (enum, values: ["STOPPED_AT", "INCOMING_AT", "IN_TRANSIT_TO"]): What the train is doing in relation to the next stop
29+
- `lat` (number): Most recent latitude of the vehicle
30+
- `lon` (number): Most recent longitude of the vehicle
31+
- `heading` (number): Most recent direction the vehicle is pointing, measuerd in degrees from Magnetic North
32+
33+
## Examples
34+
35+
<Examples
36+
examples={[
37+
{ label: "LightRailVehicleUpdated", json: LightRailVehicleUpdated },
38+
]}
39+
/>
40+
41+
## Schema
42+
43+
<EventSchemaPath event="com.mbta.rtr.lightrail-vehicle-updated" />

docs/events/rtr/index.mdx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
sidebar_label: RTR
3+
sidebar_position: 1
4+
---
5+
6+
import DocCard from "@theme/DocCard";
7+
8+
# RTR Events
9+
10+
Events published by Rapid Transit Realtime (RTR), the service that is responsible for providing predictions for all MBTA subway vehicles. These events all inform consumers (only Glides at the moment) of changes in light rail vehicles.
11+
12+
Related to [RFC-25](https://github.com/mbta/technology-docs/blob/main/rfcs/accepted/0025-light-rail-trip-model.md).
13+
14+
### lightrail-vehicle-updated
15+
16+
Published periodically to broadcast important information about all light rail vehicles that RTR is tracking.
17+
18+
<DocCard
19+
item={{
20+
type: "link",
21+
label: "com.mbta.rtr.lightrail-vehicle-updated",
22+
href: "/events/rtr/com.mbta.rtr.lightrail-vehicle-updated",
23+
docId: "events/rtr/com.mbta.rtr.lightrail-vehicle-updated",
24+
}}
25+
/>
26+
27+
### lightrail-vehicle-deleted
28+
29+
Published when RTR stops tracking a light rail vehicle in to inform consumers that there will no longer be updates for said vehicle.
30+
31+
<DocCard
32+
item={{
33+
type: "link",
34+
label: "com.mbta.rtr.lightrail-vehicle-deleted",
35+
href: "/events/rtr/com.mbta.rtr.lightrail-vehicle-deleted",
36+
docId: "events/rtr/com.mbta.rtr.lightrail-vehicle-deleted",
37+
}}
38+
/>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"data": {
3+
"vehicleId": "G-10023"
4+
},
5+
"id": "1",
6+
"source": "ctd.mbta.com/rtr-1234",
7+
"specversion": "1.0",
8+
"time": "2025-03-12T00:01:00.110000Z",
9+
"type": "com.mbta.rtr.lightrail-vehicle-deleted"
10+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"data": {
3+
"directionId": 1,
4+
"lastAvi": "875",
5+
"vehicleId": "G-10023",
6+
"routeId": "Green-D",
7+
"consist": ["3644", "3862"],
8+
"orientation": "AB",
9+
"nextStopId": "70203",
10+
"stopStatus": "IN_TRANSIT_TO",
11+
"lat": 42.21469,
12+
"lon": -71.03305,
13+
"heading": 26.69
14+
},
15+
"id": "1",
16+
"source": "ctd.mbta.com/rtr-1234",
17+
"specversion": "1.0",
18+
"time": "2025-03-12T00:01:00.110000Z",
19+
"type": "com.mbta.rtr.lightrail-vehicle-updated"
20+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://github.com/mbta/schemas/blob/main/schemas/com.mbta.rtr.lightrail-vehicle-deleted.json",
4+
"type": "object",
5+
"properties": {
6+
"id": {
7+
"$ref": "cloudevents.json#/properties/id",
8+
"examples": ["123abc"]
9+
},
10+
"source": {
11+
"$ref": "cloudevents.json#/properties/source",
12+
"examples": ["mbta.com/rtr-1"]
13+
},
14+
"specversion": {
15+
"const": "1.0",
16+
"$ref": "cloudevents.json#/properties/specversion"
17+
},
18+
"type": {
19+
"const": "com.mbta.rtr.lightrail-vehicle-deleted",
20+
"$ref": "cloudevents.json#/properties/type"
21+
},
22+
"time": {
23+
"$ref": "cloudevents.json#/properties/time"
24+
},
25+
"data": {
26+
"$ref": "#/$defs/datadef"
27+
}
28+
},
29+
"required": ["type", "specversion", "source", "id", "time", "data"],
30+
"$defs": {
31+
"datadef": {
32+
"type": "object",
33+
"required": ["vehicleId"],
34+
"properties": {
35+
"vehicleId": {
36+
"type": "string",
37+
"examples": ["G-10023"]
38+
}
39+
}
40+
}
41+
}
42+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://github.com/mbta/schemas/blob/main/schemas/com.mbta.rtr.lightrail-vehicle-updated.json",
4+
"type": "object",
5+
"properties": {
6+
"id": {
7+
"$ref": "cloudevents.json#/properties/id",
8+
"examples": ["123abc"]
9+
},
10+
"source": {
11+
"$ref": "cloudevents.json#/properties/source",
12+
"examples": ["mbta.com/rtr-1"]
13+
},
14+
"specversion": {
15+
"const": "1.0",
16+
"$ref": "cloudevents.json#/properties/specversion"
17+
},
18+
"type": {
19+
"const": "com.mbta.rtr.lightrail-vehicle-updated",
20+
"$ref": "cloudevents.json#/properties/type"
21+
},
22+
"time": {
23+
"$ref": "cloudevents.json#/properties/time"
24+
},
25+
"data": {
26+
"$ref": "#/$defs/datadef"
27+
}
28+
},
29+
"required": ["type", "specversion", "source", "id", "time", "data"],
30+
"$defs": {
31+
"datadef": {
32+
"type": "object",
33+
"required": [
34+
"directionId",
35+
"lastAvi",
36+
"vehicleId",
37+
"routeId",
38+
"consist",
39+
"orientation",
40+
"nextStopId",
41+
"stopStatus",
42+
"lat",
43+
"lon",
44+
"heading"
45+
],
46+
"properties": {
47+
"directionId": {
48+
"type": "integer",
49+
"enum": [0, 1]
50+
},
51+
"lastAvi": {
52+
"type": "string",
53+
"examples": ["875"]
54+
},
55+
"vehicleId": {
56+
"type": "string",
57+
"examples": ["G-10023"]
58+
},
59+
"routeId": {
60+
"type": "string",
61+
"enum": ["Green-B", "Green-C", "Green-D", "Green-D", "Mattapan"]
62+
},
63+
"consist": {
64+
"type": "array",
65+
"items": {
66+
"type": "string"
67+
},
68+
"examples": [["3644", "3862"]]
69+
},
70+
"orientation": {
71+
"type": "string",
72+
"enum": ["AB", "BA"]
73+
},
74+
"nextStopId": {
75+
"type": "string",
76+
"examples": ["70160", "70161", "70238"]
77+
},
78+
"stopStatus": {
79+
"type": "string",
80+
"enum": ["IN_TRANSIT_TO", "INCOMING_AT", "STOPPED_AT"]
81+
},
82+
"lat": {
83+
"type": "number",
84+
"examples": [42.21469]
85+
},
86+
"lon": {
87+
"type": "number",
88+
"examples": [-71.03305]
89+
},
90+
"heading": {
91+
"type": "number",
92+
"examples": [26.69]
93+
}
94+
}
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)