How to get route_type info from PT routing

GTFS has a route_type column in their routes.txt file which can help indicate the type of transportation

Is there anyway I can extract that in the graphhopper PT output?

For those who are trying to do something similar.

add route type variable to web-api/src/main/java/com/graphhopper/Trip.java for the class PtLeg and modify the constructor accordingly to assign a value

        public final int route_type;

In the reader-gtfs/src/main/java/com/graphhopper/gtfs/TripFromLabel.java file,
add for parsePartitionToLegs() function on line 339

declare int route_type = -1;

then in the conditionals on line 344 you can get the actual route type
if (GtfsStorage.EdgeType.ENTER_PT == path.get(1).edge.getType()) { route_type = path.get(1).edge.getRouteType();

then on line 369 where you create a new Trip.PTLeg in
result.add(new Trip.PtLeg(....

pass the route_type to the constructor.

that should be enough to get the result json to output

1 Like