Currently I am working on defining route without using U-Turns except when it is completely necessary (etc. It should not be prohibited on the dead end street as vehicle is unable to do U-Turn in the middle of the narrow street ). I saw many examples, however I could not achieve proper results.Below is code snippet that I used. Dependency that I am using is:
implementation ‘com.graphhopper:graphhopper-reader-osm:2.4’
Map that I am using is:
What I used as reference:
https://github.com/graphhopper/graphhopper/blob/master/docs/core/turn-restrictions.md
https://docs.graphhopper.com/#operation/getRoute/pass_through
CODE SNIPPET
@Component
@Getter
public class GraphHopperProvider {
GraphHopper graphHopper;
public GraphHopperProvider(@Value("${arg.graphhopper.osm.map}") String graphHopperMap,
@Value("${arg.graphhopper.osm.base}") String graphHopperBase) {
GraphHopper gh = new GraphHopperOSM().forServer().setDataReaderFile(graphHopperMap)
.setGraphHopperLocation(graphHopperBase)
.setMinNetworkSize(200)
.setEncodingManager(EncodingManager.create("car|turn_costs=true|edge_based=true|restriction=no_u_turn"));
gh.getCHPreparationHandler().setPreparationThreads(Runtime.getRuntime().availableProcessors());
Profile profile = new Profile("car").setVehicle("car").setWeighting("fastest");
gh.setProfiles(profile);
graphHopper = gh.importOrLoad();
}
}