Bytes_for_flags not considered

I followed the instructions given at After some difficulties withn the on my Windows-PC I decided to use InelliJ and compile and run directly from there. I used osm- and GTFS-data for Berlin.

However I get the following exception:

java.lang.IllegalArgumentException: Encoders are requesting 69 bits, more than 64 bits of edge flags. (Attempt to add EncodedValue car.average_speed) Decrease the number of vehicles or increase the flags to take long via graph.bytes_for_flags: 8
	at com.graphhopper.routing.util.EncodingManager.addEncodedValue(
	at com.graphhopper.routing.util.EncodingManager.addEncoder(
	at com.graphhopper.routing.util.EncodingManager.access$300(
	at com.graphhopper.routing.util.EncodingManager$Builder.add(
	at com.graphhopper.http.GraphHopperBundle.runPtGraphHopper(

I set the flag in both the config.yml and the VM-arguments to no avail.

Actually I´m on master.

We need to update the error message. You should be able to fix the problem via increasing the bytes further (in steps of 4):

graph.bytes_for_flags: 12

This didn´t seem to change anything. So I tried to debug it and noticed that the value doesn´t seem to be evaluated by the encoders at all.

final EncodingManager encodingManager = new EncodingManager.Builder(8).add(ptFlagEncoder).add(new FootFlagEncoder()).add(new CarFlagEncoder()).build();

As far as I can see the configuration being passed to runPtGraphHopper isn´t used within the above line, making any setting within this configuration quite obsolete.

Ah, ok. If you used the Java API without graphHopper.init() then no config is read.

Please try to replace the 8 with a 12:

new EncodingManager.Builder(8) -> new EncodingManager.Builder(12)

That indeeed worked. However I wonder why there´s nothing on the tutorial about GTFS mentioned earlier. Or did I miss anything about graphHopper.init()?

Usually there is no need to use the configuration file if you use the Java API or what do you mean?

Ah okay, I see. But if we´d omit the config-yml completely, how would we ever configure more sophisticated options like the logger or the host? Is there any link for when to use a config-file?

I am having a similar issue. can you please explain what you did to overcome. not an advance java user

If you are using the graphhopper as a library then use any logging framework you like.

If you want to use the web module including dropwizard (incl. the server) then you create your own XYApplication class like GraphHopperApplication that uses GraphHopperBundle (that uses GraphHopperManaged that calls graphhopper.init that uses the config file).

@Kohlroulade @karussell

Okay, slight misunderstanding here: You are running the server with configuration file, not the Java API, and you were quoting its source code, where the ‘8’ was hard-coded, and no value from the configuration file was used.

(Public transit uses an entry point different from the rest of GraphHopper.)

“Who would ever need more than 8 bytes…” – Me. Always worked for me with the Berlin file and even bigger ones.

Fixed on master. Works nicely now with

1 Like

Ups, thanks!

Hey Karussel.
i have already replaced the EncodingManager.Builder to 12 but i’m not using the GraphHopper.init when i executed the program.
This is exactly what i execute:
java -Xmx4g -Xms4g
-jar web/target/graphhopper-web-0.12.0.jar server config.yml

I’m missing something?