Exception in thread "PBF Reader" java.lang.RuntimeException: Unable to read PBF file

I am trying to load a merged osm file. I have set min network size and one way network size to 0. Getting the below error log when trying to import osm pbf file and build the graph

Exception in thread “PBF Reader” java.lang.RuntimeException: Unable to read PBF file.
at com.graphhopper.reader.osm.pbf.PbfReader.run(PbfReader.java:50)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: A PBF decoding worker thread failed, aborting.
at com.graphhopper.reader.osm.pbf.PbfDecoder.sendResultsToSink(PbfDecoder.java:87)
at com.graphhopper.reader.osm.pbf.PbfDecoder.processBlobs(PbfDecoder.java:151)
at com.graphhopper.reader.osm.pbf.PbfDecoder.run(PbfDecoder.java:162)
at com.graphhopper.reader.osm.pbf.PbfReader.run(PbfReader.java:47)
… 1 more
Caused by: java.lang.ClassCastException: cannot be cast to java.lang.Long
at com.graphhopper.reader.osm.pbf.PbfBlobDecoder.processNodes(PbfBlobDecoder.java:189)
at com.graphhopper.reader.osm.pbf.PbfBlobDecoder.processOsmPrimitives(PbfBlobDecoder.java:329)
at com.graphhopper.reader.osm.pbf.PbfBlobDecoder.runAndTrapExceptions(PbfBlobDecoder.java:343)
at com.graphhopper.reader.osm.pbf.PbfBlobDecoder.run(PbfBlobDecoder.java:355)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
… 1 more

Probably your pbf is not correct then, as it seems to work with all official pbf from Geofabrik oder OSM.

1 Like

Have a look if all node IDs are existent

Im facing the problem only when using merged and converted files and not on the official downloaded files. Not sure how to go about this issue…

How do you merge them?

osmconvert /home/osm/spain-latest.osm.pbf -o=/home/osm/spain-latest.o5m

osmconvert /home/osm/germany-latest.osm.pbf -o=/home/osm/germany-latest.o5m

osmconvert /home/osm/spain-latest.o5m /home/osm/germany-latest.o5m -o=spain-germany-latest.o5m

osmconvert /home/osm/spain-germany-latest.o5m -o=/home/osm/spain-germany-latest.osm.pbf

And do other tools work when you give them this pbf?

Also there is osmium that can print the text form of a pbf - would you mind to give like two nodes and two ways for this? http://osmcode.org/osmium-tool/manual.html

Also osmium can merge - would you mind to try this:

osmium merge country1.osm.pbf country2.osm.pbf -o together.osm.pbf

1 Like

osm2pgsql did work with the same pbf while I was trying out pgRouting

@karussell Since I had set min network size and one way network size to 0 while building the graph, the routing has roads included which are dead ends. Is there any way I can filter out dead ends during route calculation? EdgeFilter perhaps is the one I could possible look into, but how do I detect dead ends?

Did you got it working now? The min network setting has only partly to do with dead ends. The settings makes sure that certain dead ends with oneway streets are removed or small subnetworks (regardless of the oneway property)

Yes. And No. Yes because it did build a graph once on server and No because it did not when I tried it in my local system.

Is there any way I can prevent dead ends from being part of route generated?

There is no inbuilt way to do it. Why would you want this?

Well, maybe I am doing something wrong for it to be part of the route first of all. But I think its better to not let the user navigate to dead end and then force him to make a u turn after leading him in first place which is not a good user experience…

Not sure if I understand this. Do you have an example on GraphHopper Maps?

It seems to work in graphhopper maps correctly, but it doesn’t if I use google maps to plot the route… I think maybe the osm data is incorrect for Asia in specific. There are roads that are not actually there in real or atleast in google maps, but in osm they are present.