logo separator

[mkgmap-dev] [mkgmap] Bug or missunderstanding?

From Johann Gail johann.gail at gmx.de on Sat Feb 14 22:07:59 GMT 2009

I'm looking at the moment at RoadDef.java, lines 352 to 358.
As I understand it by the comments, there should be a bitfield converted 
into a byte array and in some cases be shifted by one.
I think the inner loop in 354 is wrong. At least I see no sense in the 
loop limits.
Can anyone give me a comment or explain what is intended here?

The next question appearing to me:
What happens, if the road has no final node (a dead end road)? Is there 
also a zero bit needed?

        // this is related to the number of nodes, but there
        // is more to it...
        // For now, shift by one if the first node is not a
        // routing node. Supposedly, other holes are also
        // possible.
        // This might be unnecessary if we just make sure
        // that every road starts with a node.
        int nbits = nnodes;
        if (!startsWithNode)
            nbits++;
        writer.putChar((char) nbits);
        boolean[] bits = new boolean[nbits];
        for (int i = 0; i < bits.length; i++)
            bits[i] = true;
        if (!startsWithNode)
            bits[0] = false;
352:        for (int i = 0; i < bits.length; i += 8) {
353:           int b = 0;
354:            for (int j = 0; j < bits.length - i; j++)
                if (bits[j])
                    b |= 1 << j;
            writer.put((byte) b);
        }




More information about the mkgmap-dev mailing list