-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup trip times - part B #5525
Cleanup trip times - part B #5525
Conversation
This ensures the normalization is performed even if the mapper is no used.
This creates a new interface TripTimes and rename the old class to RealTimeTripTimes and let the ScheduledTripTimes also implement this interface. This will allow us to wait for an update before an accusal RealTime object is created.
72e5d7b
to
ebbe2fd
Compare
src/main/java/org/opentripplanner/transit/model/timetable/RealTimeTripTimes.java
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesBuilder.java
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesBuilder.java
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimesBuilder.java
Show resolved
Hide resolved
src/main/java/org/opentripplanner/updater/trip/TimetableSnapshotSource.java
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/timetable/TripTimes.java
Show resolved
Hide resolved
src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/timetable/TripTimes.java
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimes.java
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/timetable/ScheduledTripTimes.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/timetable/TripTimes.java
Outdated
Show resolved
Hide resolved
src/ext/java/org/opentripplanner/ext/siri/ModifiedTripBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/framework/DataValidationException.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/framework/Result.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/model/framework/Result.java
Outdated
Show resolved
Hide resolved
@@ -432,12 +430,12 @@ public boolean isValidFor(LocalDate serviceDate) { | |||
// TODO maybe put this is a more appropriate place | |||
public void setServiceCodes(Map<FeedScopedId, Integer> serviceCodes) { | |||
for (TripTimes tt : this.tripTimes) { | |||
tt.setServiceCode(serviceCodes.get(tt.getTrip().getServiceId())); | |||
((RealTimeTripTimes) tt).setServiceCode(serviceCodes.get(tt.getTrip().getServiceId())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this cast going to stay or will it be refactored in a later PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be able to get rid of it.
- In general the updaters should work on RealTimeTripTimes and the API they use should provide them. There is several ways to achieve this - one way is to keep all RT stuff in separate data structures. Then when searching for "a" TripTime we can have a facade witch delegate to both planned and realtime - but there are other options.
- I think we are getting rid of the service-code (keeping serviceIds for reference). But, I want another calendar implementation witch works better with Raptor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good now but I have a question about casting.
Summary
THIS IS PART B, MORE TO COME ...
This clean up the TripTimes and split Scheduled trip-times and RealTime trip-times into different classes inheriting the same interface. This allow us to make the ScheduledTripTimes become immutable and freeze it after the graph is build.
This fixes a minor bug - it is no longer possible to create invalid ScheduledTripTimes - even with broken GTFS data (there was an error in the stop times interpolation).
This PR will validate the first departure-time and the last arrival-time to be within -12 hours and 10 days. If someone has a pattern witch last for more than 10 days we can increase the max limit. The min limit is set to -12 hours to account for time-shifting between time-zones. So, even if a feed can only have positive times, all feeds may not operate in the same time-zone.
This is the second refactoring with respect to trip-times. I will follow up this with more PRs. There are now unused code in these classes - these are left "as is" intentionally. This refactoring introduce a new interface for TripTimes - I have not changed all places to use this interface yet. Also, when the RealTimeTripTimes is in place, then first is the time to remove unused code.
Issue
Second step to fix #5211
Unit tests
Many unit-tests are added and other are updated
Some of the code in ScheduledTripTimeBuilder is commented out, because of problems with FLEX:
Documentation
Does not apply, JavaDoc is updated.
Changelog
This is for most part a refactoring, but the result also fixes a minor bug #5211.
Bumping the serialization version id
✅