use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.
the class NextTurnInfoWidget method updateDistance.
private void updateDistance() {
int deviatePath = turnDrawable.deviatedFromRoute ? deviatedPath : nextTurnDistance;
String ds = OsmAndFormatter.getFormattedDistance(deviatePath, app);
if (ds != null) {
TurnType turnType = getTurnType();
RoutingHelper routingHelper = app.getRoutingHelper();
if ((turnType != null) && (routingHelper != null)) {
setContentDescription(ds + " " + routingHelper.getRoute().toString(turnType, app, false));
} else {
setContentDescription(ds);
}
}
int ls = ds.lastIndexOf(' ');
if (ls == -1) {
setTextNoUpdateVisibility(ds, null);
} else {
setTextNoUpdateVisibility(ds.substring(0, ls), ds.substring(ls + 1));
}
}
use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.
the class RouteInfoWidgetsFactory method createNextNextInfoControl.
public NextTurnInfoWidget createNextNextInfoControl(final Activity activity, final OsmandApplication app, boolean horisontalMini) {
final RoutingHelper routingHelper = app.getRoutingHelper();
final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(activity, app, horisontalMini) {
NextDirectionInfo calc1 = new NextDirectionInfo();
@Override
public boolean updateInfo(DrawSettings drawSettings) {
boolean followingMode = routingHelper.isFollowingMode() || app.getLocationProvider().getLocationSimulation().isRouteAnimating();
TurnType turnType = null;
boolean deviatedFromRoute = false;
int turnImminent = 0;
int nextTurnDistance = 0;
if (routingHelper != null && routingHelper.isRouteCalculated() && followingMode) {
deviatedFromRoute = routingHelper.isDeviatedFromRoute();
NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true);
if (!deviatedFromRoute) {
if (r != null) {
r = routingHelper.getNextRouteDirectionInfoAfter(r, calc1, true);
}
}
if (r != null && r.distanceTo > 0 && r.directionInfo != null) {
turnType = r.directionInfo.getTurnType();
turnImminent = r.imminent;
nextTurnDistance = r.distanceTo;
}
}
setTurnType(turnType);
setTurnImminent(turnImminent, deviatedFromRoute);
setTurnDistance(nextTurnDistance);
return true;
}
};
nextTurnInfo.setOnClickListener(new View.OnClickListener() {
// int i = 0;
@Override
public void onClick(View v) {
// uncomment to test turn info rendering
// final int l = TurnType.predefinedTypes.length;
// final int exits = 5;
// i++;
// if (i % (l + exits) >= l ) {
// nextTurnInfo.turnType = TurnType.valueOf("EXIT" + (i % (l + exits) - l + 1), true);
// nextTurnInfo.exitOut = (i % (l + exits) - l + 1)+"";
// float a = 180 - (i % (l + exits) - l + 1) * 50;
// nextTurnInfo.turnType.setTurnAngle(a < 0 ? a + 360 : a);
// } else {
// nextTurnInfo.turnType = TurnType.valueOf(TurnType.predefinedTypes[i % (TurnType.predefinedTypes.length + exits)], true);
// nextTurnInfo.exitOut = "";
// }
// nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3;
// nextTurnInfo.nextTurnDirection = 580;
// TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, nexsweepAngletTurnInfo.turnType,nextTurnInfo.pathTransform);
// showMiniMap = true;
}
});
// initial state
return nextTurnInfo;
}
use of net.osmand.plus.routing.RoutingHelper in project Osmand by osmandapp.
the class NavResumePauseAction method execute.
@Override
public void execute(MapActivity activity) {
RoutingHelper routingHelper = activity.getRoutingHelper();
if (routingHelper.isRoutePlanningMode()) {
routingHelper.setRoutePlanningMode(false);
routingHelper.setFollowingMode(true);
} else {
routingHelper.setRoutePlanningMode(true);
routingHelper.setFollowingMode(false);
routingHelper.setPauseNavigation(true);
}
activity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
activity.refreshMap();
}
Aggregations