Small fixes

This commit is contained in:
Victor Shcherb 2012-11-11 12:04:06 +01:00
parent 3bedf18723
commit a9e186a58d
5 changed files with 22 additions and 46 deletions

View file

@ -265,39 +265,6 @@ public class BinaryRoutePlanner {
" ds=" + ((float)segment.distanceFromStart) + " es="+((float)segment.distanceToEnd) + pr);
}
private void relaxNotNeededSegments(RoutingContext ctx, PriorityQueue<RouteSegment> graphSegments, boolean inverse) {
// relax strategy is incorrect if we already found a route but it is very long due to some obstacles
RouteSegment next = graphSegments.peek();
double mine = next.distanceFromStart;
// int before = graphSegments.size();
// SegmentStat statStart = new SegmentStat("Distance from start (" + inverse + ") ");
// SegmentStat statEnd = new SegmentStat("Distance to end (" + inverse + ") ");
Iterator<RouteSegment> iterator = graphSegments.iterator();
while (iterator.hasNext()) {
RouteSegment s = iterator.next();
// statStart.addNumber((float) s.distanceFromStart);
// statEnd.addNumber((float) s.distanceToEnd);
if (s.distanceFromStart > mine) {
mine = s.distanceFromStart;
}
}
double d = mine - 50000; // ctx.config.RELAX_NODES_IF_START_DIST_COEF;
if (d > 0) {
iterator = graphSegments.iterator();
while (iterator.hasNext()) {
RouteSegment s = iterator.next();
if (s.distanceFromStart < d) {
ctx.relaxedSegments++;
iterator.remove();
}
}
}
// int after = graphSegments.size();
// println(statStart.toString());
// println(statEnd.toString());
// println("Relaxing : before " + before + " after " + after + " minend " + ((float) mine));
}
private float estimatedDistance(final RoutingContext ctx, int targetEndX, int targetEndY,
int startX, int startY) {
double distance = squareRootDist(startX, startY, targetEndX, targetEndY);
@ -409,6 +376,13 @@ public class BinaryRoutePlanner {
obstaclesTime = (float) ctx.getRouter().calculateTurnTime(segment, direction? segment.getRoad().getPointsLength() - 1 : 0,
segment.getParentRoute(), segment.getParentSegmentEnd());
}
if(ctx.firstRoadId == calculateRoutePointId(road, segment.getSegmentStart(), true) ) {
if(direction && ctx.firstRoadDirection < 0) {
obstaclesTime += 500;
} else if(!direction && ctx.firstRoadDirection > 0) {
obstaclesTime += 500;
}
}
float segmentDist = 0;
// +/- diff from middle point
int segmentEnd = segment.getSegmentStart();
@ -509,13 +483,7 @@ public class BinaryRoutePlanner {
final int middle = segment.getSegmentStart();
int oneway = ctx.getRouter().isOneWay(road);
// use positive direction as agreed
if(ctx.firstRoadId == calculateRoutePointId(road, middle, true) ) {
if(direction){
directionAllowed = ctx.firstRoadDirection >= 0;
} else {
directionAllowed = ctx.firstRoadDirection <= 0;
}
} else if (!reverseWaySearch) {
if (!reverseWaySearch) {
if(direction){
directionAllowed = oneway >= 0;
} else {

View file

@ -279,9 +279,13 @@ public class BinaryRoutePlannerOld {
boolean minusAllowed;
boolean plusAllowed;
if(ctx.firstRoadId == nt) {
minusAllowed = ctx.firstRoadDirection <= 0;
plusAllowed = ctx.firstRoadDirection >= 0;
} else if (!reverseWaySearch) {
if(ctx.firstRoadDirection < 0) {
obstaclePlusTime += 500;
} else if(ctx.firstRoadDirection > 0) {
obstacleMinusTime += 500;
}
}
if (!reverseWaySearch) {
minusAllowed = oneway <= 0;
plusAllowed = oneway >= 0;
} else {

View file

@ -215,6 +215,7 @@ public class RoutePlannerFrontEnd {
local.previouslyCalculatedRoute = firstPartRecalculatedRoute;
}
local.visitor = ctx.visitor;
local.calculationProgress = ctx.calculationProgress;
List<RouteSegmentResult> res = searchRouteInternalPrepare(local, points.get(i), points.get(i + 1), leftSideNavigation);
results.addAll(res);

View file

@ -671,8 +671,8 @@ public class RoutingHelper {
if (all > 0) {
int t = (int) Math.min(p * p / (all * all) * 100f, 99);
progress.setProgress(t);
updateProgress(calculationProgress);
}
updateProgress(calculationProgress);
} else {
progress.setVisibility(View.GONE);
}

View file

@ -234,8 +234,11 @@ bool processRouteSegment(RoutingContext* ctx, bool reverseWaySearch, SEGMENTS_QU
bool minusAllowed;
bool plusAllowed;
if(ctx->firstRoadId == nt) {
minusAllowed = ctx->firstRoadDirection <= 0;
plusAllowed = ctx->firstRoadDirection >= 0;
if(ctx->firstRoadDirection < 0) {
obstaclePlusTime += 500;
} else if(ctx->firstRoadDirection > 0) {
obstacleMinusTime += 500;
}
} else if (!reverseWaySearch) {
minusAllowed = oneway <= 0;
plusAllowed = oneway >= 0;