I would like to use OpenTripPlanner as a jar dependency in my project and do some routing with it. I have followed the steps at https://github.com/opentripplanner/OpenTripPlanner/blob/master/src/test/java/org/opentripplanner/GtfsTest.java and they do seem to work if the start and end points of a RoutingRequest
are near a transit stop but don't work otherwise.
The following line returns me an empty list:
List<GraphPath> paths = new GraphPathFinder(router).getPaths(routingRequest);
I think its because the road network is missing from the graph. Specifically, the code in https://github.com/opentripplanner/OpenTripPlanner/blob/master/src/test/java/org/opentripplanner/GtfsTest.java only adds a transit network to the graph (the GtfsBundle
). The road network is never added to the graph. So my question is could anyone please show me how to add the road network to the graph? I have the road network as an OSM PBF file. I seek a complete end-to-end example.
This link is saying at one point:
once the data have been loaded the geometries of the streets are
extra information purely for presentation purposes.
Is the OSM road network not used for routing?
Best Answer
After some searching I found this code to load road network.
But even better was to do following:
It should generate
Graph.obj
in same directory. Now you can use following code to do the routing:where the code for
planTrip
is below