womisa
March 16, 2016, 6:42pm
1
Hi
sorry for my simple (?) question!
i have first tried to get alternative Routes with GH 6.0. But i became no alternatives
GraphHopper hopper = new GraphHopper().forDesktop().setMemoryMapped().setEncodingManager(new EncodingManager(“CAR,FOOT,BIKE”));
hopper.setOSMFile(osmFile);
hopper.setGraphHopperLocation(graphFolder);
hopper.importOrLoad();
…
GHResponse rsp = hopper.route(new GHRequest(fromLat, fromLon, toLat,toLon) .setVehicle(EncodingManager.BIKE));
…
Boolean alternatives=rsp.hasAlternatives(); ====> This is allways "false"
List pathWrappers = rsp.getAll();
PathWrapper best=rsp.getBest();
…
What i’m doing wrong?
Thanks
Achim
You need using the proper algorithm:
request.setAlgorithm(AlgorithmOptions.ALT_ROUTE);
Emux
1 Like
Forgot to mention that alternative route calculation plays with the flexibility mode.
Emux
womisa
March 16, 2016, 7:37pm
4
@devmux86 thanks for your hint!
How can I find this in the documentation?
https://github.com/graphhopper/graphhopper/blob/master/docs/core/routing.md
Thanks
Achim
I think it’s mentioned in the main page at Features with link to the related topic here in forum.
Emux
womisa
March 16, 2016, 8:03pm
6
thanks again!
How can i set this parameters in the core java version (Desktop) ?
max_weight_factor – the maximum weight of the return routes, in compare to the best route.
Valid values >=1
Default value = 1.4
max_share_factor – The max overlap between returned routes
Valid values between 0 and 1
Default value = 0.6
max_paths – the maximum number of returned path
Valid values >=2
Default value = 2
min_plateau_factor - ???
Default value = 0.2
max_exploration_factor - ???
Default value = 1
Thanks
Achim
womisa
March 16, 2016, 9:23pm
7
i have found this…
/*
alternative_route.max_share_factor (get more alternatives via increasing this)
or a too
low alternative_route.min_plateau_factor (get more alt. via decreasing it)
another factor is the
alternative_route.max_exploration_factor try increasing it to get more alternatives but this
*/
ghRequest.getHints().put("alternative_route.min_plateau_factor", "0.1");
ghRequest.getHints().put("alternative_route.max_exploration_factor", "0.9");
ghRequest.getHints().put("max_share_factor", "1.0");
ghRequest.getHints().put("max_weight_factor", "1.6");
ghRequest.getHints().put("alternative_route.max_paths", "10");
Thanks
Achim
1 Like