From 34d75b1b91b756c02636fe7edee7e9d91e118a92 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 9 Oct 2012 01:00:25 +0200 Subject: [PATCH] Routing with combined intervals --- .../src/net/osmand/router/BinaryRoutePlanner.java | 11 ++++++----- .../src/net/osmand/router/RoutingContext.java | 4 +++- DataExtractionOSM/src/net/osmand/router/routing.xml | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java index c5021fb7c0..83c40f7f8f 100644 --- a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java +++ b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java @@ -319,9 +319,9 @@ public class BinaryRoutePlanner { int memOverhead = (visitedDirectSegments.size() + visitedOppositeSegments.size()) * STANDARD_ROAD_VISITED_OVERHEAD + (graphDirectSegments.size() + graphReverseSegments.size()) * STANDARD_ROAD_IN_QUEUE_OVERHEAD; - String pr = " pend="+segment.parentSegmentEnd +" " +( segment.parentRoute == null ? "" : (" parent=" + segment.parentRoute.road)); - System.out.println("Seg " + segment.road + " ind=" + segment.segmentStart + - " ds=" + ((float)segment.distanceFromStart) + " es="+((float)segment.distanceToEnd) + pr); +// String pr = " pend="+segment.parentSegmentEnd +" " +( segment.parentRoute == null ? "" : (" parent=" + segment.parentRoute.road)); +// System.out.println("Seg " + segment.road + " ind=" + segment.segmentStart + +// " ds=" + ((float)segment.distanceFromStart) + " es="+((float)segment.distanceToEnd) + pr); if(segment instanceof FinalRouteSegment) { if(RoutingContext.SHOW_GC_SIZE){ log.warn("Estimated overhead " + (memOverhead / (1<<20))+ " mb"); @@ -746,9 +746,10 @@ public class BinaryRoutePlanner { visitedSegments.containsKey(calculateRoutePointId(next.road, next.segmentStart, true)); boolean nextMinusNotAllowed = (next.segmentStart == 0) || visitedSegments.containsKey(calculateRoutePointId(next.road, next.segmentStart - 1, false)); + boolean skipSameDirection = next.road.id == segment.road.id && next.segmentStart == segmentEnd; // road.id could be equal on roundabout, but we should accept them boolean alreadyVisited = nextPlusNotAllowed && nextMinusNotAllowed; - if (!alreadyVisited) { + if (!alreadyVisited && !skipSameDirection) { double distanceToEnd = h(ctx, distToFinalPoint, next); // assigned to wrong direction if(next.directionAssigned == -direction){ @@ -773,7 +774,7 @@ public class BinaryRoutePlanner { if (ctx.visitor != null) { ctx.visitor.visitSegment(next, false); } - } else { + } else if(!skipSameDirection){ // the segment was already visited! We need to follow better route if it exists // that is very strange situation and almost exception (it can happen when we underestimate distnceToEnd) if (next.directionAssigned == direction && diff --git a/DataExtractionOSM/src/net/osmand/router/RoutingContext.java b/DataExtractionOSM/src/net/osmand/router/RoutingContext.java index e50c2ec00c..61c8550cfd 100644 --- a/DataExtractionOSM/src/net/osmand/router/RoutingContext.java +++ b/DataExtractionOSM/src/net/osmand/router/RoutingContext.java @@ -226,7 +226,9 @@ public class RoutingContext { routes = new ArrayList(); tileRoutes.put(tileId, routes); } - routes.add(o); + if(!routes.contains(o)){ + routes.add(o); + } } } diff --git a/DataExtractionOSM/src/net/osmand/router/routing.xml b/DataExtractionOSM/src/net/osmand/router/routing.xml index e121f965cc..eb2ca6e95a 100644 --- a/DataExtractionOSM/src/net/osmand/router/routing.xml +++ b/DataExtractionOSM/src/net/osmand/router/routing.xml @@ -10,7 +10,7 @@ - +