-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow itinerary in response to be sorted by duration #2593
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
Allow itinerary in response to be sorted by duration #2593
Conversation
…ntations can be added following this pattern.
|
Looks good! Maybe PathComparator should be called something else, like ArrivalTimeComparator? I think @t2gran suggested combining this with a pareto-set filter, but that could be added later. |
|
|
||
| /** Which path comparator to use */ | ||
| public String pathComparator = null; | ||
|
|
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 cannot any places where pathComparator is set. I think a comment on how this is used(set to somethingother null) should be documented. Is the plan to integrate with some kind of configuration later, routing request parameter, or just fork the code and inject a different strategy?
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.
It's not set explicitly in the code, but if you include configuration in router-config.json, it will get set automatically, e.g.
// router-config.json
{
"routingDefaults": {
"pathComparator":"duration"
}
}
This happens via the existing config-setting code:
| this.defaultRoutingRequest = scraper.scrape(routingDefaultsNode); |
I'll add code to allow this to be set via an API parameter as well.
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.
Thank you for the clarification. I think your solution is the best, it might be confusing to have "config" params only.
This PR adds a DurationComparator so that returned itineraries can be sorted by duration, instead of the default method.
More Comparator implementations can be added following this pattern.