Skip to content

Commit 79b5870

Browse files
authored
Merge pull request #442 from avatarneil/trips-route-stop-implementation
Add stop references to trips and status_changes
2 parents cfee5bf + 0545510 commit 79b5870

7 files changed

Lines changed: 74 additions & 8 deletions

File tree

general-information.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ All String fields, such as `vehicle_id`, are limited to a maximum of 255 charact
108108

109109
## Stops
110110

111+
**Stops** describe vehicle trip end locations in a pre-designated physical place. They can vary from docking stations with or without charging, corrals with lock-to railings, or suggested parking areas marked with spray paint. **Stops** are used in both [Provider](/provider#stops) (including routes and event locations) and [Agency](/agency#stops) (including telemetry data).
112+
111113
| Field | Type | Required/Optional | Description |
112114
|------------------------|-------------------------------------------------------------|-------------------|----------------------------------------------------------------------------------------------|
113115
| stop_id | UUID | Required | Unique ID for stop |
@@ -133,12 +135,24 @@ All String fields, such as `vehicle_id`, are limited to a maximum of 255 charact
133135

134136
### Stop Status
135137

138+
**Stop Status** returns information about the current status of a **[Stop](#stops)**.
139+
136140
| Field | Type | Required/Optional | Description |
137141
|--------------|---------|-------------------|-----------------------------------------------------|
138142
| is_installed | Boolean | Required | See GBFS [station_status.json][gbfs-station-status] |
139143
| is_renting | Boolean | Required | See GBFS [station_status.json][gbfs-station-status] |
140144
| is_returning | Boolean | Required | See GBFS [station_status.json][gbfs-station-status] |
141145

146+
Example of the **Stop Status** object with properties listed:
147+
148+
```json
149+
{
150+
"is_installed": true,
151+
"is_renting": false,
152+
"is_returning": true
153+
}
154+
```
155+
142156
### GBFS Compatibility
143157

144158
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.
@@ -264,7 +278,7 @@ If an unsupported or invalid version is requested, the API must respond with a s
264278

265279
[agency]: /agency/README.md
266280
[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
281+
[gbfs-station-status]: https://github.com/NABSA/gbfs/blob/master/gbfs.md#station_statusjson
268282
[policy]: /policy/README.md
269283
[provider]: /provider/README.md
270284
[toc]: #table-of-contents

provider/README.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,28 @@ represented as a GeoJSON [`Feature`][geojson-feature] object with a correspondin
120120
}
121121
```
122122

123+
#### Stop-based Geographic Data
124+
125+
When an individual location coordinate measurement corresponds to a [Stop][general-stops],
126+
it must be presented with a `stop_id` property:
127+
128+
```json
129+
{
130+
"type": "Feature",
131+
"properties": {
132+
"timestamp": 1529968782421,
133+
"stop_id": "b813cde2-a41c-4ae3-b409-72ff221e003d"
134+
},
135+
"geometry": {
136+
"type": "Point",
137+
"coordinates": [
138+
-118.46710503101347,
139+
33.9909333514159
140+
]
141+
}
142+
}
143+
```
144+
123145
#### Intersection Operation
124146

125147
For the purposes of this specification, the intersection of two geographic datatypes is defined according to the [`ST_Intersects` PostGIS operation][st-intersects]
@@ -207,13 +229,17 @@ To represent a route, MDS `provider` APIs must create a GeoJSON [`FeatureCollect
207229

208230
Routes must include at least 2 points: the start point and end point. Routes must include all possible GPS or GNSS samples collected by a Provider. Providers may round the latitude and longitude to the level of precision representing the maximum accuracy of the specific measurement. For example, [a-GPS][agps] is accurate to 5 decimal places, [differential GPS][dgps] is generally accurate to 6 decimal places. Providers may round those readings to the appropriate number for their systems.
209231

232+
Trips that start or end at a [Stop][general-stops] must include a `stop_id` property in the first (when starting) and last (when ending) Feature of the `route`. See [Stop-based Geographic Data][stop-based-geo] for more information.
233+
210234
```js
211235
"route": {
212236
"type": "FeatureCollection",
213237
"features": [{
214238
"type": "Feature",
215239
"properties": {
216-
"timestamp": 1529968782421
240+
"timestamp": 1529968782421,
241+
// Required for Trips starting at a Stop
242+
"stop_id": "95084833-6a3f-4770-9919-de1ab4b8989b",
217243
},
218244
"geometry": {
219245
"type": "Point",
@@ -226,7 +252,9 @@ Routes must include at least 2 points: the start point and end point. Routes mus
226252
{
227253
"type": "Feature",
228254
"properties": {
229-
"timestamp": 1531007628377
255+
"timestamp": 1531007628377,
256+
// Required for Trips ending at a Stop
257+
"stop_id": "b813cde2-a41c-4ae3-b409-72ff221e003d"
230258
},
231259
"geometry": {
232260
"type": "Point",
@@ -269,7 +297,7 @@ Unless stated otherwise by the municipality, this endpoint must return only thos
269297
| `event_types` | Enum[] | Required | [Vehicle event(s)][vehicle-events] for state change, allowable values determined by `vehicle_state` |
270298
| `event_time` | [timestamp][ts] | Required | Date/time that event occurred at. See [Event Times][event-times] |
271299
| `publication_time` | [timestamp][ts] | Optional | Date/time that event became available through the status changes endpoint |
272-
| `event_location` | GeoJSON [Point Feature][geo] | Required | |
300+
| `event_location` | GeoJSON [Point Feature][geo] | Required | See also [Stop-based Geographic Data][stop-based-geo] |
273301
| `battery_pct` | Float | Required if Applicable | Percent battery charge of device, expressed between 0 and 1 |
274302
| `trip_id` | UUID | Required if Applicable | Trip UUID (foreign key to Trips API), required if `event_types` contains `trip_start`, `trip_end`, `trip_cancel`, `trip_enter_jurisdiction`, or `trip_leave_jurisdiction` |
275303
| `associated_ticket` | String | Optional | Identifier for an associated ticket inside an Agency-maintained 311 or CRM system |
@@ -319,6 +347,8 @@ Unless stated otherwise by the municipality, this endpoint must return only thos
319347

320348
> Note: As a result of this definition, consumers should query the [trips endpoint][trips] to infer when vehicles enter or leave the municipality boundary.
321349
350+
See also [Stop-based Geographic Data][stop-based-geo].
351+
322352
The schema and datatypes are the same as those defined for [`/status_changes`][status].
323353

324354
**Endpoint:** `/events`
@@ -400,8 +430,8 @@ In addition to the standard [Provider payload wrapper](#response-format), respon
400430
| `last_event_time` | [timestamp][ts] | Required | Date/time when last state change occurred. See [Event Times][event-times] |
401431
| `last_vehicle_state` | Enum | Required | [Vehicle state][vehicle-states] of most recent state change. |
402432
| `last_event_types` | Enum[] | Required | [Vehicle event(s)][vehicle-events] of most recent state change, allowable values determined by `last_vehicle_state`. |
403-
| `last_event_location` | GeoJSON [Point Feature][geo]| Required | Location of vehicle's last event |
404-
| `current_location` | GeoJSON [Point Feature][geo] | Required if Applicable | Current location of vehicle if different from last event, and the vehicle is not currently on a trip |
433+
| `last_event_location` | GeoJSON [Point Feature][geo]| Required | Location of vehicle's last event. See also [Stop-based Geographic Data][stop-based-geo]. |
434+
| `current_location` | GeoJSON [Point Feature][geo] | Required if Applicable | Current location of vehicle if different from last event, and the vehicle is not currently on a trip. See also [Stop-based Geographic Data][stop-based-geo]. |
405435
| `battery_pct` | Float | Required if Applicable | Percent battery charge of device, expressed between 0 and 1 |
406436

407437
[Top][toc]
@@ -417,6 +447,7 @@ In addition to the standard [Provider payload wrapper](#response-format), respon
417447
[event-times]: #event-times
418448
[gbfs]: https://github.com/NABSA/gbfs
419449
[general-information]: /general-information.md
450+
[general-stops]: /general-information.md#stops
420451
[geo]: #geographic-data
421452
[geojson-feature]: https://tools.ietf.org/html/rfc7946#section-3.2
422453
[geojson-feature-collection]: https://tools.ietf.org/html/rfc7946#section-3.3
@@ -432,6 +463,7 @@ In addition to the standard [Provider payload wrapper](#response-format), respon
432463
[status]: #status-changes
433464
[status-schema]: status_changes.json
434465
[stops]: #stops
466+
[stop-based-geo]: #stop-based-geographic-data
435467
[st-intersects]: https://postgis.net/docs/ST_Intersects.html
436468
[toc]: #table-of-contents
437469
[trips]: #trips

provider/events.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"properties": {
7070
"timestamp": {
7171
"$ref": "#/definitions/timestamp"
72+
},
73+
"stop_id": {
74+
"$ref": "#/definitions/uuid"
7275
}
7376
}
7477
},

provider/status_changes.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"properties": {
7070
"timestamp": {
7171
"$ref": "#/definitions/timestamp"
72+
},
73+
"stop_id": {
74+
"$ref": "#/definitions/uuid"
7275
}
7376
}
7477
},

provider/trips.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"properties": {
7070
"timestamp": {
7171
"$ref": "#/definitions/timestamp"
72+
},
73+
"stop_id": {
74+
"$ref": "#/definitions/uuid"
7275
}
7376
}
7477
},

provider/vehicles.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"properties": {
7070
"timestamp": {
7171
"$ref": "#/definitions/timestamp"
72+
},
73+
"stop_id": {
74+
"$ref": "#/definitions/uuid"
7275
}
7376
}
7477
},

schema/generate_schemas.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,16 @@ def provider_schema(endpoint, common_definitions, extra_definitions={}):
325325
title = "MDS GeoJSON Feature Point",
326326
# Only allow GeoJSON Point feature geometry
327327
geometry = { "$ref": definition_id("Point") },
328-
# Point features *must* include a `timestamp` property.
329-
properties = { "timestamp": { "$ref": definition_id("timestamp") } },
328+
properties = {
329+
"timestamp": {
330+
"$ref": definition_id("timestamp")
331+
},
332+
# Locations corresponding to Stops must include a `stop_id` reference
333+
"stop_id": {
334+
"$ref": definition_id("uuid")
335+
}
336+
},
337+
# Point features *must* include the `timestamp`
330338
required = ["timestamp"]
331339
)
332340

0 commit comments

Comments
 (0)