[OSRM-talk] Read the edges out of an osrm file

Jorne De Blaere jorne.deblaere at conundra.eu
Fri Feb 20 16:33:12 UTC 2015

Hey all,

What I have is a generated osrm file. I used the file to set up an osrm server and tried to compute a route. The server response in a good way and returns a plausible distance and travel time (compared with google maps) On the other hand our Java program calculates the same route based on the same osrm file which gives us the same travel distance but a total wrong travel time. So I checked where it goes wrong and what I think is that it goes wrong from the very beginning which is reading in the osrm file. Here I can read in the nodes and edges. The reading of the nodes doesn't seem to be a problem. The problem lies within the reading of the edges.  Both node id's are found and correct, the distance is also correct, singleDirection I'm not sure and weight (what should be the time, right?) is totally wrong.

To solve my problem I checked the C++ source code and found in util > graph_loader.hpp on lines 142 to 152 the structure that loads and parses the osrm data. What I have is the following Java code

  public void readEdge() throws IOException {

        long startId = readUnsignedInt();
        long targetId = readUnsignedInt();
        int distance = readSignedInt();                // [m]
        boolean singleDirection = readBoolean();

        int weight = readSignedInt();                // [1/10s] (40 means 4.0 seconds)
        int type = readUnsignedShort();
        long streetnamePosition = readUnsignedInt();
        boolean roundabout = readBoolean();
        boolean ignoreInGrid = readBoolean();
        boolean accessRestricted = readBoolean();
        boolean contraflow = readBoolean();

        if (forward) {
            osrmGraph.addEdge(startId, targetId, distance, weight, singleDirection);
        } else {
            osrmGraph.addEdge(targetId, startId, distance, weight, singleDirection);

Now notice that singleDirection is a boolean in this code and a short in the C++ code. Which differs a byte (I think?). I tried to read in a short instead but then thinks got mixed up and the reading of my edges is totally wrong (id's, distance, etc.).
Can anyone tell me what I'm doing wrong or have a clue what else can be wrong?

Kind regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osrm-talk/attachments/20150220/7c08bd32/attachment.html>

More information about the OSRM-talk mailing list