MobilityData / gtfs-validator

Canonical GTFS Validator project for schedule (static) files.
https://gtfs-validator.mobilitydata.org/
Apache License 2.0
290 stars 101 forks source link

[REQUEST] Implement no stop sequence duplicate in a trip verification (GTFS rule) #166

Closed maximearmstrong closed 4 years ago

maximearmstrong commented 4 years ago

Is your feature request related to a problem? Please describe. A trip should have no duplicate stops. This is a GTFS rule implemented in Google Python validator and featured in Google Type Error as TYPE_TRIP_WITH_DUPLICATE_STOPS.

Describe the solution you'd like Actual Google GTFS validator behaviour : verifies if there is a duplicate stop sequence in a trip. https://github.com/google/transitfeed/blob/master/transitfeed/trip.py#L575

Describe alternatives you've considered

Additional context Line 205 in Error support priorities https://docs.google.com/spreadsheets/d/1vqe6wq7ctqk1EhYkgtZ0_TbcQ91vccfs2daSjn20BLE/edit#gid=0

brodyFlannigan commented 4 years ago

The spec specifies this rule indirectly, as stop_sequence values must increase, but do not need to be consecutive. A violation of this rule should throw an error.

LeoFrachet commented 4 years ago

The same stop can be twice in the same trip, for example for loop trip. I think the goal of the rule is to not have twice the same stop consecutively

barbeau commented 4 years ago

I agree that the GTFS spec definitely says that stop_sequence is a unique key for the stoptime in a trip - you can't have more than one stoptime with the same stop_sequence in a trip. And you can definitely have more than one occurrence of a stop_id within a trip for loop routes.

However, it's not currently clear to me if you can have the same stop_id consecutively in a trip. I thought you couldn't, and we have a GTFS-rt validator rule "E037 - Sequential stop_time_updates have the same stop_id". However, Metro Transit Minneapolis told me that they have occurrences of this in their GTFS data that they consider valid. It's been on my TODO list to investigate this further but I haven't had a chance.

barbeau commented 4 years ago

@maximearmstrong Could you link to the Python code so we can see exactly what is implemented there?

barbeau commented 4 years ago

Looks like https://github.com/MobilityData/gtfs-validator/issues/161 is checking for duplicate stop_sequence in a trip, so I assume this rule is indeed looking a sequential stop_ids in a trip.

maximearmstrong commented 4 years ago

@barbeau sure, here it is https://github.com/google/transitfeed/blob/master/transitfeed/trip.py#L575

I now realize I did not understand well the rule implemented in the Python validator the first time. #161 verifies if a stop is not duplicated in a trip, while this one verifies stop_sequence is unique in a trip ex. correct : stop_sequence = 1, stop_sequence = 23, stop_sequence = 40, stop_sequence = 50, and not correct : stop_sequence = 1, stop_sequence = 23, stop_sequence = 23, stop_sequence = 50.

So TYPE_TRIP_WITH_DUPLICATE_STOPS is verified by #161, and this one is not linked to any Google Type Error.

maximearmstrong commented 4 years ago

Rule already verified by ProcessedParsedStopTime.