Open hbruch opened 5 years ago
We will approach this problem the following way:
GraphPathFinder
and in case of a car route execute two routing requests:
CAR
and number of routes set to 1CAR_PARK
Good news, I've create a wrapper around the routing engine that executes two requests when P&R is selected.
The above route would now have an additional car-only result. This is visualised here:
Now I need to implement the actual comparing and filtering of the routes.
I've pushed my code (which forks off HSLdev/OTP) here: https://github.com/mfdz/OpenTripPlanner/tree/park-and-ride
You want to check out ComparingGraphFinder
.
I have implemented the current filtering logic as follows:
For many requests, I get an exception:
21:22:23.935 WARN (GraphPathFinder.java:185) CompactLegsByReversedSearch failed on request: 48.65400545105678,9.063034057617188 48.6106679311573,8.842964172363281 804.672 Fri Nov 01 20:53:00 CET 2019 false QUICK WALK,TRAM,SUBWAY,RAIL,BUS,FERRY,CABLE_CAR,GONDOLA,FUNICULAR,TRANSIT,AIRPLANE 3
21:22:23.936 ERROR (PlannerError.java:62) exception planning trip:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[na:1.8.0_192]
at java.util.ArrayList.get(ArrayList.java:433) ~[na:1.8.0_192]
at org.opentripplanner.api.resource.GraphPathToTripPlanConverter.generatePlan(GraphPathToTripPlanConverter.java:59) ~[classes/:na]
at org.opentripplanner.api.resource.PlannerResource.plan(PlannerResource.java:72) ~[classes/:na]
at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_192]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_192]
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [jersey-server-2.23.jar:na]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [jersey-server-2.23.jar:na]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [jersey-server-2.23.jar:na]
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:205) [jersey-server-2.23.jar:na]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [jersey-server-2.23.jar:na]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [jersey-server-2.23.jar:na]
One possible cause might be, that the RoutingRequest used for both requests is mutable and used to store state (see e.g. GraphPathToTripPlanConverter:105).
Discussion continued here: https://github.com/mfdz/OpenTripPlanner/pull/1
For car_park requests, the proposed connection may include a car leg which is longer than a car-only trip would be:
In such cases, just the car-only trip should be proposed.
This relates to opentripplanner/OpenTripPlanner#2808