Update routing

This commit is contained in:
Victor Shcherb 2012-07-11 01:16:00 +02:00
parent a7dde925ca
commit 0a2199f488
4 changed files with 72 additions and 20 deletions

View file

@ -609,10 +609,20 @@ public class BinaryRoutePlanner {
RoutingTile tile = loadRoutes(ctx, x, y); RoutingTile tile = loadRoutes(ctx, x, y);
// 2.1 calculate possible obstacle plus time // 2.1 calculate possible obstacle plus time
if(d > 0){ if(segmentEnd > middle){
obstaclePlusTime += ctx.getRouter().defineObstacle(road, segmentEnd); double obstacle = ctx.getRouter().defineObstacle(road, segmentEnd);
} else if(d < 0) { if(obstacle < 0){
obstacleMinusTime += ctx.getRouter().defineObstacle(road, segmentEnd); 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; speed = ctx.getRouter().getMinDefaultSpeed() * priority;
} }
double distStartObstacles = segment.distanceFromStart + ( d > 0? obstaclePlusTime : obstacleMinusTime) + double distStartObstacles = segment.distanceFromStart + ( segmentEnd > middle? obstaclePlusTime : obstacleMinusTime) +
distOnRoadToPass / speed; distOnRoadToPass / speed;
double distToFinalPoint = squareRootDist(x, y, targetEndX, targetEndY); 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), double d = measuredDist(road.getPoint31XTile(j), road.getPoint31YTile(j), road.getPoint31XTile(next),
road.getPoint31YTile(next)); road.getPoint31YTile(next));
distance += d; 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<RouteSegmentResult> attachedRoutes = rr.getAttachedRoutes(next); List<RouteSegmentResult> attachedRoutes = rr.getAttachedRoutes(next);
if (next != rr.getEndPointIndex() && !rr.getObject().roundabout() && attachedRoutes != null) { if (next != rr.getEndPointIndex() && !rr.getObject().roundabout() && attachedRoutes != null) {

View file

@ -13,7 +13,7 @@ public class GeneralRouter extends VehicleRouter {
Map<String, Double> highwaySpeed = new LinkedHashMap<String, Double>(); Map<String, Double> highwaySpeed = new LinkedHashMap<String, Double>();
Map<String, Double> highwayPriorities = new LinkedHashMap<String, Double>(); Map<String, Double> highwayPriorities = new LinkedHashMap<String, Double>();
Map<String, Double> highwayFuturePriorities = new LinkedHashMap<String, Double>(); Map<String, Double> highwayFuturePriorities = new LinkedHashMap<String, Double>();
Map<String, Double> avoidElements = new LinkedHashMap<String, Double>(); Map<String, Double> avoid = new LinkedHashMap<String, Double>();
Map<String, Double> obstacles = new LinkedHashMap<String, Double>(); Map<String, Double> obstacles = new LinkedHashMap<String, Double>();
boolean followSpeedLimitations = true; boolean followSpeedLimitations = true;
boolean restrictionsAware = true; boolean restrictionsAware = true;
@ -40,7 +40,7 @@ public class GeneralRouter extends VehicleRouter {
for(int i=0; i<s.length; i++) { for(int i=0; i<s.length; i++) {
RouteTypeRule r = way.region.quickGetEncodingRule(s[i]); RouteTypeRule r = way.region.quickGetEncodingRule(s[i]);
String k = r.getTag() + "$" + r.getValue(); String k = r.getTag() + "$" + r.getValue();
if(avoidElements.containsKey(k)) { if(avoid.containsKey(k)) {
return false; return false;
} }
} }
@ -95,7 +95,18 @@ public class GeneralRouter extends VehicleRouter {
} }
} }
Double value = highwaySpeed.get(road.getHighway()); Double value = null;
for (int i = 0; i < road.types.length; i++) {
RouteTypeRule r = road.region.quickGetEncodingRule(road.types[i]);
String highway = r.highwayRoad();
if (highway != null && highwaySpeed.containsKey(highway)) {
value = highwaySpeed.get(highway);
break;
} else if(highwaySpeed.containsKey(r.getTag()+"$"+r.getValue())){
value = highwaySpeed.get(r.getTag()+"$"+r.getValue());
break;
}
}
if (value == null) { if (value == null) {
value = minDefaultSpeed; value = minDefaultSpeed;
} }
@ -104,8 +115,16 @@ public class GeneralRouter extends VehicleRouter {
@Override @Override
public double defineSpeedPriority(RouteDataObject road) { public double defineSpeedPriority(RouteDataObject road) {
String highway = road.getHighway(); double priority = 1;
double priority = highway != null && highwayPriorities.containsKey(highway) ? highwayPriorities.get(highway) : 1d; for (int i = 0; i < road.types.length; i++) {
RouteTypeRule r = road.region.quickGetEncodingRule(road.types[i]);
String highway = r.highwayRoad();
if (highway != null && highwayPriorities.containsKey(highway)) {
priority *= highwayPriorities.get(highway);
} else if(highwayPriorities.containsKey(r.getTag()+"$"+r.getValue())){
priority *= highwayPriorities.get(r.getTag()+"$"+r.getValue());
}
}
return priority; return priority;
} }

View file

@ -178,8 +178,13 @@ public class RoutingConfiguration {
0)); 0));
} else if("avoid".equals(name)) { } else if("avoid".equals(name)) {
String key = attributes.getValue("tag") + "$" + attributes.getValue("value"); String key = attributes.getValue("tag") + "$" + attributes.getValue("value");
currentRouter.avoidElements.put(key, parseSilentDouble(attributes.getValue("coefficient"), double priority = parseSilentDouble(attributes.getValue("decreasedPriority"),
0)); 0);
if(priority == 0) {
currentRouter.avoid.put(key, priority);
} else {
currentRouter.highwayPriorities.put(key, priority);
}
} }
} }

