From 594fafdc50be5529d9e697f2133022def84d6d27 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 30 Jun 2012 01:50:55 +0200 Subject: [PATCH] Fix bearing when we calculate projection --- OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index cf753ddf0e..c489e208a3 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -200,15 +200,19 @@ public class RoutingHelper { log.info("Recalculate route, because correlation : " + dist); //$NON-NLS-1$ calculateRoute = true; } + // calculate projection of current location if(dist < POSITION_TOLERANCE * 1.5f) { + Location nextLocation = routeNodes.get(currentRoute); LatLon project = getProject(currentLocation, routeNodes.get(currentRoute - 1), routeNodes.get(currentRoute)); - // calculate projection of current location + locationProjection.setLatitude(project.getLatitude()); locationProjection.setLongitude(project.getLongitude()); + float bearingTo = locationProjection.bearingTo(nextLocation); + // we need to update bearing too + locationProjection.setBearing(bearingTo); } } // 3. Identify wrong movement direction (very similar to 2?) - // Put 3*POSITION_TOLERANCE/2 in order to avoid sharp turns Location next = route.getNextRouteLocation(); boolean wrongMovementDirection = checkWrongMovementDirection(currentLocation, next); if (wrongMovementDirection && currentLocation.distanceTo(routeNodes.get(currentRoute)) > 2 * POSITION_TOLERANCE) {