I’m trying to set up a Graphhopper instance as provided in the examples.
But I would like to use the “racingbike” profile:
public static void routing(GraphHopper hopper) {
GraphHopper hopper = createGraphHopperInstance(relDir + "core/files/berlin.osm.pbf");
}
static GraphHopper createGraphHopperInstance(String ghLoc) {
GraphHopper hopper = new GraphHopper();
hopper.setOSMFile(ghLoc);
// specify where to store graphhopper files
hopper.setGraphHopperLocation("target/routing-graph-cache");
// add all encoded values that are used in the custom model, these are also available as path details or for client-side custom models
hopper.setEncodedValuesString("racingbike_priority, racingbike_access, bike_network, roundabout, racingbike_average_speed, bike_road_access, average_slope, mtb_rating, hike_rating, sac_scale, country, road_class, ferry_speed");
// see docs/core/profiles.md to learn more about profiles
hopper.setProfiles(new Profile("racingbike").setCustomModel(GHUtility.loadCustomModelFromJar("racingbike.json")));
// this enables speed mode for the profile we called car
hopper.getCHPreparationHandler().setCHProfiles(new CHProfile("racingbike"));
// now this can take minutes if it imports or a few seconds for loading of course this is dependent on the area you import
hopper.importOrLoad();
return hopper;
}
I’m getting errors when using the supplied “racingbike.json”:
Exception in thread “main” java.lang.IllegalArgumentException: Could not create weighting for profile: ‘racingbike’.
Profile: name=racingbike|turn_costs={null}|weighting=custom|hints={custom_model=distanceInfluence=null|headingPenalty=null|speedStatements=[{"if": "road_environment == FERRY", "limit_to": "ferry_speed"}, {"else": "", "limit_to": "racingbike_average_speed"}, {"if": "!racingbike_access && backward_racingbike_access", "limit_to": "5"}]|priorityStatements=[{"if": "true", "multiply_by": "racingbike_priority"}, {"if": "bike_network == INTERNATIONAL || bike_network == NATIONAL", "multiply_by": "1.4"}, {"else_if": "bike_network == REGIONAL || bike_network == LOCAL", "multiply_by": "1.2"}, {"if": "road_environment == FERRY", "multiply_by": "0.5"}, {"if": "mtb_rating > 2", "multiply_by": "0"}, {"else_if": "mtb_rating == 2", "multiply_by": "0.5"}, {"if": "hike_rating > 1", "multiply_by": "0"}, {"if": "bike_road_access == NO", "multiply_by": "0"}, {"if": "!racingbike_access && (!backward_racingbike_access || roundabout)", "multiply_by": "0"}, {"else_if": "!racingbike_access && backward_racingbike_access", "multiply_by": "0.2"}]|turnPenaltyStatements=[]|areas=[]} Error: Cannot compile expression: 'racingbike_priority' not available
If I comment out the first line of racingbike.json
{ "if": "true", "multiply_by": "racingbike_priority" },
which causes this error I get:
Exception in thread “main” java.lang.IllegalArgumentException: Could not create weighting for profile: ‘racingbike’.
Profile: name=racingbike|turn_costs={null}|weighting=custom|hints={custom_model=distanceInfluence=null|headingPenalty=null|speedStatements=[{“if”: “road_environment == FERRY”, “limit_to”: “ferry_speed”}, {“else”: “”, “limit_to”: “racingbike_average_speed”}, {“if”: “!racingbike_access && backward_racingbike_access”, “limit_to”: “5”}]|priorityStatements=[{“if”: “bike_network == INTERNATIONAL || bike_network == NATIONAL”, “multiply_by”: “1.4”}, {“else_if”: “bike_network == REGIONAL || bike_network == LOCAL”, “multiply_by”: “1.2”}, {“if”: “road_environment == FERRY”, “multiply_by”: “0.5”}, {“if”: “mtb_rating > 2”, “multiply_by”: “0”}, {“else_if”: “mtb_rating == 2”, “multiply_by”: “0.5”}, {“if”: “hike_rating > 1”, “multiply_by”: “0”}, {“if”: “bike_road_access == NO”, “multiply_by”: “0”}, {“if”: “!racingbike_access && (!backward_racingbike_access || roundabout)”, “multiply_by”: “0”}, {“else_if”: “!racingbike_access && backward_racingbike_access”, “multiply_by”: “0.2”}]|turnPenaltyStatements=[]|areas=[]}
Error: Cannot compile expression: priority entry invalid condition “bike_network == INTERNATIONAL || bike_network == NATIONAL”: ‘bike_network’ not available
at com.graphhopper.GraphHopper.checkProfilesConsistency(GraphHopper.java:1208)
Am I doing something wrong or is racingbike,json outdated?
Many thanks for your support
Robert