Bytes_for_flags not considered

I followed the instructions given at https://github.com/graphhopper/graphhopper/tree/master/reader-gtfs. After some difficulties withn the graphhopper.sh-script 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(EncodingManager.java:350)
	at com.graphhopper.routing.util.EncodingManager.addEncoder(EncodingManager.java:329)
	at com.graphhopper.routing.util.EncodingManager.access$300(EncodingManager.java:45)
	at com.graphhopper.routing.util.EncodingManager$Builder.add(EncodingManager.java:213)
	at com.graphhopper.http.GraphHopperBundle.runPtGraphHopper(GraphHopperBundle.java:212)
	at com.graphhopper.http.GraphHopperBundle.run(GraphHopperBundle.java:202)
	at com.graphhopper.http.GraphHopperBundle.run(GraphHopperBundle.java:64)

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
-Dgraphhopper.datareader.file=brazil-latest.osm.pbf
-Dgraphhopper.gtfs.file=gtfs_campo-largo.zip
-Dgraphhopper.graph.flag_encoders=pt
-Dgraphhopper.prepare.ch.weightings=no
-Dgraphhopper.graph.location=./graph-cache
-jar web/target/graphhopper-web-0.12.0.jar server config.yml

Iā€™m missing something?