[PATCH] pink line in dead end street.

After some digging in the code I found a place, where is a special treatment for roads starting with or without a node. I give it just a try and duplicated this code for the end of the road. With these changes the wrong pink line in roads with dead end has disappeared in my cases. If this patch is working, then the superfluous nodes at end of streets can be removed again. Here the patch: Index: src/uk/me/parabola/imgfmt/app/net/RoadDef.java =================================================================== --- src/uk/me/parabola/imgfmt/app/net/RoadDef.java (Revision 881) +++ src/uk/me/parabola/imgfmt/app/net/RoadDef.java (Arbeitskopie) @@ -281,6 +281,7 @@ // the first point in the road is a node (the above routing node) private boolean startsWithNode = true; + private boolean endsWithNode = true; // number of nodes in the road private int nnodes; @@ -310,6 +311,10 @@ startsWithNode = s; } + public void setEndsWithNode(boolean s) { + endsWithNode = s; + } + public void setNumNodes(int n) { nnodes = n; } @@ -343,17 +348,21 @@ int nbits = nnodes; if (!startsWithNode) nbits++; + if (!endsWithNode) + 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; + if (!endsWithNode) + bits[bits.length] = false; for (int i = 0; i < bits.length; i += 8) { int b = 0; - for (int j = 0; j < bits.length - i; j++) + for (int j = i*8; j < bits.length; j++) if (bits[j]) - b |= 1 << j; + b |= 1 << j-i*8; writer.put((byte) b); } } Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java =================================================================== --- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (Revision 881) +++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java (Arbeitskopie) @@ -433,6 +433,7 @@ } road.setStartsWithNode(nodeIndices.get(0) == 0); + road.setEndsWithNode(nodeIndices.get(numNodes-1) == points.size() - 1); road.setInternalNodes(hasInternalNodes); } Index: src/uk/me/parabola/mkgmap/general/MapRoad.java =================================================================== --- src/uk/me/parabola/mkgmap/general/MapRoad.java (Revision 881) +++ src/uk/me/parabola/mkgmap/general/MapRoad.java (Arbeitskopie) @@ -90,6 +90,10 @@ this.roadDef.setStartsWithNode(s); } + public void setEndsWithNode(boolean s) { + this.roadDef.setStartsWithNode(s); + } + public void setInternalNodes(boolean s) { this.roadDef.setInternalNodes(s); }

On Sun, Feb 15, 2009 at 10:52:03AM +0100, Johann Gail wrote:
But I made one change:
+ bits[bits.length] = false;
This surely must be: bits[bits.length-1] = false;
Youre right. I'm astonished that my code was running without exceptions.
Yes, so that line must not have run and so endsWithNode was never true. So the change you saw must have come from changing the loop. On looking at it when I'm less tired, I'm think that the loop is still wrong. ..Steve
participants (2)
-
Johann Gail
-
Steve Ratcliffe