Depending on your needs. You can always use GraphHopper Maps that includes auto completion and an export button to share these models (click the “custom” button to see the custom model editor).
I had read the post you mention before but I think my main issue is on how to use those JSON configurations from Java. Also, it seems like I can’t use the init() method with the params to load the toll road information and at the same time set a CustomProfile with the Statement expressions…
Yes, you should either use GraphHopper#init or the different setters of the GraphHopper class, but not both. You can set profiles both ways though: Both GraphHopperConfig and GraphHopper offer a setProfiles method.
Anyway, here is some code that sets up a server-side profile that avoids ferries and toll roads using GraphHopperConfig and GraphHopper#init:
GraphHopperConfig config = new GraphHopperConfig()
.putObject("datareader.file", "your-country.osm.pbf")
.putObject("graph.location", "your-country-gh")
.putObject("graph.encoded_values", "road_class,road_class_link,road_environment,max_speed,road_access,toll")
.setProfiles(Arrays.asList(
new CustomProfile("car_no_toll").setVehicle("car").setCustomModel(
new CustomModel()
.addToPriority(If("toll != NO", MULTIPLY, 0))
.addToPriority(If("road_environment == FERRY", MULTIPLY, 0))
)
))
// optional (allows much faster routing)
.setCHProfiles(Arrays.asList(new CHProfile("car_no_toll")));
GraphHopper hopper = new GraphHopper();
hopper.init(config);
hopper.importOrLoad();
GHRequest request = new GHRequest(45, 10, 46, 11);
request.setProfile("car_no_toll");
GHResponse response = hopper.route(request);