Custom Profiles in GH v 9.0

Hiyas,

After sitting on Graphhopper 7.0 I have attempted to move to 9.0.

Just wondering the new implementation to restrict and allow different roads.


v7.0
graphHopper.setVehiclesString("foot|block_private=false,car|block_private=false|turn_costs=true")

I’m not sure in v9.0




Custom models - There is no-longer the option to set vehicle, how is this now handled?


v7.0
new CustomProfile("paxster").setCustomModel(new CustomModel(getPaxsterModel())).setVehicle("foot")

v9.0
new Profile("paxster").setCustomModel(new CustomModel(getPaxsterModel()))
(no setVehicle)

Where getPaxsterModel is

    private static CustomModel getPaxsterModel(){
        CustomModel model = new CustomModel();
        model.addToPriority(If("road_class == CONSTRUCTION", MULTIPLY, "1.0"));
        return model;
    }

Using the following I’ve attempted to change to using custom models via the suggested .json profiles, but end up getting stuck (as I have in the past) with setting up the config.yml.

Thanks

Somewhat resolved;

CustomModel model = new CustomModel();
model.setDistanceInfluence(10.0);
model.addToSpeed(If("true", LIMIT, "car_average_speed"));

new Profile("paxster").setCustomModel(new CustomModel(getPaxsterModel()))

.setEncodedValuesString("foot|block_private=false,car|block_private=false|turn_costs=true")
.setEncodedValuesString("road_access, road_class, car_average_speed");

Now with;
model.addToPriority(If("road_class == CONSTRUCTION", MULTIPLY, "1.0"));

Error
File ‘priority entry’, Line 3, Column 29: “CONSTRUCTION” is neither a method, a field, nor a member class of “com.graphhopper.routing.ev.RoadClass”

Even though github has;
image

Maven doesn’t have;

Helpful docs

graphhopper/CHANGELOG.md at master · graphhopper/graphhopper · GitHub
graphhopper/docs/migration/config-migration-08-09.md at master · graphhopper/graphhopper · GitHub

This is explained here or did this not make it clear?

CONSTRUCTION was added after 9.0, so you would have to use the current master branch to use it.

2 Likes

Yes, please see my initial reply to myself.

I use the following 9.1 and it isn’t there.
image
image

<dependency>
    <groupId>com.graphhopper</groupId>
    <artifactId>graphhopper-core</artifactId>
    <version>9.1</version>
</dependency>

Ok sorry, it was also added after 9.1. It isn’t included in any release yet.

1 Like

Thanks, is there an ETA for when it will be included in the release?

I’ve just used OTHER for the moment, but it would be more reliable if there was a bit more control over it using the released version.

Currently we do approx. two releases per year. GH10 should be released around September.

1 Like

Cool, love your work. Looking forward to the next release!