From ce564e82cfd7084dbe42fbc332f2300775426e39 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 18 Oct 2012 18:42:44 +0200 Subject: [PATCH] Fix critical bug with roundabout --- .../src/net/osmand/router/RoutingContext.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/router/RoutingContext.java b/DataExtractionOSM/src/net/osmand/router/RoutingContext.java index f0b29c4f56..f426f89a85 100644 --- a/DataExtractionOSM/src/net/osmand/router/RoutingContext.java +++ b/DataExtractionOSM/src/net/osmand/router/RoutingContext.java @@ -300,7 +300,7 @@ public class RoutingContext { for (RouteDataObject ro : routes) { for (int i = 0; i < ro.pointsX.length; i++) { if (ro.getPoint31XTile(i) == x31 && ro.getPoint31YTile(i) == y31) { - excludeDuplications.put(ro.id, ro); + excludeDuplications.put(calcRouteId(ro, i), ro); RouteSegment segment = new RouteSegment(ro, i); segment.next = original; original = segment; @@ -560,6 +560,10 @@ public class RoutingContext { return usedMem1; } + + private static long calcRouteId(RouteDataObject o, int ind) { + return (o.getId() << 10) + ind; + } public static class RoutingSubregionTile { @@ -614,9 +618,9 @@ public class RoutingContext { RouteSegment segment = routes.get(l); while (segment != null) { RouteDataObject ro = segment.road; - RouteDataObject toCmp = excludeDuplications.get(ro.id); + RouteDataObject toCmp = excludeDuplications.get(calcRouteId(ro, segment.getSegmentStart())); if (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength()) { - excludeDuplications.put(ro.id, ro); + excludeDuplications.put(calcRouteId(ro, segment.getSegmentStart()), ro); RouteSegment s = new RouteSegment(ro, segment.getSegmentStart()); s.next = original; original = s; @@ -631,18 +635,21 @@ public class RoutingContext { ctx.timeToLoad += (System.nanoTime() - nanoTime); if (res != null) { for (RouteDataObject ro : res) { - RouteDataObject toCmp = excludeDuplications.get(ro.id); - boolean accept = ro != null && (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength()); - if (ctx != null && accept) { + + boolean accept = ro != null; + if (ctx != null) { accept = ctx.getRouter().acceptLine(ro); } if (accept) { - excludeDuplications.put(ro.id, ro); for (int i = 0; i < ro.pointsX.length; i++) { if (ro.getPoint31XTile(i) == x31 && ro.getPoint31YTile(i) == y31) { - RouteSegment segment = new RouteSegment(ro, i); - segment.next = original; - original = segment; + RouteDataObject toCmp = excludeDuplications.get(calcRouteId(ro, i)); + if (toCmp == null || toCmp.getPointsLength() < ro.getPointsLength()) { + RouteSegment segment = new RouteSegment(ro, i); + segment.next = original; + original = segment; + excludeDuplications.put(calcRouteId(ro, i), ro); + } } } }