View file

@ -24,10 +24,18 @@
<!-- 0 - 2 ways, 1 - direct way, -1 - reverse way --> <!-- 0 - 2 ways, 1 - direct way, -1 - reverse way -->
<attribute name="planRoadDirection" value="0" /> <attribute name="planRoadDirection" value="0" />
<!-- highway value="motorway" speed="110" priority="1.5" dynamicPriority="1.4" --> <!-- HELP INFORMATION ABOUT FILE -->
<!-- Highway defines acceptable route for routingProfile, speed in km/h (if it is not specified on level road) --> <!-- 1) Highway defines acceptable route for routingProfile, speed in km/h (if it is not specified on level road) -->
<!-- priority is multiplicator for already passed road (consider it is an accelerator of the road) --> <!-- priority is multiplicator for already passed road (consider it is an accelerator of the road) -->
<!-- dynamicPriority is multiplicator for future roads used by heuristic useDynamicRoadPrioritising --> <!-- dynamicPriority is multiplicator for future roads used by heuristic useDynamicRoadPrioritising -->
<!-- <highway value="living_street" speed="25" priority="0.5" dynamicPriority="0.5"/> -->
<!-- <road tag="route" value="ferry" speed="15" priority="1.0" dynamicPriority="0.7"/> -->
<!-- 2) Obstacle defines a point of the road and how it could be passed by vehicle -->
<!-- penalty is measured in time and -1 means it could not be passed! -->
<!-- <obstacle tag="highway" value="traffic_signals" penalty="35"/> -->
<!-- 3) Avoid describes what road should be completely avoided or passed with multiplied (decreased) priority -->
<!-- <avoid tag="access" value="no" decreasedPriority="0.9"/> -->
<!-- obstacle tag="highway" value="traffic_signals" penalty="35", penalty measured in seconds --> <!-- obstacle tag="highway" value="traffic_signals" penalty="35", penalty measured in seconds -->
<routingProfile name="car" baseProfile="car" restrictionsAware="true" minDefaultSpeed="45.0" maxDefaultSpeed="110.0" <routingProfile name="car" baseProfile="car" restrictionsAware="true" minDefaultSpeed="45.0" maxDefaultSpeed="110.0"
@ -69,8 +77,13 @@
<obstacle tag="highway" value="traffic_signals" penalty="35"/> <obstacle tag="highway" value="traffic_signals" penalty="35"/>
<obstacle tag="railway" value="crossing" penalty="25"/> <obstacle tag="railway" value="crossing" penalty="25"/>
<obstacle tag="railway" value="level_crossing" penalty="25"/> <obstacle tag="railway" value="level_crossing" penalty="25"/>
<obstacle tag="motorcar" value="no" penalty="-1"/>
<obstacle tag="barrier" value="lift_gate" penalty="-1"/>
<obstacle tag="barrier" value="gate" penalty="-1"/>
<obstacle tag="barrier" value="bollard" penalty="-1"/>
<!-- in future can be multiplicator can be added (like coefficient="0.1") --> <!-- -->
<avoid tag="tracktype" value="grade5" decreasedPriority="0.6"/>
<avoid tag="access" value="no"/> <avoid tag="access" value="no"/>
<avoid tag="motorcycle" value="no"/> <avoid tag="motorcycle" value="no"/>
<avoid tag="motorcar" value="no"/> <avoid tag="motorcar" value="no"/>
@ -117,7 +130,7 @@
<routingProfile name="pedestrian" baseProfile="pedestrian" restrictionsAware="false" minDefaultSpeed="3" maxDefaultSpeed="5" <routingProfile name="pedestrian" baseProfile="pedestrian" restrictionsAware="false" minDefaultSpeed="3" maxDefaultSpeed="5"
leftTurn="0" rightTurn="0" followSpeedLimitations="false" onewayAware="false"> leftTurn="0" rightTurn="0" followSpeedLimitations="false" onewayAware="false">
<attribute name="heuristicCoefficient" value="1.2" /> <attribute name="heuristicCoefficient" value="1.2" />
<highway value="motorway" speed="5" priority="0.7" dynamicPriority="0.7"/> <highway value="motorway" speed="5" priority="0.7" dynamicPriority="0.7"/>
<highway value="motorway_link" speed="5" priority="0.7" dynamicPriority="0.7"/> <highway value="motorway_link" speed="5" priority="0.7" dynamicPriority="0.7"/>