Search in sources :

Example 36 with RoutingHelper

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));
    }
}
Also used : RoutingHelper(net.osmand.plus.routing.RoutingHelper) TurnType(net.osmand.router.TurnType) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 37 with RoutingHelper

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;
}
Also used : NextDirectionInfo(net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TurnType(net.osmand.router.TurnType) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) Paint(android.graphics.Paint) DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Example 38 with RoutingHelper

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();
}
Also used : RoutingHelper(net.osmand.plus.routing.RoutingHelper)

Aggregations

RoutingHelper (net.osmand.plus.routing.RoutingHelper)38 LatLon (net.osmand.data.LatLon)9 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)9 OsmandApplication (net.osmand.plus.OsmandApplication)8 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)8 PointDescription (net.osmand.data.PointDescription)7 Intent (android.content.Intent)6 DialogInterface (android.content.DialogInterface)5 AlertDialog (android.support.v7.app.AlertDialog)5 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 Paint (android.graphics.Paint)4 NextDirectionInfo (net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo)4 TurnType (net.osmand.router.TurnType)4 PendingIntent (android.app.PendingIntent)3 BroadcastReceiver (android.content.BroadcastReceiver)3 Context (android.content.Context)3 IntentFilter (android.content.IntentFilter)3 Uri (android.net.Uri)3