New experimental routing

This commit is contained in:
Victor Shcherb 2014-07-18 17:50:38 +02:00
parent aa68c75528
commit 2eca9ec77f
3 changed files with 23 additions and 6 deletions

View file

@ -136,11 +136,11 @@ public class BinaryRoutePlanner {
} }
if (ctx.planRouteIn2Directions()) { if (ctx.planRouteIn2Directions()) {
forwardSearch = (nonHeuristicSegmentsComparator.compare(graphDirectSegments.peek(), graphReverseSegments.peek()) < 0); forwardSearch = (nonHeuristicSegmentsComparator.compare(graphDirectSegments.peek(), graphReverseSegments.peek()) < 0);
if (graphDirectSegments.size() * 2 > graphReverseSegments.size()) { // if (graphDirectSegments.size() * 2 > graphReverseSegments.size()) {
forwardSearch = false; // forwardSearch = false;
} else if (graphDirectSegments.size() < 2 * graphReverseSegments.size()) { // } else if (graphDirectSegments.size() < 2 * graphReverseSegments.size()) {
forwardSearch = true; // forwardSearch = true;
} // }
} else { } else {
// different strategy : use onedirectional graph // different strategy : use onedirectional graph
forwardSearch = onlyForward; forwardSearch = onlyForward;

View file

@ -57,7 +57,8 @@ public class GeneralRouter implements VehicleRouter {
ACCESS("access"), ACCESS("access"),
OBSTACLES("obstacle_time"), OBSTACLES("obstacle_time"),
ROUTING_OBSTACLES("obstacle"), ROUTING_OBSTACLES("obstacle"),
ONEWAY("oneway"); ONEWAY("oneway"),
PENALTY_TRANSITION("penalty_transition");
public final String nm; public final String nm;
RouteDataObjectAttribute(String name) { RouteDataObjectAttribute(String name) {
nm = name; nm = name;
@ -272,6 +273,11 @@ public class GeneralRouter implements VehicleRouter {
public int isOneWay(RouteDataObject road) { public int isOneWay(RouteDataObject road) {
return getObjContext(RouteDataObjectAttribute.ONEWAY).evaluateInt(road, 0); return getObjContext(RouteDataObjectAttribute.ONEWAY).evaluateInt(road, 0);
} }
@Override
public float getPenaltyTransition(RouteDataObject road) {
return getObjContext(RouteDataObjectAttribute.PENALTY_TRANSITION).evaluateInt(road, 0);
}
@Override @Override
public float defineRoutingSpeed(RouteDataObject road) { public float defineRoutingSpeed(RouteDataObject road) {
@ -323,6 +329,12 @@ public class GeneralRouter implements VehicleRouter {
} }
} }
float ts = getPenaltyTransition(segment.getRoad());
float prevTs = getPenaltyTransition(prev.getRoad());
if(prevTs != ts) {
if(ts > prevTs) return (ts - prevTs);
}
if(segment.getRoad().roundabout() && !prev.getRoad().roundabout()) { if(segment.getRoad().roundabout() && !prev.getRoad().roundabout()) {
double rt = getRoundaboutTurn(); double rt = getRoundaboutTurn();
if(rt > 0) { if(rt > 0) {

View file

@ -22,6 +22,11 @@ public interface VehicleRouter {
*/ */
public int isOneWay(RouteDataObject road); public int isOneWay(RouteDataObject road);
/**
* return penalty transition in seconds
*/
public float getPenaltyTransition(RouteDataObject road);
/** /**
* return delay in seconds (0 no obstacles) * return delay in seconds (0 no obstacles)
*/ */