R: [mkgmap-dev] [PATCH v3] - merge nodes to remove evil short arcs

Hi, I switched on the mkgmap logging and I noticed, compiling "the most simple failing map" I attched to a mail yesterday, that when the routing is faulty (routing nodes collapsing) the TableA used by the NOD builder has 5 nodes and 5 arcs. This should means that the central node (the collapsed) has a routing Arc going to itself. This may cause the problem. In the file \parabola\imgfmt\app\net\NOD1Part.java there is the function that populates the TableA. The original function is: /** * Add a node to this part. * * The node is used to populate the tables. If an * arc points outside the bbox, we know it's not * an internal arc. It might still turn into an * external arc at a deeper level of recursion. */ public void addNode(RouteNode node) { assert bbox == null || bbox.contains(node.getCoord()) : "trying to add out-of-bounds node: " + node; bboxActual.extend(node.getCoord()); nodes.add(node); for (RouteArc arc : node.arcsIteration()) { tabA.addArc(arc); RouteNode dest = arc.getDest(); if (bbox != null && !bbox.contains(dest.getCoord())) { arc.setInternal(false); tabB.addNode(dest); } } nodesSize += node.boundSize(); } The instruction adding the arcs to the table A is tabA.addArc(arc). We should try to change the function avoiding to add an arc to Table A if the arc from a node points to itself. I propose to change the code in a way similar to the following: .... nodes.add(node); for (RouteArc arc : node.arcsIteration()) { RouteNode dest = arc.getDest(); if (dest!=node) tabA.addArc(arc); if (bbox != null && !bbox.contains(dest.getCoord())) { ..... I don't know if this works, (for example I don't if the comparison dest!=node can be done like that) but it should easy to try. Ciao.

Hi Marko, Many thanks for your suggestion about avoiding adding an arc from a node to itself. Your detective work/thinking has paid off. Actually, the real problem is much earlier in the processing and I have now committed a fix. The problem is that you can't use Coord objects as keys in HashMaps because two Coords with the same coordinates map to the same object rather than distinct objects. The bug is mine, I introduced it when I wrote the OSM support for routing. The fix is trivial, use IdentityHashMaps instead. I had already come across this issue when working on the node merging patch yesterday but it didn't occur to me to look at the rest of the code to see if the problem happened elsewhere. However, although that fixes a real bug that was causing routing crashes, it doesn't make maps that contain short segments work right. Even with that fix, the sample map I have been trying still doesn't route OK through the short segment unless I also use the merging nodes patch I have posted today. Cheers, Mark
participants (2)
-
marco_certelli@yahoo.it
-
Mark Burton