Hello! I’m trying to calculate shortest path for different vehicle types but avoiding some road classes and environments (eg motorways, toll roads, etc). I’m running an instance of GH locally but the API doesn’t seem to actually avoid the different keywords I’m passing. I saw on a different thread that this feature is only available in the commercial version (but that comment was quite old). Could anyone confirm if that is still the case?
On a related issue, is it possible to avoid road classes and environments when calculating isodistances? I couldn’t find this option when checking the docs. If this is not possible, I’m assuming the only solution to calculate isodistances whilst avoiding motorways, tolls, etc is to write my own version of it using the routing API?
// Exclude footways, stairs from profile
CustomModel model = new CustomModel();
HashMap map = new HashMap();
Then as you set the profiles;
graphHopper = new GraphHopperOSM().setGraphHopperLocation(locationGrapphopperFiles)
So the footway is set to 0 which disables it and service 1.0 to enable it.
To enable private access for private roads; EncodingManager encodingManager = EncodingManager.create(FlagEncoderFactory.FOOT + "|block_private=false,
Hi @Gregws! Thank you very much for your answer. Have it working now… apart from avoiding toll roads. Can’t see tolls being any under a custom model (and I believe the example yml in the repo have toll inside “priority” but that doesn’t seem to be correct…) Many thanks!!
Hi again @Gregws! Thank you very much for taking the time to reply! Unfortunately, I’ve already tried what you suggested but it doesn’t like it Error: Cannot find encoded value 'toll' specified in 'priority'. Available: roundabout,road_class,road_class_link,road_environment,max_speed,road_access I read through the code in the repo and I can’t quite see any reference to tolls in the custom models so wondering if that’s not really possible.
I’m able to replicate the behaviour you are describing using flex and the maps service, but I’m trying to do everything programmatically against the Routing API (as I need to calculate shortest distance for a large number of locations, but also using some customisation like no tolls, no motorways, etc). Not very successfully so far unfortunately (and using &avoid=toll in the request doesn’t seem to do the trick. Would you happen to know if I could use flex programmatically against Routing API?
Sadly I also tried that but it didn’t like it either Error: Cannot find enum toll in [other, road, ferry, tunnel, bridge, ford, shuttle_train] Reading through the code, tolls don’t seem to be in any of the custom profiles so might not be possible Thanks for your very kind help @Gregws!!
Thank you so much for all the help, really appreciate it!! I’m almost there I believe. Now, I’m trying to write some tests to double check the paths I’m getting are correct. I’m not spinning the API, just querying the JAR and I would like to get the details of the path (e.g road class, road environment, etc). I’ve got here
The bit I’m struggling to get working in Java (fine when querying the API) is to get details about toll roads. I thought this would do but it doesn’t like it
GraphHopper hopper = new GraphHopperOSM().forServer();
hopper.init(new GraphHopperConfig().putObject("graph.encoded_values", "road_class, ...,toll"));
GHRequest req = new GHRequest(latFrom, lonFrom, latTo, lonTo)
.setPathDetails(Arrays.asList("road_class", "road_environment", "toll"));
Getting You requested the details [road_class, road_environment, toll] but we could only find [road_class, road_environment] so I’m assuming the way I do GraphHopperConfig()... is not quite correct. Any clue why that might not be working? Thanks so much!