I want to get as many paths possible.
I have a local instance of graphhopper in the back-end. this is the set up I have:
@PostConstruct
public void init() {
Profile profile = new Profile("my_profile")
.setVehicle("foot")
.setWeighting("shortest");
profile.getHints().put("instructions", "true");
profiles = new ArrayList<>();
profiles.add(profile);
graphHopper = new GraphHopperOSM();
graphHopper.setOSMFile(dataPath + "eindhoven.osm.pbf");
// Create a new GraphHopperConfig and disable CH.
GraphHopperConfig ghConfig = new GraphHopperConfig();
ghConfig.setProfiles(profiles);
ghConfig.putObject("prepare.ch.enabled", false);
graphHopper.init(ghConfig);
graphHopper.setGraphHopperLocation(graphFolder);
graphHopper.getCHPreparationHandler();
graphHopper.importOrLoad();
}
and this is the controller I use in the front-end:
public List<CustomPath> getRoute(
@RequestParam("fromLat") double fromLat,
@RequestParam("fromLng") double fromLng,
@RequestParam("toLat") double toLat,
@RequestParam("toLng") double toLng) {
try {
System.out.println("fromLat: " + fromLat);
System.out.println("fromLng: " + fromLng);
System.out.println("toLat: " + toLat);
System.out.println("toLng: " + toLng);
GHRequest request = new GHRequest(fromLat, fromLng, toLat, toLng).setProfile("my_profile")
.setAlgorithm(Parameters.Algorithms.ALT_ROUTE)
.putHint(Parameters.Algorithms.AltRoute.MAX_PATHS, "10")
.putHint(Parameters.CH.DISABLE, "true");
GHResponse response = graphHopperService.getGraphHopper().route(request);
List<ResponsePath> responsePaths = response.getAll();
System.out.println("response: " + response);
// return graphHopperService.getBestAirQualityPath(responsePaths);
return (graphHopperService.createCustomPaths(responsePaths));
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
ok I set the alt routes to be 10 but I get 2 at maximum. What can I do to get more routes.
PS: I will sent 10 euro through Revolut to the person who solves it.