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); " 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, private float estimatedDistance(final RoutingContext ctx, int targetEndX, int targetEndY,
int startX, int startY) { int startX, int startY) {
double distance = squareRootDist(startX, startY, targetEndX, targetEndY); 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, obstaclesTime = (float) ctx.getRouter().calculateTurnTime(segment, direction? segment.getRoad().getPointsLength() - 1 : 0,
segment.getParentRoute(), segment.getParentSegmentEnd()); 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; float segmentDist = 0;
// +/- diff from middle point // +/- diff from middle point
int segmentEnd = segment.getSegmentStart(); int segmentEnd = segment.getSegmentStart();
@ -509,13 +483,7 @@ public class BinaryRoutePlanner {
final int middle = segment.getSegmentStart(); final int middle = segment.getSegmentStart();
int oneway = ctx.getRouter().isOneWay(road); int oneway = ctx.getRouter().isOneWay(road);
// use positive direction as agreed // use positive direction as agreed
if(ctx.firstRoadId == calculateRoutePointId(road, middle, true) ) { if (!reverseWaySearch) {
if(direction){
directionAllowed = ctx.firstRoadDirection >= 0;
} else {
directionAllowed = ctx.firstRoadDirection <= 0;
}
} else if (!reverseWaySearch) {
if(direction){ if(direction){
directionAllowed = oneway >= 0; directionAllowed = oneway >= 0;
} else { } else {

View file

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

View file

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

View file

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

View file

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