Can't set max_width (or max_weight / height) in .yml file

I’m trying to create a custom profile following the instructions here: https://github.com/graphhopper/graphhopper/pull/1841

but I get the following error:

java.lang.IllegalArgumentException: Could not create weighting for profile: 'emergencycar'.                                  │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=emergencytruck&calc_points=true&points_encoded=false&ch.di
Profile: name=emergencycar|vehicle=emergencycar|weighting=custom|turnCosts=false|hints={custom_model=CustomModel{distanceInfl│sable=trueuence=50.0, speedFactor={}, maxSpeed={}, maxSpeedFallback=null, priorityMap={max_weight={<2.5=0}, max_height={<1.5=0}}, #area│serve: /route?point=40.716957,-74.004334&point=40.729756,-73.999555&vehicle=emergencycar&calc_points=true&points_encoded=false&ch.
s=0}, custom_model_file=empty}                                                                                               │disable=trueError: Cannot find encoded value 'max_weight' specified in 'priority'. Available: roundabout,road_class,road_class_link,road_│serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=emergencycar&calc_points=true&points_encoded=false&ch.disa
environment,max_speed,road_access,bike_network,get_off_bike,                                                                 │ble=true        at com.graphhopper.GraphHopper.checkProfilesConsistency(GraphHopper.java:829)                                        │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=bike&calc_points=true&points_encoded=false&ch.disable=true        at com.graphhopper.GraphHopper.load(GraphHopper.java:772)                                                            │serve: /route?point=40.716957,-74.004334&point=40.729756,-73.999555&vehicle=emergencycar&calc_points=true&points_encoded=false&ch.
        at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:639)                                                    │disable=true        at com.graphhopper.http.GraphHopperManaged.start(GraphHopperManaged.java:125)                                        │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=emergencycar&calc_points=true&points_encoded=false&ch.disa
        at io.dropwizard.lifecycle.JettyManaged.doStart(JettyManaged.java:27)                                                │ble=true        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)                               │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=bike&calc_points=true&points_encoded=false&ch.disable=true        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)                            │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=bike&calc_points=true&points_encoded=false&ch.disable=true        at org.eclipse.jetty.server.Server.start(Server.java:407)                                                            │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=emergencytruck&calc_points=true&points_encoded=false&ch.di
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)                          │sable=true        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)                                 │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=emergencytruck&calc_points=true&points_encoded=false&ch.di
        at org.eclipse.jetty.server.Server.doStart(Server.java:371)                                                          │sable=true        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)                               │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=bike&calc_points=true&points_encoded=false&ch.disable=true        at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:53)                                                        │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=bike&calc_points=true&points_encoded=false&ch.disable=true        at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:45)                                              │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=emergencytruck&calc_points=true&points_encoded=false&ch.di
        at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:87)                                                │sable=true        at io.dropwizard.cli.Cli.run(Cli.java:78)                                                                            │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=bike&calc_points=true&points_encoded=false&ch.disable=true        at io.dropwizard.Application.run(Application.java:94)                                                                │serve: /route?point=36.04682,-75.6827&point=35.90204,-75.671464&vehicle=emergencytruck&calc_points=true&points_encoded=false&ch.di
        at com.graphhopper.http.GraphHopperApplication.main(GraphHopperApplication.java:36)

I’ve modified the following lines of the config.yml file:
graph.flag_encoders: car, emergencycar

profiles:
    name: emergencycar
        vehicle: emergencycar
        weighting: custom
        custom_model_file: ./emergencycar.yml

emergencycar.yml looks like this:

distance_influence: 50
priority:
  max_weight: { "<2.5": 0 }
  max_height: { "<1.5": 0 }
  max_width: { "<2": 0 }

I’ve also created an encoder for emergencycar by copying CarFlagEncoder.java to EmergencyCarFlagEncoder.java, modifying the speeds and referencing it in DefaultFlagEncoderFactory.java and FlagEncoderFactory.java.

If I comment out the max_width/height/weight lines of the emergencycar.yml the server starts up and I can make requests using the route-custom?profile=emergencycar endpoint.

Any assistance is much appreciated. Thanks in advance!

You need to setup the encoded values you are using: graph.encoded_values=max_weight,max_height,max_width

1 Like

Also have a look into this tutorial: Flexible / Configurable Weighting Update I’m currently improving it and will release it as a blog post in the next few days.

Thank you @easbar! I should have noticed that in the config.yml. I set line 19 of my config file to graph.encoded_values: max_weight,max_height,max_width and it works now!

@karussell That tutorial is helpful. I had previously reviewed the discussion in the PR (https://github.com/graphhopper/graphhopper/pull/1841) which was very useful but the tutorial added some good context.

1 Like
Powered by Discourse