Update routing too long distance

This commit is contained in:
vshcherb 2014-03-26 21:21:00 +01:00
parent 5bfa50d994
commit 36c684d443
4 changed files with 14 additions and 7 deletions

View file

@ -8,6 +8,7 @@ import net.osmand.Location;
import net.osmand.StateChangedListener;
import net.osmand.data.LatLon;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.util.MapUtils;
public class TargetPointsHelper {
@ -208,7 +209,12 @@ public class TargetPointsHelper {
}
public boolean hasLongDistancesInBetween(Location current, double dist) {
public boolean hasTooLongDistanceToNavigate() {
if(settings.ROUTER_SERVICE.get() != RouteService.OSMAND) {
return false;
}
Location current = routingHelper.getLastProjection();
double dist = 300000;
List<LatLon> list = getIntermediatePointsWithTarget();
if(!list.isEmpty()) {
if(current != null && MapUtils.getDistance(list.get(0), current.getLatitude(), current.getLongitude()) > dist) {

View file

@ -41,6 +41,7 @@ import net.osmand.plus.activities.actions.StartGPSStatus;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.views.BaseMapLayer;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
@ -465,6 +466,9 @@ public class MapActivityActions implements DialogProvider {
targets.updateRoutingHelper();
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
mapActivity.getMapView().refreshMap(true);
if(targets.hasTooLongDistanceToNavigate()) {
app.showToastMessage(R.string.route_is_too_long);
}
}
public void contextMenuPoint(final double latitude, final double longitude){

View file

@ -17,9 +17,8 @@ import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.routing.RoutingHelper;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
@ -283,9 +282,8 @@ public class NavigateAction {
}
private void updateTooLongDistance(final Location start, final TargetPointsHelper targets, View view, ApplicationMode appMode) {
boolean osmandRouter = mapActivity.getMyApplication().getSettings().ROUTER_SERVICE.getModeValue(appMode) == RouteService.OSMAND;
TextView textView = (TextView) view.findViewById(R.id.ValidateTextView);
if(osmandRouter && targets.hasLongDistancesInBetween(start, 150000)) {
if(targets.hasTooLongDistanceToNavigate()) {
textView.setText(R.string.route_is_too_long);
textView.setVisibility(View.VISIBLE);
} else{

View file

@ -114,8 +114,7 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
lmain.findViewById(R.id.SimulateRoute).setVisibility(View.GONE);
TextView textView = (TextView) lmain.findViewById(R.id.ValidateTextView);
TargetPointsHelper targets = getTargets();
boolean osmandRouter = mapActivity.getMyApplication().getSettings().ROUTER_SERVICE.get() == RouteService.OSMAND;
if(osmandRouter && targets.hasLongDistancesInBetween(routingHelper.getLastProjection(), 15000)) {
if(targets.hasTooLongDistanceToNavigate()) {
textView.setText(R.string.route_is_too_long);
textView.setVisibility(View.VISIBLE);
} else{