Fix consolidation stop returning original stop ID. #6156
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR has two changes to fix #6032 .
Fix a core issue of Timetable not linking back to the referenced TripPattern
The bug shows from GraphQL in the sense that the stops returned by the pattern are the primary stops, but once the StopTimes are loaded from the timetable, the stops returned are the original, secondary stops.
In the original core code, the Timetable links back to TripPattern which is supposed to create a circular reference as commented. However, it isn't true once the TripPattern is copied. The change to core code makes sure that Timetable instances are never shared across multiple TripPattern instances, and each Timetable instance has a link back to the owning TripPattern.
The
sameAs
method in TripPattern is updated to work on content equality of the timetable, instead of theequals()
method, which can't be overridden because timetable is mutable and is placed in the set, which requires identity equality.Use the primary stop object in the legs even if the secondary stop names are to be used.
This allows clients to programmatically query the stop data, while showing the secondary stop names to the user.
Unit tests
Added for static timetables. However, real-time updates with consolidated stops aren't tested yet.
Documentation
None.