From 0a2199f488095379246ac9c7b88eb4b79df3156d Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 11 Jul 2012 01:16:00 +0200 Subject: [PATCH] Update routing --- .../net/osmand/router/BinaryRoutePlanner.java | 27 ++++++++++++---- .../src/net/osmand/router/GeneralRouter.java | 31 +++++++++++++++---- .../osmand/router/RoutingConfiguration.java | 9 ++++-- .../src/net/osmand/router/routing.xml | 25 +++++++++++---- 4 files changed, 72 insertions(+), 20 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java index 76e2c442d2..5a15434b35 100644 --- a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java +++ b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java @@ -609,10 +609,20 @@ public class BinaryRoutePlanner { RoutingTile tile = loadRoutes(ctx, x, y); // 2.1 calculate possible obstacle plus time - if(d > 0){ - obstaclePlusTime += ctx.getRouter().defineObstacle(road, segmentEnd); - } else if(d < 0) { - obstacleMinusTime += ctx.getRouter().defineObstacle(road, segmentEnd); + if(segmentEnd > middle){ + double obstacle = ctx.getRouter().defineObstacle(road, segmentEnd); + if(obstacle < 0){ + plusAllowed = false; + continue; + } + obstaclePlusTime += obstacle; + } else if(segmentEnd < middle) { + double obstacle = ctx.getRouter().defineObstacle(road, segmentEnd); + if(obstacle < 0){ + minusAllowed = false; + continue; + } + obstacleMinusTime += obstacle; } @@ -634,7 +644,7 @@ public class BinaryRoutePlanner { speed = ctx.getRouter().getMinDefaultSpeed() * priority; } - double distStartObstacles = segment.distanceFromStart + ( d > 0? obstaclePlusTime : obstacleMinusTime) + + double distStartObstacles = segment.distanceFromStart + ( segmentEnd > middle? obstaclePlusTime : obstacleMinusTime) + distOnRoadToPass / speed; double distToFinalPoint = squareRootDist(x, y, targetEndX, targetEndY); @@ -865,7 +875,12 @@ public class BinaryRoutePlanner { double d = measuredDist(road.getPoint31XTile(j), road.getPoint31YTile(j), road.getPoint31XTile(next), road.getPoint31YTile(next)); distance += d; - distOnRoadToPass += d / speed + ctx.getRouter().defineObstacle(road, j); + double obstacle = ctx.getRouter().defineObstacle(road, j); + if(obstacle >= 0) { + distOnRoadToPass += d / speed + obstacle; + } else { + System.err.println("Something completely wrong if we pass obstacle < 0 " + Arrays.toString(road.getPointTypes(j))); + } List attachedRoutes = rr.getAttachedRoutes(next); if (next != rr.getEndPointIndex() && !rr.getObject().roundabout() && attachedRoutes != null) { diff --git a/DataExtractionOSM/src/net/osmand/router/GeneralRouter.java b/DataExtractionOSM/src/net/osmand/router/GeneralRouter.java index 51c39ac157..d8f33f91d1 100644 --- a/DataExtractionOSM/src/net/osmand/router/GeneralRouter.java +++ b/DataExtractionOSM/src/net/osmand/router/GeneralRouter.java @@ -13,7 +13,7 @@ public class GeneralRouter extends VehicleRouter { Map highwaySpeed = new LinkedHashMap(); Map highwayPriorities = new LinkedHashMap(); Map highwayFuturePriorities = new LinkedHashMap(); - Map avoidElements = new LinkedHashMap(); + Map avoid = new LinkedHashMap(); Map obstacles = new LinkedHashMap(); boolean followSpeedLimitations = true; boolean restrictionsAware = true; @@ -40,7 +40,7 @@ public class GeneralRouter extends VehicleRouter { for(int i=0; i - - - - + + + + + + + + + + + + + + + + - + + @@ -117,7 +130,7 @@ - +