google / google/transit

stop_times.shapes_dist_traveled shouldn't be defined if the trip doesn't have shapes associated

Open
#394 8 comments 0 reactions 0 assignees View on GitHub
Change type: Non-Functional GTFS Schedule
Dominant language
No language data
Stars
1.1k
Forks
225
Avg merge
7d 17h
Merged PRs (30d)
3

Description

## Context
The spec definition of `stop_times.shapes_dist_traveled` says ([reference](https://gtfs.org/schedule/reference/#stop_timestxt)):

> Actual distance traveled along the associated shape, from the first stop to the stop specified in this record. This field specifies how much of the shape to draw between any two stops during a trip. Must be in the same units used in [shapes.txt](https://gtfs.org/schedule/reference/#shapestxt).

We've observed cases where a `stop_times.shapes_dist_traveled` is specified for trips that don't have a shape associated (no `shape_id` for the `trip_id` referenced in `stop_times.txt`).

trips.txt
| route_id | service_id | trip_id | shape_id |
|----------|------------|---------|----------|
| route_a | regular | trip_1 | |
| route_a | regular | trip_2 | |
| route_a | regular | trip_3 | |

stop_times.txt
| trip_id | stop_id | stop_sequence | shape_dist_traveled |
|---------|---------|---------------|---------------------|
| trip_1 | stop_3 | 3 | 0 |
| trip_1 | stop_4 | 4 | 298 |
| trip_1 | stop_5 | 5 | 1029 |

Although this doesn't break anything, it seems like it's never intentional, and could potentially mean that a shape was intended to be associated.

## Proposed solution
We would like to amend the specification with a "should" statement and add a check in the [Canonical GTFS Schedule Validator](https://gtfs-validator.mobilitydata.org/) with a WARNING severity level.

The new statement could look like this:

> `shape_dist_traveled` should not be specified if the `trip_id` value does not have a `shape_id` defined in `trips.txt`.

### Questions we'd like the community's input on before proposing a spec amendment
- Are we in agreement that this should be flagged as a WARNING?
- Do we also need`shapes.shape_dist_traveled` to be defined to make use of `stop_times.shape_distance_traveled`?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.