Create offline routing with custom map

Hello, I created a road network with my own shapefile (SHP) with QGIS.

Then I imported that to JOSM. Make sure it has highways tags. But, I don’t create a column called osm_id since it pure my own SHP.

Finally I exported it to PBF format with JOSM.

I want to read that PBF with graphhopper. I don’t use any GTFS.

I followed this tutorial graphhopper/README.md at master · graphhopper/graphhopper · GitHub. Off course, I edited reader-gtfs/config-example-pt.yml to adjust it with my own PBF and turn off GTFS.

But I got error like this, I don’t know any solution since googling doesn;t solve my problem

ERROR [2023-01-31 14:28:27,545] io.dropwizard.cli.ServerCommand: Unable to start server, shutting down
! java.lang.IllegalArgumentException: Invalid OSM NODE Id: -4521674; Ids must not be negative
! at com.graphhopper.reader.ReaderElement.<init>(ReaderElement.java:48)
! at com.graphhopper.reader.ReaderElement.<init>(ReaderElement.java:43)
! at com.graphhopper.reader.ReaderNode.<init>(ReaderNode.java:33)
! at com.graphhopper.reader.osm.pbf.PbfBlobDecoder.processNodes(PbfBlobDecoder.java:240)
! 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.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
! at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
! ... 1 common frames omitted
! Causing: java.lang.RuntimeException: A PBF decoding worker thread failed, aborting.
! at com.graphhopper.reader.osm.pbf.PbfDecoder.sendResultsToSink(PbfDecoder.java:85)
! at com.graphhopper.reader.osm.pbf.PbfDecoder.processBlobs(PbfDecoder.java:149)
! at com.graphhopper.reader.osm.pbf.PbfDecoder.run(PbfDecoder.java:159)
! at com.graphhopper.reader.osm.pbf.PbfReader.run(PbfReader.java:48)
! at java.base/java.lang.Thread.run(Thread.java:829)
! Causing: java.lang.RuntimeException: Unable to read PBF file.
! at com.graphhopper.reader.osm.pbf.PbfReader.close(PbfReader.java:62)
! at com.graphhopper.reader.osm.OSMInputFile.close(OSMInputFile.java:231)
! at com.graphhopper.reader.osm.WaySegmentParser.readOSM(WaySegmentParser.java:400)
! ... 20 common frames omitted
! Causing: java.lang.RuntimeException: Could not parse OSM file: /media/ichsan/SAMPINGAN/Graphhopper/Highway_Riau/Highway_Riau_20230123.osm.pbf
! at com.graphhopper.reader.osm.WaySegmentParser.readOSM(WaySegmentParser.java:401)
! at com.graphhopper.reader.osm.WaySegmentParser.readOSM(WaySegmentParser.java:110)
! at com.graphhopper.reader.osm.OSMReader.readGraph(OSMReader.java:167)
! at com.graphhopper.GraphHopper.importOSM(GraphHopper.java:867)
! at com.graphhopper.GraphHopper.process(GraphHopper.java:803)
! at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:756)
! at com.graphhopper.http.GraphHopperManaged.start(GraphHopperManaged.java:104)
! at io.dropwizard.lifecycle.JettyManaged.doStart(JettyManaged.java:27)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
! at org.eclipse.jetty.server.Server.start(Server.java:423)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
! at org.eclipse.jetty.server.Server.doStart(Server.java:387)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
! at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:53)
! at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:60)
! at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:98)
! at io.dropwizard.cli.Cli.run(Cli.java:78)
! at io.dropwizard.Application.run(Application.java:94)
! at com.graphhopper.application.GraphHopperApplication.main(GraphHopperApplication.java:38)
java.lang.RuntimeException: Could not parse OSM file: /media/ichsan/SAMPINGAN/Graphhopper/Highway_Riau/Highway_Riau_20230123.osm.pbf
        at com.graphhopper.reader.osm.WaySegmentParser.readOSM(WaySegmentParser.java:401)
        at com.graphhopper.reader.osm.WaySegmentParser.readOSM(WaySegmentParser.java:110)
        at com.graphhopper.reader.osm.OSMReader.readGraph(OSMReader.java:167)
        at com.graphhopper.GraphHopper.importOSM(GraphHopper.java:867)
        at com.graphhopper.GraphHopper.process(GraphHopper.java:803)
        at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:756)
        at com.graphhopper.http.GraphHopperManaged.start(GraphHopperManaged.java:104)
        at io.dropwizard.lifecycle.JettyManaged.doStart(JettyManaged.java:27)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.server.Server.start(Server.java:423)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
        at org.eclipse.jetty.server.Server.doStart(Server.java:387)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:53)
        at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:60)
        at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:98)
        at io.dropwizard.cli.Cli.run(Cli.java:78)
        at io.dropwizard.Application.run(Application.java:94)
        at com.graphhopper.application.GraphHopperApplication.main(GraphHopperApplication.java:38)
