
Hi, it looks like the looped way check doesn't find all self intersection ways. It just checks if some waypoint is the same like the last way point. It misses loops somewhere in the middle of the way. This results in route calculation hangups on the nuvi. Here comes a patch for the nod branch that fixes the problem. The new function should also work with multiple loops in a way. The check for the two point loops needs a closer look. For now we only check if there are more then 2 points in the way. I have tried a alternate way by checking the distance between the intersection points to be greater the 1 (j-pIdx>1). This will produce some more loop warnings. In one case I was not able to see the reason for the warning so I commented the alternate check out for now. Berni. 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 (working copy) @@ -261,36 +261,42 @@ } } - boolean looped = false; - List<Coord> wayPoints = way.getPoints(); - int numPointsInWay = wayPoints.size(); + int numPointsInWay; + int pIdx; + boolean tinyLoop = false; - if(numPointsInWay > 1) { - // check if the last point in the way is the same as - // any other point in the way - if it is, there's a loop - Coord wayEndCoord = wayPoints.get(numPointsInWay - 1); - for(int i = 0; !looped && i < numPointsInWay - 1; ++i) { - if(wayPoints.get(i) == wayEndCoord) - looped = true; + do + { + List<Coord> wayPoints = way.getPoints(); + numPointsInWay = wayPoints.size(); + boolean looped = false; + + // check if the way contains a loop or self intersection + for(pIdx = 0; !looped && pIdx < (numPointsInWay - 1); pIdx++) { + for(int j = pIdx+1; !looped && j < numPointsInWay; j++) { + if(wayPoints.get(pIdx) == wayPoints.get(j)) + { + if(numPointsInWay > 2) // (j-pIdx > 1) will find more ugly stuff + { + Way loopTail = splitWayAt(way, pIdx + 1); + addRoadWithoutLoops(way, gt); + way = loopTail; // the rest + looped = true; + } + else + { + System.err.println("Ignoring looped way with only 2 points located at " + wayPoints.get(0).toDegreeString()); + looped = true; + tinyLoop = true; + } + } + } } - } - - if(looped) { - if(numPointsInWay > 2) { - // create a new way to replace the last segment - Way loopTail = splitWayAt(way, numPointsInWay - 2); - // make roads from the un-looped ways - addRoadWithoutLoops(way, gt); - addRoadWithoutLoops(loopTail, gt); - } - else { - System.err.println("Ignoring looped way with only 2 points located at " + wayPoints.get(0).toDegreeString()); - } - } - else { - // make a road from the way (it wasn't looped) + } while(pIdx < numPointsInWay -1 && !tinyLoop); // until we are at the end of the way + + if(!tinyLoop) addRoadWithoutLoops(way, gt); - } + } void addRoadWithoutLoops(Way way, GType gt) {