Improve smart recalculation

This commit is contained in:
Victor Shcherb 2012-07-19 00:46:12 +02:00
parent dc57d3929a
commit 85524b2ce7
2 changed files with 22 additions and 12 deletions

View file

@ -213,7 +213,18 @@ public class BinaryRoutePlanner {
boolean runRecalculation = ctx.previouslyCalculatedRoute != null && ctx.previouslyCalculatedRoute.size() > 0; boolean runRecalculation = ctx.previouslyCalculatedRoute != null && ctx.previouslyCalculatedRoute.size() > 0;
if (runRecalculation) { if (runRecalculation) {
RouteSegment previous = null; RouteSegment previous = null;
List<RouteSegmentResult> rlist = new ArrayList<RouteSegmentResult>();
// always recalculate first 2.5 km
int distanceThreshold = 2500;
float threshold = 0;
for(RouteSegmentResult rr : ctx.previouslyCalculatedRoute) { for(RouteSegmentResult rr : ctx.previouslyCalculatedRoute) {
threshold += rr.getDistance();
if(threshold > distanceThreshold) {
rlist.add(rr);
}
}
if (rlist.size() > 0) {
for (RouteSegmentResult rr : rlist) {
RouteSegment segment = new RouteSegment(rr.getObject(), rr.getEndPointIndex()); RouteSegment segment = new RouteSegment(rr.getObject(), rr.getEndPointIndex());
if (previous != null) { if (previous != null) {
previous.parentRoute = segment; previous.parentRoute = segment;
@ -226,6 +237,7 @@ public class BinaryRoutePlanner {
} }
end = previous; end = previous;
} }
}
// for start : f(start) = g(start) + h(start) = 0 + h(start) = h(start) // for start : f(start) = g(start) + h(start) = 0 + h(start) = h(start)
int targetEndX = end.road.getPoint31XTile(end.segmentStart); int targetEndX = end.road.getPoint31XTile(end.segmentStart);

View file

@ -74,8 +74,6 @@ import android.view.Window;
import android.view.animation.AccelerateInterpolator; import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.Transformation; import android.view.animation.Transformation;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;