Solve Issue 2233: Routing instructions disappearing too early in roundabouts
Keep track of the end for directions that are not spots (like roundabouts). Then use this information to keep on this directions until we reach their end. Has a strange side effect. Distance drop as we arrive to start of roundabout (like previously) and when entering roundabout grow up to roundabout distance. modified: src/net/osmand/plus/routing/RouteCalculationResult.java modified: src/net/osmand/plus/routing/RouteDirectionInfo.java
This commit is contained in:
parent
2c0d1fdcd0
commit
b5aa267c69
2 changed files with 17 additions and 3 deletions
|
@ -243,10 +243,14 @@ public class RouteCalculationResult {
|
|||
if (routeInd < list.size()) {
|
||||
int lind = routeInd;
|
||||
if(turn.isRoundAbout()) {
|
||||
int roundAboutEnd = prevLocationSize - 1;
|
||||
// take next name for roundabout (not roundabout name)
|
||||
while(lind < list.size() -1 && list.get(lind).getObject().roundabout()) {
|
||||
roundAboutEnd += Math.abs(list.get(lind).getEndPointIndex()-list.get(lind).getStartPointIndex());
|
||||
lind++;
|
||||
}
|
||||
// Consider roundabout end.
|
||||
info.routeEndPointOffset = roundAboutEnd;
|
||||
}
|
||||
RouteSegmentResult next = list.get(lind);
|
||||
info.setRef(next.getObject().getRef());
|
||||
|
@ -689,7 +693,9 @@ public class RouteCalculationResult {
|
|||
|
||||
public void updateCurrentRoute(int currentRoute) {
|
||||
this.currentRoute = currentRoute;
|
||||
while (currentDirectionInfo < directions.size() - 1 && directions.get(currentDirectionInfo + 1).routePointOffset < currentRoute) {
|
||||
while (currentDirectionInfo < directions.size() - 1
|
||||
&& directions.get(currentDirectionInfo + 1).routePointOffset < currentRoute
|
||||
&& directions.get(currentDirectionInfo + 1).routeEndPointOffset < currentRoute) {
|
||||
currentDirectionInfo++;
|
||||
}
|
||||
while(nextIntermediate < intermediatePoints.length) {
|
||||
|
@ -721,7 +727,7 @@ public class RouteCalculationResult {
|
|||
/*public */NextDirectionInfo getNextRouteDirectionInfo(NextDirectionInfo info, Location fromLoc, boolean toSpeak) {
|
||||
int dirInfo = currentDirectionInfo;
|
||||
if (dirInfo < directions.size()) {
|
||||
int dist = listDistance[currentRoute];
|
||||
// Locate next direction of interest
|
||||
int nextInd = dirInfo + 1;
|
||||
if (toSpeak) {
|
||||
while (nextInd < directions.size()) {
|
||||
|
@ -732,12 +738,18 @@ public class RouteCalculationResult {
|
|||
nextInd++;
|
||||
}
|
||||
}
|
||||
int dist = listDistance[currentRoute];
|
||||
if (fromLoc != null) {
|
||||
dist += fromLoc.distanceTo(locations.get(currentRoute));
|
||||
}
|
||||
if (nextInd < directions.size()) {
|
||||
info.directionInfo = directions.get(nextInd);
|
||||
dist -= listDistance[directions.get(nextInd).routePointOffset];
|
||||
if (directions.get(nextInd).routePointOffset <= currentRoute
|
||||
&& currentRoute <= directions.get(nextInd).routeEndPointOffset)
|
||||
// We are not into a puntual direction.
|
||||
dist -= listDistance[directions.get(nextInd).routeEndPointOffset];
|
||||
else
|
||||
dist -= listDistance[directions.get(nextInd).routePointOffset];
|
||||
}
|
||||
if(intermediatePoints != null && nextIntermediate < intermediatePoints.length) {
|
||||
info.intermediatePoint = intermediatePoints[nextIntermediate] == nextInd;
|
||||
|
|
|
@ -7,6 +7,8 @@ import net.osmand.router.TurnType;
|
|||
public class RouteDirectionInfo {
|
||||
// location when you should action (turn or go ahead)
|
||||
public int routePointOffset;
|
||||
// location where direction end. useful for roundabouts.
|
||||
public int routeEndPointOffset = 0;
|
||||
// Type of action to take
|
||||
private TurnType turnType;
|
||||
// Description of the turn and route after
|
||||
|
|
Loading…
Reference in a new issue