osm-ToniE / ptna

Public Transport Network Analysis for OSM
GNU General Public License v3.0
19 stars 5 forks source link

Bug in handling re-used shape_ids #139

Closed JesseWeinstein closed 9 months ago

JesseWeinstein commented 9 months ago

I've observed that, for GTFS data that has two different sets of stops that use the same shape_id, PTNA behaves incorrectly. Here's an example:

https://ptna.openstreetmap.de/gtfs/US/trips.php?feed=US-MA-MBTA&release_date=2023-09-01&route_id=CR-Fitchburg

Note that this shows 4 route variants.

However, there are actually two different sets of stops that use the same shape_id:

https://ptna.openstreetmap.de/gtfs/US/single-trip.php?feed=US-MA-MBTA&release_date=2023-09-01&trip_id=CR-595163-1404 https://ptna.openstreetmap.de/gtfs/US/single-trip.php?feed=US-MA-MBTA&release_date=2023-09-01&trip_id=CR-606471-420

And linking to the shape_id just picks one of them, arbitrarily:

https://ptna.openstreetmap.de/gtfs/US/single-trip.php?feed=US-MA-MBTA&release_date=2023-09-01&shape_id=9840003

It probably should show an error message, and link to the two different possibilities.

osm-ToniE commented 9 months ago

Thanks for reporting this.

In this particular case, the shape data of the second trip is wrong. https://ptna.openstreetmap.de/gtfs/US/single-trip.php?feed=US-MA-MBTA&release_date=2023-09-01&trip_id=CR-606471-420 if you have a look on the map west of stop #1. In this case, GTFS analysis could report that stop #1 is too far away from shape point #1 - or in general: a stop is quite far away from the closest shape point.

Anyway, the issue is valid as for, for example, an express bus skipping every second stop of a regular bus using the same route, having even different route_ids.

JesseWeinstein commented 9 months ago

Yeah, I agree that in this example, the GTFS data is wrong. But as you said, it does show an example of odd/wrong behavior by PTNA, with regards to distinguishing the different route variants.

osm-ToniE commented 9 months ago

After a deeper analysis, it splits into several different issues

If a shape_id is used by more than one trip_id PTNA should be able to handle that:

osm-ToniE commented 9 months ago

PTNA will now link to the page 'shape.php?...&shape_id=...' (instead of 'single-trip.php?...&shape_id=...') and this new page will handle the stuff showing the shape only, printing the trip(s) (as URL) which follow this route.

There are no other checks. Maybe in the future, PTNA may raise an error/note when only "gtfs:shape_id" (and not gtfs:trip_id*) is set in a route relation and shape_id is ambiguous.