Prohibiting U-Turns in GraphHopper Core

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:


public class GraphHopperProvider {
    GraphHopper graphHopper;

    public GraphHopperProvider(@Value("${}") String graphHopperMap,
                               @Value("${arg.graphhopper.osm.base}") String graphHopperBase) {

        GraphHopper gh = new GraphHopperOSM().forServer().setDataReaderFile(graphHopperMap)
        Profile profile = new Profile("car").setVehicle("car").setWeighting("fastest");

        graphHopper = gh.importOrLoad();

I figured out that I can use GraphHopper request object as solution, for example:

            GHRequest ghRequest = new GHRequest().setPoints( -> new GHPoint(e.getLatitude(), e.getLongitude())).collect(Collectors.toList())).setProfile("car")
                    .putHint(Parameters.CH.DISABLE, true)
                    .putHint(Parameters.Routing.PASS_THROUGH, true)
                    .putHint(Parameters.Routing.HEADING_PENALTY, 300)
                    .setSnapPreventions(List.of("motorway", "trunk", "tunnel", "bridge"));

However, I would like to set this restriction on my vehicle profile, in this case “car”, or on GraphHopper object.