From a410e2b56597c152ac2ac9074ee87f8449035e19 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 26 Oct 2014 23:48:47 +0100 Subject: [PATCH] Fix be attentive with route recalculation --- .../osmand/router/RoutePlannerFrontEnd.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java index 57888d1c71..d8e1117edc 100644 --- a/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java @@ -336,20 +336,25 @@ public class RoutePlannerFrontEnd { List prev = ctx.previouslyCalculatedRoute; long id = points.get(1).getRoad().id; int ss = points.get(1).getSegmentStart(); + int px = points.get(1).getRoad().getPoint31XTile(ss); + int py = points.get(1).getRoad().getPoint31YTile(ss); for (int i = 0; i < prev.size(); i++) { RouteSegmentResult rsr = prev.get(i); - if (id == rsr.getObject().getId() && ss == rsr.getEndPointIndex()) { - firstPartRecalculatedRoute = new ArrayList(i + 1); - restPartRecalculatedRoute = new ArrayList(prev.size() - i); - for (int k = 0; k < prev.size(); k++) { - if (k <= i) { - firstPartRecalculatedRoute.add(prev.get(k)); - } else { - restPartRecalculatedRoute.add(prev.get(k)); + if (id == rsr.getObject().getId()) { + if (MapUtils.getDistance(rsr.getPoint(rsr.getEndPointIndex()), MapUtils.get31LatitudeY(py), + MapUtils.get31LongitudeX(px)) < 50) { + firstPartRecalculatedRoute = new ArrayList(i + 1); + restPartRecalculatedRoute = new ArrayList(prev.size() - i); + for (int k = 0; k < prev.size(); k++) { + if (k <= i) { + firstPartRecalculatedRoute.add(prev.get(k)); + } else { + restPartRecalculatedRoute.add(prev.get(k)); + } } + System.out.println("Recalculate only first part of the route"); + break; } - System.out.println("Recalculate only first part of the route"); - break; } } }