Caused by: java.lang.RuntimeException: Unable to read PBF file.
        at com.graphhopper.reader.osm.pbf.PbfReader.close(PbfReader.java:62)
        at com.graphhopper.reader.osm.OSMInputFile.close(OSMInputFile.java:231)
        at com.graphhopper.reader.osm.WaySegmentParser.readOSM(WaySegmentParser.java:400)
        ... 20 more
Caused by: java.lang.RuntimeException: A PBF decoding worker thread failed, aborting.
        at com.graphhopper.reader.osm.pbf.PbfDecoder.sendResultsToSink(PbfDecoder.java:85)
        at com.graphhopper.reader.osm.pbf.PbfDecoder.processBlobs(PbfDecoder.java:149)
        at com.graphhopper.reader.osm.pbf.PbfDecoder.run(PbfDecoder.java:159)
        at com.graphhopper.reader.osm.pbf.PbfReader.run(PbfReader.java:48)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: Invalid OSM NODE Id: -4521674; Ids must not be negative
        at com.graphhopper.reader.ReaderElement.<init>(ReaderElement.java:48)
        at com.graphhopper.reader.ReaderElement.<init>(ReaderElement.java:43)
        at com.graphhopper.reader.ReaderNode.<init>(ReaderNode.java:33)
        at com.graphhopper.reader.osm.pbf.PbfBlobDecoder.processNodes(PbfBlobDecoder.java:240)
        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.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        ... 1 more
  • Using Graphhopper 6.2
  • Using OpenJDK 11 in MXLinux 19.4 (based on Debian 10)

Similar problem that doesn’t have any solution

Why do you use reader-gtfs when you don’t use gtfs?
And yes, JOSM uses negative OSM IDs for new IDs that weren’t uploaded yet. So you need to process your pbf file to assign positive IDs since GraphHopper won’t accept negative ones.

I use reader-gtfs/config-example-pt.yaml because I just follow this tutorial graphhopper/README.md at master · graphhopper/graphhopper · GitHub, then I erase gtfs.file loader.

“You need to process your pbf file to assign positive IDs”
How to do that? Please let me know the tutorial for making positive IDs PBF.

If you don’t use public transport / gtfs take a look at the main README: graphhopper/README.md at master · graphhopper/graphhopper · GitHub

I don’t know how to turn negative into positive IDs. But GraphHopper requires the IDs to be positive. Maybe take a look at tools like osmium or osmosis, they might provide some functionality that does this.

This could be useful: Osmium manual pages – osmium-renumber (1)

2 Likes

Thanks for your reference, I will try it

If I find any problem to convert negative IDs to Positive IDs with that tools, I will create new thread.

There is my way to solve my own problem with osmium

  1. Make sure you have installed osmium. In this case, I use Linux (Debian Buster), so I downloaded the osmiom-tool.deb from their website

  2. Sort the IDs, so it has number from the smaller to the bigger.

osmium sort -o sorted.osm.pbf my_own_road_network.osm.pbf
  1. Renumber it, so it doesn’t have any negative IDs
osmium renumber -o renumbered.osm.pbf sorted.osm.pbf
1 Like