Merge pull request #5696 from osmandapp/Fix_5585

Fix_5585
This commit is contained in:
Vitaliy 2018-07-24 12:16:32 +03:00 committed by GitHub
commit 7c65f452fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -884,13 +884,21 @@ public class RouteProvider {
if(directions.size() > 0) {
RouteDirectionInfo last = directions.get(directions.size() - 1);
// update speed using time and idstance
last.setAverageSpeed((distanceToEnd[last.routePointOffset] - distanceToEnd[offset])/last.getAverageSpeed());
last.distance = (int) Math.round(distanceToEnd[last.routePointOffset] - distanceToEnd[offset]);
if (distanceToEnd.length > last.routePointOffset && distanceToEnd.length > offset) {
float lastDistanceToEnd = distanceToEnd[last.routePointOffset];
float currentDistanceToEnd = distanceToEnd[offset];
last.setAverageSpeed((lastDistanceToEnd - currentDistanceToEnd) / last.getAverageSpeed());
last.distance = (int) Math.round(lastDistanceToEnd - currentDistanceToEnd);
}
}
// save time as a speed because we don't know distance of the route segment
float avgSpeed = time;
if(!iterator.hasNext() && time > 0) {
avgSpeed = distanceToEnd[offset] / time;
if (!iterator.hasNext() && time > 0) {
if (distanceToEnd.length > offset) {
avgSpeed = distanceToEnd[offset] / time;
} else {
avgSpeed = defSpeed;
}
}
String stype = item.getExtensionsToRead().get("turn"); //$NON-NLS-1$
TurnType turnType;