If I make a bus profile, how can I get the bus to use the busway tagged highways? For example, this one Way: Bus Lane (1134794367) | OpenStreetMap
From what I can see reading the code, it doesn’t seem like road_class supports busway at the moment?
/**
* This enum defines the road class of an edge. It is heavily influenced from the highway tag in OSM that can be
* primary, cycleway etc. All edges that do not fit get OTHER as value.
*/
public enum RoadClass {
OTHER, MOTORWAY, TRUNK, PRIMARY, SECONDARY, TERTIARY, RESIDENTIAL, UNCLASSIFIED,
SERVICE, ROAD, TRACK, BRIDLEWAY, STEPS, CYCLEWAY, PATH, LIVING_STREET, FOOTWAY,
PEDESTRIAN, PLATFORM, CORRIDOR, CONSTRUCTION;
public static final String KEY = "road_class";
public static EnumEncodedValue<RoadClass> create() {
return new EnumEncodedValue<>(RoadClass.KEY, RoadClass.class);
}
@Override
public String toString() {
return Helper.toLowerCase(super.toString());
}
Yes, but you could add it of course. You’ll also need to add it to CarAccessParser.java
if you like to use car_access
for your bus profile.
Currently the recommended way for bus support is to use bus_access
(which uses the ModeAccessParser). See bus access by karussell · Pull Request #2913 · graphhopper/graphhopper · GitHub
1 Like
in the PR you made @karussell does that ingest ways that have the busway tag? If I want the bus to use ways tagged with busway, do I need to edit to the code as @easbar suggested?
if I want to add the busway tag, but I don’t want to allow the default car profile to route on busways, can I accomplish this without adding to CarAccessParser? If I don’t add to that, but add the tag into the bus profile like this
{ "if": "bus_access && (road_class == BUSWAY || road_class == MOTORWAY || road_class == TRUNK || road_class == PRIMARY || road_class == SECONDARY || road_class == TERTIARY || road_class == UNCLASSIFIED || road_class == LIVING_STREET || road_class == RESIDENTIAL || road_class == SERVICE || road_class == ROAD)",
"multiply_by": "1"
},
will that work?
I made a PR which seems to work. I’m not totally sure where I should write unit tests / how to unit test this – I’m assuming I need a unit test for the bus profile and one for the car profile, and I need to make sure the routing works correctly for each profile. Is there a code pointer for an example unit test I can pattern match?
master
← mobility-solutions-inc:ctriley/busway
opened 01:26PM - 28 May 25 UTC
I'm not sure how to write a unit test for this -- hoping someone might advise me… on that.
I tested manually on the graphhopper server with a lane that is marked as a busway using both the car profile and the bus profile. The car profile takes the road correctly, and the bus profile takes the bus lane.


Please read [our contributing guide](https://github.com/graphhopper/graphhopper/blob/master/CONTRIBUTING.md) and note that also your contribution falls under the Apache License 2.0 as outlined there.
Your first contribution should include a change where you add yourself to the CONTRIBUTORS.md file.