Skip to content

Filtering non-pickup calls - #2377

Merged
novalis merged 6 commits into
opentripplanner:masterfrom
barslett:patch-3
Jun 28, 2017
Merged

Filtering non-pickup calls#2377
novalis merged 6 commits into
opentripplanner:masterfrom
barslett:patch-3

Conversation

@barslett

@barslett barslett commented Dec 8, 2016

Copy link
Copy Markdown
Contributor

IndexAPI (and GraphQL) has apparently had no method to filter away calls in StopTimes that have no boarding (piclupType = 1). This change ignores these stops in stopTimesForStop(). If some implementations still need to show these calls, we can of course make it configurable.

Partly replaces PR #2358, which contained too much clutter.

IndexAPI (and GraphQL) has apparently had no method to filter away calls in StopTimes that have no boarding (piclupType = 1). This change ignores these stops in stopTimesForStop(). If some implementations still need to show these calls, we can of course make it configurable.

Partly replaces PR opentripplanner#2358, which contained too much clutter.
@hannesj

hannesj commented Dec 9, 2016

Copy link
Copy Markdown
Contributor

It would be nice if this would be based on an argument, as we are showing the arriving vehicles differently in the ui.

@barslett

barslett commented Dec 9, 2016

Copy link
Copy Markdown
Contributor Author

@hannesj I suggest adding a parameter for this to the router-config. An argument would have to be added to two methods in Index API as well as to the GraphQL request structure.

EDIT: Seems that I wrongly have assumed that the router-config can be used for the Index API. Seems it only affects routing requests over the Plan API...

@hannesj

hannesj commented Dec 16, 2016

Copy link
Copy Markdown
Contributor

Thanks!

@QueryParam("timeRange") @DefaultValue("86400") int timeRange,
@QueryParam("numberOfDepartures") @DefaultValue("2") int numberOfDepartures) {
@QueryParam("numberOfDepartures") @DefaultValue("2") int numberOfDepartures,
@QueryParam("omitNonPickups") boolean omitNonPickups) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting looks funny here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix.

