I’m trying to use graphhopper to plan routes for our emergency service response cars that use motorway access gates and service routes. I’m very new to Java - I’m just trying to see if I can do a proof of concept to take to my bosses so we can engage with a programmer.
I’ve successfully installed a local java installation from source and can use it to create standard car routes. I’ve tried editing the restricted values section of CarTagParser.java to:
I’ve also removed the recent update which restricts access for cars to service roads with emergency access.
I’ve deleted the files in graph-cache and then re-started the application without any success.
Here are two different examples of the access routes, one that includes the tag emergency: designated and one that just appears as a service highway.
When I select the local MVT layer, no overlay or information is displayed for these roads - could it be that they’re not being recognised by the OSM reader?
Instead of changing the CarFlagEncoder I recommend to use the new RoadsFlagEncoder instead and then restrict access as you need it. E.g. using a custom_model like:
Please note the condition with car$access, this allows the vehicle to drive oneway roads in reverse order but still gives a big penalty for these cases so that this only happens when necessary. Please note that this model can only act as a start and you should introduce a conditional for motorways so that the reverse direction is never used and probably many more.
Unfortunately, that doesn’t create routes using the private segments of road. I’ve tried adding
{
“if”: “access == PRIVATE”,
“multiply_by”: 1
}
to the custom model and adding a limit_to entry. I’ve also tried changing the graph.flag_encoders entry to car|block_private=false.
When I use the local MVT layer, the roads that are listen as private access in OSM do not have an overlay with any data - see picture for example. When I edit the map in JOSM and change the road segment to public access then re-build the application, the segment has an MVT entry. Is it possible that the private access roads are not passing/visible to the routing engine?
Did you use the roads encoder instead of car? Remove the line with graph.flag_encoders and do:
...
profiles:
- name: roads # or name it `car` or `emergency` or something
vehicle: roads
weighting: custom
custom_model_file: empty # or directly use the custom_model above
The top custom model worked as I hoped when I changed “car$access” to “car_access”. Using “car$access” produced the following error message in NetBeans:
“Error: Cannot compile expression: in ‘priority’ entry, invalid expression “car$access == false”: ‘car$access’ not available”
Likewise, the second model produced the following error message:
“Operations limit_to expects a number but was “car$average_speed” (through reference chain: com.graphhopper.util.CustomModel[“speed”]->java.util.ArrayList[0])”