From a114ba97f6876927d545c5004b96fb9b162f10e6 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 17 Oct 2018 02:03:44 +0200 Subject: [PATCH] Fix Routing #5764 --- .../net/osmand/router/BinaryRoutePlanner.java | 10 ++++++---- .../osmand/router/RouteResultPreparation.java | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index fb154ae378..60a1abaf99 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -396,7 +396,7 @@ public class BinaryRoutePlanner { final RouteDataObject road = segment.road; boolean initDirectionAllowed = checkIfInitialMovementAllowedOnSegment(ctx, reverseWaySearch, visitedSegments, segment, road); if (TEST_SPECIFIC && road.getId() >> 6 == TEST_ID) { - printRoad(" ! " + +segment.distanceFromStart + " ", segment, reverseWaySearch); + printRoad(" ! " + segment.distanceFromStart + " ", segment, reverseWaySearch); } boolean directionAllowed = initDirectionAllowed; if (!directionAllowed) { @@ -514,9 +514,11 @@ public class BinaryRoutePlanner { directionAllowed = oneway >= 0; } } - - if (directionAllowed && visitedSegments.containsKey(calculateRoutePointId(segment, segment.isPositive()))) { - directionAllowed = false; + RouteSegment visitedSegment = visitedSegments.get(calculateRoutePointId(segment, segment.isPositive())); + if (directionAllowed && visitedSegment != null) { + if (visitedSegment.distanceFromStart <= segment.distanceFromStart) { + directionAllowed = false; + } } return directionAllowed; } diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index ee618358fc..2c975ac500 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -464,12 +464,18 @@ public class RouteResultPreparation { double startLon = start.getLongitude(); double endLat = end.getLatitude(); double endLon = end.getLongitude(); - String msg = MessageFormat.format("", - startLat + "", startLon + "", endLat + "", endLon + "", ctx.config.routerName, - "loadedTiles = \"" + ctx.loadedTiles + "\" " + "visitedSegments = \"" + ctx.visitedSegments + "\" " + - "complete_distance = \"" + completeDistance + "\" " + "complete_time = \"" + completeTime + "\" " + - "routing_time = \"" + ctx.routingTime + "\" "); + + String msg = String.format("", + ctx.config.routerName, startLat, startLon, endLat, endLon, ctx.routingTime, ctx.loadedTiles, + ctx.visitedSegments, completeDistance, completeTime); +// String msg = MessageFormat.format("", +// startLat + "", startLon + "", endLat + "", endLon + "", ctx.config.routerName, +// "loadedTiles = \"" + ctx.loadedTiles + "\" " + "visitedSegments = \"" + ctx.visitedSegments + "\" " + +// "complete_distance = \"" + completeDistance + "\" " + "complete_time = \"" + completeTime + "\" " + +// "routing_time = \"" + ctx.routingTime + "\" "); log.info(msg); println(msg); if (PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST) {