Skip to content

Commit 8912442

Browse files
authored
Merge pull request #427 from avatarneil/stops-specification
Add MDS Stops RT Specification (Agency & Provider)
2 parents d9ffa25 + 716680d commit 8912442

3 files changed

Lines changed: 120 additions & 16 deletions

File tree

agency/README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This specification contains a collection of RESTful APIs used to specify the dig
1414
* [Vehicle Events](#vehicle---event)
1515
* [Vehicles Telemetry](#vehicles---telemetry)
1616
* [Telemetry Data](#telemetry-data)
17+
* [Stops](#stops)
1718

1819
## General information
1920

@@ -231,17 +232,47 @@ A standard point of vehicle telemetry. References to latitude and longitude impl
231232
| `gps.hdop` | Float | Required if Available | Horizontal GPS or GNSS accuracy value (see [hdop][hdop]) |
232233
| `gps.satellites` | Integer | Required if Available | Number of GPS or GNSS satellites
233234
| `charge` | Float | Required if Applicable | Percent battery charge of vehicle, expressed between 0 and 1 |
235+
| `stop_id` | UUID | Required if Applicable | Stop that the vehicle is currently located at. Only applicable for _docked_ Micromobility. See [Stops][stops] |
236+
237+
## Stops
238+
239+
The `/stops` endpoint allows an agency to register Stops.
240+
241+
**Endpoint:** `/stops`
242+
**Method:** `POST`
243+
**[Beta feature][beta]:** Yes (as of 1.0.0)
244+
**Request Body**: An array of [Stops][stops]
245+
246+
**Endpoint:** `/stops`
247+
**Method:** `PUT`
248+
**[Beta feature][beta]:** Yes (as of 1.0.0)
249+
**Request Body**: An array of subsets of [Stop][stops] information, where the permitted subset fields are defined as:
250+
251+
| Field | Required/Optional | Description |
252+
|---------------------|-------------------|---------------------------------------------|
253+
| stop_id | Required |See [Stops][stops] |
254+
| status | Optional |See [Stops][stops] |
255+
| num_spots_disabled | Optional |See [Stops][stops] |
256+
257+
**Endpoint:** `/stops/:stop_id`
258+
**Method:** `GET`
259+
**[Beta feature][beta]:** Yes (as of 1.0.0)
260+
**`data` Payload:** `{ "stops": [] }`, an array of [Stops][stops]
261+
262+
In the case that a `stop_id` query parameter is specified, the `stops` array returned will only have one entry. In the case that no `stop_id` query parameter is specified, all stops will be returned.
234263

235264
[Top][toc]
236265

266+
[beta]: /general-information.md#beta-features
237267
[general]: /general-information.md
238268
[error-messages]: /general-information.md#error-messages
239269
[hdop]: https://support.esri.com/en/other-resources/gis-dictionary/term/358112bd-b61c-4081-9679-4fca9e3eb926
240270
[propulsion-types]: /general-information.md#propulsion-types
241271
[responses]: /general-information.md#responses
272+
[stops]: /general-information#stops
242273
[toc]: #table-of-contents
243274
[ts]: /general-information.md#timestamps
244275
[vehicle-types]: /general-information.md#vehicle-types
245276
[vehicle-states]: /general-information.md#vehicle-states
246277
[vehicle-events]: /general-information.md#vehicle-state-events
247-
[versioning]: /general-information.md#versioning
278+
[versioning]: /general-information.md#versioning

general-information.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This document contains specifications that are shared between the various MDS AP
1212
* [Responses](#responses)
1313
* [Error Messages](#error-messages)
1414
* [Strings](#strings)
15+
* [Stops](#stops)
1516
* [Timestamps](#timestamps)
1617
* [UUIDs](#uuids)
1718
* [Vehicle States](#vehicle-states)
@@ -43,10 +44,10 @@ If the currency field is null, USD cents is implied.
4344

4445
Defining terminology and abbreviations used throughout MDS.
4546

46-
- **API** - Application Programming Interface - A function or set of functions that allow one software application to access or communicate with features of a different software application or service.
47-
- **API Endpoint** - A point at which an API connects with a software application or service.
48-
- **DOT** - Department of Transportation, usually a city-run agency.
49-
- **PROW** - Public Right of Way - the physical infrastructure reserved for transportation purposes, examples include sidewalks, curbs, bike lanes, transit lanes and stations, traffic lanes and signals, and public parking.
47+
* **API** - Application Programming Interface - A function or set of functions that allow one software application to access or communicate with features of a different software application or service.
48+
* **API Endpoint** - A point at which an API connects with a software application or service.
49+
* **DOT** - Department of Transportation, usually a city-run agency.
50+
* **PROW** - Public Right of Way - the physical infrastructure reserved for transportation purposes, examples include sidewalks, curbs, bike lanes, transit lanes and stations, traffic lanes and signals, and public parking.
5051

5152
[Top][toc]
5253

@@ -105,6 +106,45 @@ All String fields, such as `vehicle_id`, are limited to a maximum of 255 charact
105106

106107
[Top][toc]
107108

109+
## Stops
110+
111+
| Field | Type | Required/Optional | Description |
112+
|------------------------|-------------------------------------------------------------|-------------------|----------------------------------------------------------------------------------------------|
113+
| stop_id | UUID | Required | Unique ID for stop |
114+
| name | String | Required | Name of stop |
115+
| last_reported | Timestamp | Required | Date/Time that the stop was last updated |
116+
| location | GeoJSON [Point Feature](provider/README.md#geographic-data) | Required | Location of the Stop |
117+
| status | [Stop Status](#stop-status) | Required | Object representing the status of the Stop. See [Stop Status](#stop-status). |
118+
| capacity | {vehicle_type: number} | Required | Number of total spaces per vehicle_type |
119+
| num_vehicles_available | {vehicle_type: number} | Required | How many vehicles are available per vehicle_type at this stop? |
120+
| num_vehicles_disabled | {vehicle_type: number} | Required | How many vehicles are unavailable/reserved per vehicle_type at this stop? |
121+
| managed_by | UUID | Optional | `provider_id` for the provider which manages this stop. null/undefined if city managed. |
122+
| geography_id | UUID | Optional | Pointer to the Geography that represents the Stop geospatially |
123+
| region_id | string | Optional | ID of the region where station is located, see [GBFS Station Information][gbfs-station-info] |
124+
| short_name | String | Optional | Abbreviated stop name |
125+
| address | String | Optional | Postal address (useful for directions) |
126+
| post_code | String | Optional | Postal code (e.g. `10036`) |
127+
| rental_methods | [Enum][gbfs-station-info] | Optional | Payment methods accepted at stop, see [GBFS Rental Methods][gbfs-station-info] |
128+
| cross_street | String | Optional | Cross street of where the station is located. |
129+
| num_spaces_available | {vehicle_type: number} | Optional | How many spaces are free to be populated with vehicles at this stop? |
130+
| num_spaces_disabled | {vehicle_type: number} | Optional | How many spaces are disabled and unable to accept vehicles at this stop? |
131+
| parent_stop | UUID | Optional | Describe a basic hierarchy of stops (e.g.a stop inside of a greater stop) |
132+
| devices | UUID[] | Optional | List of device_ids for vehicles which are currently at this stop |
133+
134+
### Stop Status
135+
136+
| Field | Type | Required/Optional | Description |
137+
|--------------|---------|-------------------|-----------------------------------------------------|
138+
| is_installed | Boolean | Required | See GBFS [station_status.json][gbfs-station-status] |
139+
| is_renting | Boolean | Required | See GBFS [station_status.json][gbfs-station-status] |
140+
| is_returning | Boolean | Required | See GBFS [station_status.json][gbfs-station-status] |
141+
142+
### GBFS Compatibility
143+
144+
Some of the fields in the `Stops` definition are using notions which are currently not in MDS, such as `rental_methods`. These fields are included for compatibility with GBFS.
145+
146+
[Top][toc]
147+
108148
## Timestamps
109149

110150
A `timestamp` refers to integer milliseconds since Unix epoch.
@@ -183,7 +223,6 @@ Note that to handle out-of-order events, the validity of the prior-state shall n
183223
The *State Machine Diagram* shows how the `vehicle_state` and `event_type` relate to each other and how vehicles can transition between states. See [Google Slides](https://docs.google.com/presentation/d/1Ar2-ju8YlddSsTATvQw4YjsSa5108XtidtnJNk-UAfA/edit) for the source file.
184224
![MDS State Machine Diagram](/MDS-state-machine-diagram.svg)
185225

186-
187226
[Top][toc]
188227

189228
## Vehicle Types
@@ -224,6 +263,8 @@ If an unsupported or invalid version is requested, the API must respond with a s
224263
[Top][toc]
225264

226265
[agency]: /agency/README.md
266+
[gbfs-station-info]: https://github.com/NABSA/gbfs/blob/master/gbfs.md#station_informationjson
267+
[gbfs-station-status]: https://github.com/NABSA/gbfs/blob/v2.1-RC/gbfs.md#station_statusjson
227268
[policy]: /policy/README.md
228269
[provider]: /provider/README.md
229270
[toc]: #table-of-contents

provider/README.md

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ This specification contains a data standard for *mobility as a service* provider
99
* [Status Changes][status]
1010
* [Realtime Data](#realtime-data)
1111
* [GBFS](#GBFS)
12+
* [Data Latency Requirements][data-latency]
1213
* [Events][events]
14+
* [Stops][stops]
1315
* [Vehicles][vehicles]
1416

1517
## General Information
@@ -296,9 +298,20 @@ GBFS 2.0 includes some changes that may make it less useful for regulatory purpo
296298

297299
[Top][toc]
298300

301+
### Data Latency Requirements
302+
303+
The data returned by a near-realtime endpoint should be as close to realtime as possible, but in no case should it be more than 5 minutes out-of-date. Near-realtime endpoints must contain `last_updated` and `ttl` properties in the top-level of the response body. These properties are defined as:
304+
305+
Field Name | Required | Defines
306+
--------------------| ----------| ----------
307+
last_updated | Yes | Timestamp indicating the last time the data in this feed was updated
308+
ttl | Yes | Integer representing the number of milliseconds before the data in this feed will be updated again (0 if the data should always be refreshed).
309+
310+
[Top][toc]
311+
299312
### Events
300313

301-
The `/events` endpoint is a near-ish real-time feed of status changes, designed to give access to as recent as possible series of events.
314+
The `/events` endpoint is a near-realtime feed of status changes, designed to give access to as recent as possible series of events.
302315

303316
The `/events` endpoint functions similarly to `/status_changes`, but shall not included data older than 2 weeks (that should live in `/status_changes.`)
304317

@@ -327,13 +340,37 @@ Should either side of the requested time range be missing, `/events` shall retur
327340

328341
Should either side of the requested time range be greater than 2 weeks before the time of the request, `/events` shall return a `400 Bad Request` error.
329342

343+
### Stops
344+
345+
Stop information should be updated on a near-realtime basis by providers who operate _docked_ mobility devices in a given municipality.
346+
347+
In addition to the standard [Provider payload wrapper](#response-format), responses from this endpoint should contain the last update timestamp and amount of time until the next update in accordance with the [Data Latency Requirements][data-latency]:
348+
349+
```json
350+
{
351+
"version": "x.y.z",
352+
"data": {
353+
"stops": []
354+
},
355+
"last_updated": "12345",
356+
"ttl": "12345"
357+
}
358+
```
359+
360+
**Endpoint:** `/stops/:stop_id`
361+
**Method:** `GET`
362+
**[Beta feature][beta]:** Yes (as of 1.0.0)
363+
**`data` Payload:** `{ "stops": [] }`, an array of [Stops](/general-information.md#stop)
364+
365+
In the case that a `stop_id` query parameter is specified, the `stops` array returned will only have one entry. In the case that no `stop_id` query parameter is specified, all stops will be returned.
366+
330367
[Top][toc]
331368

332369
### Vehicles
333370

334-
The `/vehicles` endpoint returns the current status of vehicles on the PROW. Only vehicles that are currently in available, unavailable, or reserved states should be returned in this payload. Data in this endpoint should reconcile with data from the `/status_changes` enpdoint. The data returned by this endpoint should be as close to realtime as possible, but in no case should it be more than 5 minutes out-of-date. As with other MDS APIs, `/vehicles` is intended for use by regulators, not by the general public. It does not replace the role of a [GBFS][gbfs] feed in enabling consumer-facing applications.
371+
The `/vehicles` endpoint returns the current status of vehicles on the PROW. Only vehicles that are currently in available, unavailable, or reserved states should be returned in this payload. Data in this endpoint should reconcile with data from the `/status_changes` enpdoint. As with other MDS APIs, `/vehicles` is intended for use by regulators, not by the general public. It does not replace the role of a [GBFS][gbfs] feed in enabling consumer-facing applications.
335372

336-
In addition to the standard [Provider payload wrapper](#response-format), responses from this endpoint should contain the last update timestamp and amount of time until the next update:
373+
In addition to the standard [Provider payload wrapper](#response-format), responses from this endpoint should contain the last update timestamp and amount of time until the next update in accordance with the [Data Latency Requirements][data-latency]:
337374

338375
```json
339376
{
@@ -346,13 +383,6 @@ In addition to the standard [Provider payload wrapper](#response-format), respon
346383
}
347384
```
348385

349-
Where `last_updated` and `ttl` are defined as follows:
350-
351-
Field Name | Required | Defines
352-
--------------------| ----------| ----------
353-
last_updated | Yes | Timestamp indicating the last time the data in this feed was updated
354-
ttl | Yes | Integer representing the number of milliseconds before the data in this feed will be updated again (0 if the data should always be refreshed).
355-
356386
**Endpoint:** `/vehicles`
357387
**Method:** `GET`
358388
**[Beta feature][beta]:** Yes (as of 0.4.1)
@@ -379,6 +409,7 @@ ttl | Yes | Integer representing the number of millisecond
379409
[agps]: https://en.wikipedia.org/wiki/Assisted_GPS
380410
[beta]: /general-information.md#beta
381411
[costs-and-currencies]: /general-information.md#costs-and-currencies
412+
[data-latency]: #data-latency-requirements
382413
[decimal-degrees]: https://en.wikipedia.org/wiki/Decimal_degrees
383414
[dgps]: https://en.wikipedia.org/wiki/Differential_GPS
384415
[events]: #events
@@ -400,6 +431,7 @@ ttl | Yes | Integer representing the number of millisecond
400431
[responses]: /general-information.md#responses
401432
[status]: #status-changes
402433
[status-schema]: dockless/status_changes.json
434+
[stops]: #stops
403435
[st-intersects]: https://postgis.net/docs/ST_Intersects.html
404436
[toc]: #table-of-contents
405437
[trips]: #trips

0 commit comments

Comments
 (0)