for (Stop currStop : pattern.stopPattern.stops) {
if (currStop == stop) {
if(pattern.stopPattern.pickups[sidx] == pattern.stopPattern.PICKDROP_NONE) continue;
if(omitNonPickups && pattern.stopPattern.pickups[sidx] == pattern.stopPattern.PICKDROP_NONE) continue;

@novalis novalis Dec 30, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a funny variable name -- you really mean stops that allow neither pickups nor dropoffs (I think they might be called "non-stop timepoints"). At any rate, the name "nonPickups" confused me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we are talking about stops that have dropoff, but pickups aren't allowed. In Oslo, this is the case with most region buses when approaching the urban area. They let off passengers on the way, but not taking any new ones on board.

So, the variable name describes a call that is not for pickup. I could rename it omitPickupOnly or something similar.

int sidx = 0;
for (Stop currStop : pattern.stopPattern.stops) {
if (currStop == stop) {
if(pattern.stopPattern.pickups[sidx] == pattern.stopPattern.PICKDROP_NONE) continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

* @param startTime Start time for the search. Seconds from UNIX epoch
* @param timeRange Searches forward for timeRange seconds from startTime
* @param numberOfDepartures Number of departures to fetch per pattern
* @param omitNonPickups If departures with pickup restrictions should be included or not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reword: "If stops at which passengers are neither picked up nor dropped off should be omitted".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, ref my other comment. Dropoffs are allowed here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is the key to understanding the parameter, I would still like to re-phrase it a little to avoid people misunderstanding it. How about "@PARAM omitNonPickups If true, do not include vehicles that will not pick up passengers."

@novalis

novalis commented Jan 2, 2017

Copy link
Copy Markdown
Contributor

OK, now I understand better. I'm still concerned about what happens at the terminus of a route (which might be marked as PICKDROP_NONE). Do you know what agencies do here?

@barslett

barslett commented Jan 2, 2017

Copy link
Copy Markdown
Contributor Author

In our data, the call at the terminus is indeed marked as PICKDROP_NONE, and with this filtering it will not be shown in the list of departures, which is our intended behaviour.

I will guess that other agencies who might want to do this filtering, would like to do it both for intermediate no-boarding stops and for termini. Maybe @hannesj has comments?

@barslett

Copy link
Copy Markdown
Contributor Author

@novalis - do we have any chance of merging this, ref my last comments?

@novalis

novalis commented Jan 16, 2017

Copy link
Copy Markdown
Contributor

I want to merge this, but I don't feel confident that it is really the right thing to do. If I were still running the project, I would probably take it, since that's my philosophy. But because this is such a niche feature (why not just filter the results afterwards?), I don't want to merge it until I hear more from people who are more closely involved. Why not ask on the mailing list and see what they think?

Sorry to be annoying here, and thanks for contributing.

@hannesj

hannesj commented Jan 17, 2017

Copy link
Copy Markdown
Contributor

Actually our use case has changed slightly, as we would like to skip the arrivals/non-pickups for terminal views, but show those for individual stops, so this change would be beneficial to us also.

@barslett

Copy link
Copy Markdown
Contributor Author

@novalis It's impossible to filter on pickdrop afterwards because the attribute itself doesn't exist in the response model. And as this feature is triggered only by a request argument, it will have no impact on other users.

@novalis

novalis commented Jan 17, 2017

Copy link
Copy Markdown
Contributor

OK, but you could put the attribute in the response. If that had been the PR, I would have approved it without worrying.

The issue is not direct impact on other users. The issue is code complexity. If, tomorrow, someone says that they only care about arrival times for dropoff stops, then another parameter needs to get added. Eventually, we have a lot of parameters and code that is hard to read. Since I don't do much day-to-day maintenance on the code, I don't feel confident making this particular decision.

But like I said, feel free to ask on the mailing list. You can get a definitive answer there.

@abyrd

abyrd commented Jan 17, 2017

Copy link
Copy Markdown
Member

Hey @novalis and @hannesj, actually I'd say no real need to go to the mailing list. I and other developers do see these discussions, I just haven't had time recently to catch up on PRs. @novalis summarizes the situation well, there is the possibility of continuing growth of the API and unmanageable complexity. But for people who are making active use of OTP in production deployments where you've got staff working on the code regularly, I don't really worry to much about this and would like to integrate your contributions. I'll review this and hopefully merge it soon.

@hannesj

hannesj commented Jan 17, 2017

Copy link
Copy Markdown
Contributor

@barslett I've added those fields to the GraphQL schema in our fork. I should create a PR for that (and other features added to the GraphQL endpoint) to upstream.

@novalis The idea is that no code for adding/removing data fields is required when using GraphQL, however what we have noticed is that you often want to do some kind of filtering for the data before it is sent to the client, and that needs to be done server-side. In our example we just want to show the next five departures in the popup, and without this filtering we would need to over-request data from the server and filter out those vehicles arriving from that data.

@barslett

Copy link
Copy Markdown
Contributor Author

Had to push an additional commit, as the logic was missing from a stopTimes method in both IndexAPI and GraphQL.

@abyrd abyrd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can go ahead and merge this if the comments can be revised slightly to be more clear. It does have the potential to increase code complexity but I trust that you'll assist in maintaining this code since you're relying on it yourselves.

* @param startTime Start time for the search. Seconds from UNIX epoch
* @param timeRange Searches forward for timeRange seconds from startTime
* @param numberOfDepartures Number of departures to fetch per pattern
* @param omitNonPickups If departures with pickup restrictions should be included or not

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is the key to understanding the parameter, I would still like to re-phrase it a little to avoid people misunderstanding it. How about "@PARAM omitNonPickups If true, do not include vehicles that will not pick up passengers."

@barslett

barslett commented Mar 31, 2017

Copy link
Copy Markdown
Contributor Author

Sorry for the delay! Have updated the parameter description. However, Travis fails, seems like a general error.

@novalis
novalis merged commit 6b77b6e into opentripplanner:master Jun 28, 2017
@demory demory mentioned this pull request Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants