-
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
Fix arrive by filtering for on-street/flex itineraries #6050
Merged
leonardehrenfried
merged 39 commits into
opentripplanner:dev-2.x
from
ibi-group:arrive-by-filtering
Oct 11, 2024
Merged
Changes from 29 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
c35c98b
Make it explicit which itineraries are timeWindowAware
leonardehrenfried 9b161fb
Implement filtering of search window aware itineraries
leonardehrenfried 8d8566e
Add flex time windows in test builder
leonardehrenfried 9ba36ed
Flesh out tests
leonardehrenfried e706076
Fix spelling in paging README
leonardehrenfried cf5266e
Add Javadoc for DirectStreetRouter, FilterTransitWhenStreetModeIsEmpty
leonardehrenfried f61cf33
Add documentation why applying the page cursor unsets the direct mode
leonardehrenfried a851e50
Remove outdated deprecation comment
leonardehrenfried 1a5a388
Make test more comprehensive
leonardehrenfried 318ea2f
Add filter just for direct flex itineraries
leonardehrenfried d37c51c
Add test for FlexWindowFilter
leonardehrenfried 4c11b2a
Merge remote-tracking branch 'upstream/dev-2.x' into arrive-by-filtering
leonardehrenfried 0538587
Extract factory methods for creating itineraries
leonardehrenfried c2a5310
Apply suggestions from code review
leonardehrenfried a6098d7
Rename isFlexAndWalkOnly to isDirectFlex
leonardehrenfried 15faf80
Update Javadoc
leonardehrenfried f9c3add
Rename method
leonardehrenfried a6d11a5
Merge remote-tracking branch 'upstream/dev-2.x' into arrive-by-filtering
leonardehrenfried 07d1c5c
Add setting for turning direct flex filter off
leonardehrenfried d1961b4
Add test for switching filter off
leonardehrenfried 744017f
Improve documentation
leonardehrenfried b64c5da
Update src/main/java/org/opentripplanner/routing/algorithm/filterchai…
leonardehrenfried aca7ccd
Update src/main/java/org/opentripplanner/routing/algorithm/raptoradap…
leonardehrenfried 442840b
Apply suggestions from code review
leonardehrenfried aa153b7
Check if itinerary contains flex
leonardehrenfried ac53bc0
Fix time notation in test
leonardehrenfried ef22007
Merge remote-tracking branch 'upstream/dev-2.x' into arrive-by-filtering
leonardehrenfried 9ec11be
Fine-tune documentation
leonardehrenfried 023c693
Merge remote-tracking branch 'upstream/dev-2.x' into arrive-by-filtering
leonardehrenfried fca7ba9
Filter flex resuls also by sort order
leonardehrenfried 9e293e8
Update src/main/java/org/opentripplanner/routing/algorithm/filterchai…
leonardehrenfried 483a04f
Add comment
leonardehrenfried aa7334e
Rename config parameter
leonardehrenfried 4557498
Change logic of arrive by filters
leonardehrenfried 4a519e4
Fix formatting
leonardehrenfried 3169cef
Fix documentation
leonardehrenfried ce36b34
Update src/main/java/org/opentripplanner/routing/algorithm/filterchai…
leonardehrenfried c35532c
Apply suggestions from code review
leonardehrenfried 9cb2f4e
Update documentation
leonardehrenfried File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../opentripplanner/routing/algorithm/filterchain/filters/system/FlexSearchWindowFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.opentripplanner.routing.algorithm.filterchain.filters.system; | ||
|
||
import java.time.Instant; | ||
import java.util.function.Predicate; | ||
import org.opentripplanner.model.plan.Itinerary; | ||
import org.opentripplanner.routing.algorithm.filterchain.framework.spi.RemoveItineraryFlagger; | ||
|
||
/** | ||
* The flex router doesn't use the transit router's time window but nevertheless using it | ||
leonardehrenfried marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* for filtering is useful when combining flex with transit. | ||
* <p> | ||
* The flex router also searches the previous day (arrive by) or the next one (depart after). | ||
* If you didn't filter the flex results by something you could get yesterday's or tomorrow's | ||
* trips where you would not expect it. | ||
*/ | ||
public class FlexSearchWindowFilter implements RemoveItineraryFlagger { | ||
|
||
public static final String TAG = "outside-flex-window"; | ||
leonardehrenfried marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private final Instant earliestDepartureTime; | ||
|
||
public FlexSearchWindowFilter(Instant earliestDepartureTime) { | ||
this.earliestDepartureTime = earliestDepartureTime; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return TAG; | ||
} | ||
|
||
@Override | ||
public Predicate<Itinerary> shouldBeFlaggedForRemoval() { | ||
return it -> { | ||
if (it.isDirectFlex()) { | ||
var time = it.startTime().toInstant(); | ||
return time.isBefore(earliestDepartureTime); | ||
} else { | ||
return false; | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public boolean skipAlreadyFlaggedItineraries() { | ||
return false; | ||
} | ||
} | ||
leonardehrenfried marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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.
filterDirectFlexByEarliestDepartureTime ?
Is this still correct?