Add parameter to calculate osmand route parts
This commit is contained in:
parent
01dcf992a9
commit
b1d7cf3f22
7 changed files with 45 additions and 452 deletions
|
@ -9,6 +9,7 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="gpx_option_calculate_first_last_segment">Calculate OsmAnd route for first and last route segment</string>
|
||||||
<string name="use_displayed_track_for_navigation">Do you want to use displayed track for navigation?</string>
|
<string name="use_displayed_track_for_navigation">Do you want to use displayed track for navigation?</string>
|
||||||
<string name="keep_and_add_destination_point">Add as destination point</string>
|
<string name="keep_and_add_destination_point">Add as destination point</string>
|
||||||
<string name="select_gpx">Select GPX …</string>
|
<string name="select_gpx">Select GPX …</string>
|
||||||
|
|
|
@ -741,6 +741,7 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Boolean> SPEAK_SPEED_CAMERA = new BooleanPreference("speak_cameras", true).makeProfile().cache();
|
public final OsmandPreference<Boolean> SPEAK_SPEED_CAMERA = new BooleanPreference("speak_cameras", true).makeProfile().cache();
|
||||||
public final OsmandPreference<Boolean> SPEAK_SPEED_LIMIT = new BooleanPreference("speak_speed_limit", true).makeProfile().cache();
|
public final OsmandPreference<Boolean> SPEAK_SPEED_LIMIT = new BooleanPreference("speak_speed_limit", true).makeProfile().cache();
|
||||||
|
|
||||||
|
public final OsmandPreference<Boolean> GPX_ROUTE_CALC_OSMAND_PARTS = new BooleanPreference("gpx_routing_calculate_osmand_route", true).makeGlobal().cache();
|
||||||
public final OsmandPreference<Boolean> SPEAK_GPX_WPT = new BooleanPreference("speak_gpx_wpt", true).makeGlobal().cache();
|
public final OsmandPreference<Boolean> SPEAK_GPX_WPT = new BooleanPreference("speak_gpx_wpt", true).makeGlobal().cache();
|
||||||
public final OsmandPreference<Boolean> CALC_GPX_ROUTE = new BooleanPreference("calc_gpx_route", false).makeGlobal().cache();
|
public final OsmandPreference<Boolean> CALC_GPX_ROUTE = new BooleanPreference("calc_gpx_route", false).makeGlobal().cache();
|
||||||
|
|
||||||
|
|
|
@ -455,6 +455,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
} else {
|
} else {
|
||||||
GPXRouteParamsBuilder params = new GPXRouteParamsBuilder(result, mapActivity.getMyApplication()
|
GPXRouteParamsBuilder params = new GPXRouteParamsBuilder(result, mapActivity.getMyApplication()
|
||||||
.getSettings());
|
.getSettings());
|
||||||
|
params.setCalculateOsmAndRouteParts(settings.GPX_ROUTE_CALC_OSMAND_PARTS.get());
|
||||||
params.setAnnounceWaypoints(settings.SPEAK_GPX_WPT.get());
|
params.setAnnounceWaypoints(settings.SPEAK_GPX_WPT.get());
|
||||||
params.setCalculateOsmAndRoute(settings.CALC_GPX_ROUTE.get());
|
params.setCalculateOsmAndRoute(settings.CALC_GPX_ROUTE.get());
|
||||||
List<Location> ps = params.getPoints();
|
List<Location> ps = params.getPoints();
|
||||||
|
|
|
@ -1,439 +0,0 @@
|
||||||
package net.osmand.plus.activities.actions;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.osmand.CallbackWithObject;
|
|
||||||
import net.osmand.Location;
|
|
||||||
import net.osmand.access.AccessibleToast;
|
|
||||||
import net.osmand.data.LatLon;
|
|
||||||
import net.osmand.plus.ApplicationMode;
|
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
|
||||||
import net.osmand.plus.OsmAndLocationProvider;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
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.RouteProvider.GPXRouteParamsBuilder;
|
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.AlertDialog.Builder;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import android.widget.ToggleButton;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class NavigateAction {
|
|
||||||
|
|
||||||
private MapActivity mapActivity;
|
|
||||||
private OsmandApplication app;
|
|
||||||
private OsmandSettings settings;
|
|
||||||
|
|
||||||
|
|
||||||
public NavigateAction(MapActivity mapActivity){
|
|
||||||
this.mapActivity = mapActivity;
|
|
||||||
app = mapActivity.getMyApplication();
|
|
||||||
settings = app.getSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void navigateUsingGPX(final ApplicationMode appMode) {
|
|
||||||
final LatLon endForRouting = mapActivity.getPointToNavigate();
|
|
||||||
GpxUiHelper.selectGPXFile(mapActivity, false, false, new CallbackWithObject<GPXFile>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean processResult(final GPXFile result) {
|
|
||||||
return navigateUsingGPX(appMode, endForRouting, result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean navigateUsingGPX(final ApplicationMode appMode, final LatLon endForRouting,
|
|
||||||
final GPXFile result) {
|
|
||||||
Builder builder = new AlertDialog.Builder(mapActivity);
|
|
||||||
final boolean[] props = new boolean[]{false, false, false, settings.SPEAK_GPX_WPT.get(), settings.CALC_GPX_ROUTE.get()};
|
|
||||||
builder.setMultiChoiceItems(new String[] { getString(R.string.gpx_option_reverse_route),
|
|
||||||
getString(R.string.gpx_option_destination_point), getString(R.string.gpx_option_from_start_point),
|
|
||||||
getString(R.string.announce_gpx_waypoints),
|
|
||||||
getString(R.string.calculate_osmand_route_gpx)}, props,
|
|
||||||
new OnMultiChoiceClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
|
||||||
props[which] = isChecked;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setPositiveButton(R.string.default_buttons_apply, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
boolean reverse = props[0];
|
|
||||||
boolean passWholeWay = props[2];
|
|
||||||
boolean useDestination = props[1];
|
|
||||||
boolean announceGpxWpt = props[3];
|
|
||||||
boolean calculateOsmAndRoute = props[4];
|
|
||||||
settings.SPEAK_GPX_WPT.set(announceGpxWpt);
|
|
||||||
settings.CALC_GPX_ROUTE.set(calculateOsmAndRoute);
|
|
||||||
GPXRouteParamsBuilder gpxRoute = new GPXRouteParamsBuilder(result, settings);
|
|
||||||
if(reverse) {
|
|
||||||
gpxRoute.setReverse(true);
|
|
||||||
}
|
|
||||||
if(announceGpxWpt) {
|
|
||||||
gpxRoute.setAnnounceWaypoints(true);
|
|
||||||
}
|
|
||||||
if(calculateOsmAndRoute) {
|
|
||||||
gpxRoute.setCalculateOsmAndRoute(true);
|
|
||||||
}
|
|
||||||
if(passWholeWay) {
|
|
||||||
gpxRoute.setPassWholeRoute(true);
|
|
||||||
}
|
|
||||||
Location startForRouting = getLastKnownLocation();
|
|
||||||
if(startForRouting == null){
|
|
||||||
startForRouting = null;//gpxRoute.getStartPointForRoute();
|
|
||||||
}
|
|
||||||
|
|
||||||
LatLon endPoint = endForRouting;
|
|
||||||
if(endPoint == null || !useDestination){
|
|
||||||
// LatLon point = gpxRoute.getLastPoint();
|
|
||||||
// if(point != null){
|
|
||||||
// endPoint = point;
|
|
||||||
// }
|
|
||||||
if(endPoint != null) {
|
|
||||||
app.getTargetPointsHelper().navigateToPoint(endPoint, false, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(endPoint != null){
|
|
||||||
followRoute(appMode, endPoint,
|
|
||||||
new ArrayList<LatLon>(), startForRouting, gpxRoute);
|
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(result.path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
|
||||||
builder.show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void getDirections(final Location mapView, String name, DirectionDialogStyle style) {
|
|
||||||
final Location current = getLastKnownLocation();
|
|
||||||
Builder builder = new AlertDialog.Builder(mapActivity);
|
|
||||||
final TargetPointsHelper targets = app.getTargetPointsHelper();
|
|
||||||
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(app.getSettings()));
|
|
||||||
values.remove(ApplicationMode.DEFAULT);
|
|
||||||
|
|
||||||
final View view = mapActivity.getLayoutInflater().inflate(R.layout.calculate_route, null);
|
|
||||||
|
|
||||||
LinearLayout topLayout = (LinearLayout) view.findViewById(R.id.LinearLayout);
|
|
||||||
final ToggleButton[] buttons = AppModeDialog.createToggles(values, topLayout, mapActivity);
|
|
||||||
|
|
||||||
final Spinner fromSpinner = setupFromSpinner(mapView, name, view, style);
|
|
||||||
final List<LatLon> toList = new ArrayList<LatLon>();
|
|
||||||
final Spinner toSpinner = setupToSpinner(mapView, name,view, toList, style);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String via = generateViaDescription();
|
|
||||||
if(via.length() == 0){
|
|
||||||
((TextView) view.findViewById(R.id.ViaView)).setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
((TextView) view.findViewById(R.id.ViaView)).setVisibility(View.VISIBLE);
|
|
||||||
((TextView) view.findViewById(R.id.ViaView)).setText(via);
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicationMode appMode = settings.getApplicationMode();
|
|
||||||
if(appMode == ApplicationMode.DEFAULT) {
|
|
||||||
appMode = ApplicationMode.CAR;
|
|
||||||
}
|
|
||||||
updateTooLongDistance(current != null ? current : mapView, targets, view, appMode);
|
|
||||||
for (int i = 0; i < buttons.length; i++) {
|
|
||||||
if (buttons[i] != null) {
|
|
||||||
final int ind = i;
|
|
||||||
ToggleButton b = buttons[i];
|
|
||||||
final ApplicationMode buttonAppMode = values.get(i);
|
|
||||||
b.setChecked(appMode == buttonAppMode);
|
|
||||||
if(b.isChecked()) {
|
|
||||||
// update application mode controls
|
|
||||||
}
|
|
||||||
b.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
// update application mode controls
|
|
||||||
updateTooLongDistance(current != null ? current : mapView, targets, view, buttonAppMode);
|
|
||||||
for (int j = 0; j < buttons.length; j++) {
|
|
||||||
if (buttons[j] != null) {
|
|
||||||
if (buttons[j].isChecked() != (ind == j)) {
|
|
||||||
buttons[j].setChecked(ind == j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// revert state
|
|
||||||
boolean revert = true;
|
|
||||||
for (int j = 0; j < buttons.length; j++) {
|
|
||||||
if (buttons[j] != null) {
|
|
||||||
if (buttons[j].isChecked()) {
|
|
||||||
revert = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (revert) {
|
|
||||||
buttons[ind].setChecked(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogInterface.OnClickListener onlyShowCall = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
LatLon tos = toList.get(toSpinner.getSelectedItemPosition());
|
|
||||||
if ( tos != null && tos != targets.getPointToNavigate()) {
|
|
||||||
targets.navigateToPoint(tos, false, -1);
|
|
||||||
}
|
|
||||||
if (!targets.checkPointToNavigate()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Location from = fromSpinner.getSelectedItemPosition() == 0 ? current : mapView;
|
|
||||||
if (from == null) {
|
|
||||||
from = getLastKnownLocation();
|
|
||||||
}
|
|
||||||
if (from == null) {
|
|
||||||
AccessibleToast.makeText(mapActivity, R.string.unknown_from_location, Toast.LENGTH_LONG).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicationMode mode = getAppMode(buttons, settings, values);
|
|
||||||
app.getRoutingHelper().setAppMode(mode);
|
|
||||||
// save application mode controls
|
|
||||||
settings.FOLLOW_THE_ROUTE.set(false);
|
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
|
||||||
app.getRoutingHelper().setFollowingMode(false);
|
|
||||||
app.getRoutingHelper().setFinalAndCurrentLocation(targets.getPointToNavigate(), targets.getIntermediatePoints(), from, null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DialogInterface.OnClickListener followCall = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
LatLon tos = toList.get(toSpinner.getSelectedItemPosition());
|
|
||||||
if ( tos != null && tos != targets.getPointToNavigate()) {
|
|
||||||
targets.navigateToPoint(tos, false, -1);
|
|
||||||
}
|
|
||||||
if (!targets.checkPointToNavigate()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean msg = true;
|
|
||||||
Location lastKnownLocation = getLastKnownLocation();
|
|
||||||
Location from = fromSpinner.getSelectedItemPosition() == 0 ? current : mapView;
|
|
||||||
if(from == null) {
|
|
||||||
from = lastKnownLocation;
|
|
||||||
}
|
|
||||||
if (OsmAndLocationProvider.isPointAccurateForRouting(lastKnownLocation)) {
|
|
||||||
from = lastKnownLocation;
|
|
||||||
msg = false;
|
|
||||||
}
|
|
||||||
if (msg) {
|
|
||||||
AccessibleToast.makeText(mapActivity, R.string.route_updated_loc_found, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
ApplicationMode mode = getAppMode(buttons, settings, values);
|
|
||||||
// save application mode controls (optimal)
|
|
||||||
dialog.dismiss();
|
|
||||||
followRoute(mode, targets.getPointToNavigate(), targets.getIntermediatePoints(),
|
|
||||||
from, null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DialogInterface.OnClickListener useGpxNavigation = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
LatLon tos = toList.get(toSpinner.getSelectedItemPosition());
|
|
||||||
if ( tos != null && tos != targets.getPointToNavigate()) {
|
|
||||||
targets.navigateToPoint(tos, false, -1);
|
|
||||||
}
|
|
||||||
ApplicationMode mode = getAppMode(buttons, settings, values);
|
|
||||||
navigateUsingGPX(mode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
builder.setView(view);
|
|
||||||
builder.setTitle(R.string.get_directions);
|
|
||||||
builder.setPositiveButton(R.string.follow, followCall);
|
|
||||||
builder.setNeutralButton(R.string.only_show, onlyShowCall);
|
|
||||||
if (style.gpxRouteEnabled) {
|
|
||||||
builder.setNegativeButton(R.string.gpx_navigation, useGpxNavigation);
|
|
||||||
} else {
|
|
||||||
builder.setNegativeButton(R.string.no_route, null);
|
|
||||||
}
|
|
||||||
builder.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTooLongDistance(final Location start, final TargetPointsHelper targets, View view, ApplicationMode appMode) {
|
|
||||||
TextView textView = (TextView) view.findViewById(R.id.ValidateTextView);
|
|
||||||
if(targets.hasTooLongDistanceToNavigate()) {
|
|
||||||
textView.setText(R.string.route_is_too_long);
|
|
||||||
textView.setVisibility(View.VISIBLE);
|
|
||||||
} else{
|
|
||||||
textView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getRoutePointDescription(double lat, double lon) {
|
|
||||||
return mapActivity.getString(R.string.route_descr_lat_lon, lat, lon);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRoutePointDescription(LatLon l, String d) {
|
|
||||||
if(d != null && d.length() > 0) {
|
|
||||||
return d.replace(':', ' ');
|
|
||||||
}
|
|
||||||
if(l != null) {
|
|
||||||
return mapActivity.getString(R.string.route_descr_lat_lon, l.getLatitude(), l.getLongitude());
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String generateViaDescription() {
|
|
||||||
TargetPointsHelper targets = getTargets();
|
|
||||||
String via = "";
|
|
||||||
List<String> names = targets.getIntermediatePointNames();
|
|
||||||
List<LatLon> points = targets.getIntermediatePoints();
|
|
||||||
if (names.size() == 0) {
|
|
||||||
return via;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < points.size() ; i++) {
|
|
||||||
via += "\n - " + getRoutePointDescription(points.get(i), i >= names.size() ? "" :names.get(i));
|
|
||||||
}
|
|
||||||
return mapActivity.getString(R.string.route_via) + via;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DirectionDialogStyle {
|
|
||||||
public boolean gpxRouteEnabled;
|
|
||||||
public boolean routeToMapPoint;
|
|
||||||
public boolean routeFromMapPoint;
|
|
||||||
|
|
||||||
public static DirectionDialogStyle create() {
|
|
||||||
return new DirectionDialogStyle();
|
|
||||||
}
|
|
||||||
public DirectionDialogStyle gpxRouteEnabled() {
|
|
||||||
gpxRouteEnabled = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DirectionDialogStyle routeToMapPoint() {
|
|
||||||
routeToMapPoint = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DirectionDialogStyle routeFromMapPoint() {
|
|
||||||
routeFromMapPoint = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Spinner setupFromSpinner(final Location mapView, String name, View view, DirectionDialogStyle style) {
|
|
||||||
String currentLocation = mapActivity.getString(R.string.route_descr_current_location);
|
|
||||||
ArrayList<String> fromActions = new ArrayList<String>();
|
|
||||||
fromActions.add(currentLocation);
|
|
||||||
if(mapView != null) {
|
|
||||||
String oname = name != null ? name : getRoutePointDescription(mapView.getLatitude(),mapView.getLongitude());
|
|
||||||
String mapLocation = mapActivity.getString(R.string.route_descr_map_location) + " " + oname;
|
|
||||||
fromActions.add(mapLocation);
|
|
||||||
}
|
|
||||||
final Spinner fromSpinner = ((Spinner) view.findViewById(R.id.FromSpinner));
|
|
||||||
ArrayAdapter<String> fromAdapter = new ArrayAdapter<String>(view.getContext(),
|
|
||||||
android.R.layout.simple_spinner_item,
|
|
||||||
fromActions
|
|
||||||
);
|
|
||||||
fromAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
||||||
fromSpinner.setAdapter(fromAdapter);
|
|
||||||
if(style.routeFromMapPoint && mapView != null) {
|
|
||||||
fromSpinner.setSelection(1);
|
|
||||||
}
|
|
||||||
return fromSpinner;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Spinner setupToSpinner(final Location mapView, String name, View view, List<LatLon> locs, DirectionDialogStyle style) {
|
|
||||||
final TargetPointsHelper targets = getTargets();
|
|
||||||
ArrayList<String> toActions = new ArrayList<String>();
|
|
||||||
if (targets.getPointToNavigate() != null) {
|
|
||||||
toActions.add(mapActivity.getString(R.string.route_descr_destination) + " "
|
|
||||||
+ getRoutePointDescription(targets.getPointToNavigate(), targets.getPointNavigateDescription()));
|
|
||||||
locs.add(targets.getPointToNavigate());
|
|
||||||
}
|
|
||||||
if(mapView != null) {
|
|
||||||
String oname = name != null ? name : getRoutePointDescription(mapView.getLatitude(),mapView.getLongitude());
|
|
||||||
String mapLocation = mapActivity.getString(R.string.route_descr_map_location) + " " + oname;
|
|
||||||
toActions.add(mapLocation);
|
|
||||||
locs.add(new LatLon(mapView.getLatitude(), mapView.getLongitude()));
|
|
||||||
}
|
|
||||||
if(style.routeToMapPoint) {
|
|
||||||
Collections.reverse(locs);
|
|
||||||
Collections.reverse(toActions);
|
|
||||||
}
|
|
||||||
final Spinner toSpinner = ((Spinner) view.findViewById(R.id.ToSpinner));
|
|
||||||
ArrayAdapter<String> toAdapter = new ArrayAdapter<String>(view.getContext(),
|
|
||||||
android.R.layout.simple_spinner_item,
|
|
||||||
toActions
|
|
||||||
);
|
|
||||||
toAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
||||||
toSpinner.setAdapter(toAdapter);
|
|
||||||
return toSpinner;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private TargetPointsHelper getTargets() {
|
|
||||||
return app.getTargetPointsHelper();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Location getLastKnownLocation() {
|
|
||||||
return app.getLocationProvider().getLastKnownLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String getString(int resId) {
|
|
||||||
return mapActivity.getString(resId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ApplicationMode getAppMode(ToggleButton[] buttons, OsmandSettings settings, List<ApplicationMode> modes){
|
|
||||||
for (int i = 0; i < buttons.length; i++) {
|
|
||||||
if (buttons[i] != null && buttons[i].isChecked() && i < modes.size()) {
|
|
||||||
return modes.get(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return settings.getApplicationMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void followRoute(ApplicationMode appMode, LatLon finalLocation, List<LatLon> intermediatePoints, net.osmand.Location currentLocation,
|
|
||||||
GPXRouteParamsBuilder gpxRoute){
|
|
||||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
|
||||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
|
||||||
settings.APPLICATION_MODE.set(appMode);
|
|
||||||
settings.FOLLOW_THE_ROUTE.set(true);
|
|
||||||
if(gpxRoute == null) {
|
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
|
||||||
}
|
|
||||||
routingHelper.setFollowingMode(true);
|
|
||||||
|
|
||||||
routingHelper.setFinalAndCurrentLocation(finalLocation, intermediatePoints, currentLocation, gpxRoute);
|
|
||||||
app.initVoiceCommandPlayer(mapActivity);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -131,6 +131,9 @@ public class FailSafeFuntions {
|
||||||
if (settings.SPEAK_GPX_WPT.get()) {
|
if (settings.SPEAK_GPX_WPT.get()) {
|
||||||
gpxRoute.setAnnounceWaypoints(true);
|
gpxRoute.setAnnounceWaypoints(true);
|
||||||
}
|
}
|
||||||
|
if (settings.GPX_ROUTE_CALC_OSMAND_PARTS.get()) {
|
||||||
|
gpxRoute.setCalculateOsmAndRouteParts(true);
|
||||||
|
}
|
||||||
if(settings.CALC_GPX_ROUTE.get()) {
|
if(settings.CALC_GPX_ROUTE.get()) {
|
||||||
gpxRoute.setCalculateOsmAndRoute(true);
|
gpxRoute.setCalculateOsmAndRoute(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@ public class RouteProvider {
|
||||||
private boolean reverse;
|
private boolean reverse;
|
||||||
private boolean leftSide;
|
private boolean leftSide;
|
||||||
private boolean passWholeRoute;
|
private boolean passWholeRoute;
|
||||||
|
public boolean calculateOsmAndRouteParts;
|
||||||
|
|
||||||
public GPXRouteParamsBuilder(GPXFile file, OsmandSettings settings){
|
public GPXRouteParamsBuilder(GPXFile file, OsmandSettings settings){
|
||||||
leftSide = settings.DRIVING_REGION.get().leftHandDriving;
|
leftSide = settings.DRIVING_REGION.get().leftHandDriving;
|
||||||
|
@ -131,6 +132,14 @@ public class RouteProvider {
|
||||||
return reverse;
|
return reverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCalculateOsmAndRouteParts() {
|
||||||
|
return calculateOsmAndRouteParts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCalculateOsmAndRouteParts(boolean calculateOsmAndRouteParts) {
|
||||||
|
this.calculateOsmAndRouteParts = calculateOsmAndRouteParts;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCalculateOsmAndRoute() {
|
public boolean isCalculateOsmAndRoute() {
|
||||||
return calculateOsmAndRoute;
|
return calculateOsmAndRoute;
|
||||||
}
|
}
|
||||||
|
@ -184,6 +193,7 @@ public class RouteProvider {
|
||||||
DataTileManager<WptPt> wpt;
|
DataTileManager<WptPt> wpt;
|
||||||
boolean calculateOsmAndRoute;
|
boolean calculateOsmAndRoute;
|
||||||
boolean passWholeRoute;
|
boolean passWholeRoute;
|
||||||
|
boolean calculateOsmAndRouteParts;
|
||||||
|
|
||||||
public List<Location> getPoints() {
|
public List<Location> getPoints() {
|
||||||
return points;
|
return points;
|
||||||
|
@ -209,6 +219,7 @@ public class RouteProvider {
|
||||||
GPXFile file = builder.file;
|
GPXFile file = builder.file;
|
||||||
boolean reverse = builder.reverse;
|
boolean reverse = builder.reverse;
|
||||||
passWholeRoute = builder.passWholeRoute;
|
passWholeRoute = builder.passWholeRoute;
|
||||||
|
calculateOsmAndRouteParts = builder.calculateOsmAndRouteParts;
|
||||||
boolean announceWaypoints = builder.announceWaypoints;
|
boolean announceWaypoints = builder.announceWaypoints;
|
||||||
calculateOsmAndRoute = false; // Disabled temporary builder.calculateOsmAndRoute;
|
calculateOsmAndRoute = false; // Disabled temporary builder.calculateOsmAndRoute;
|
||||||
if(file.isCloudmadeRouteFile() || OSMAND_ROUTER.equals(file.author)){
|
if(file.isCloudmadeRouteFile() || OSMAND_ROUTER.equals(file.author)){
|
||||||
|
@ -316,19 +327,8 @@ public class RouteProvider {
|
||||||
if(rParams.start != null && rParams.gpxRoute.passWholeRoute) {
|
if(rParams.start != null && rParams.gpxRoute.passWholeRoute) {
|
||||||
Location startOfGpx = rParams.gpxRoute.getStartPointForRoute();
|
Location startOfGpx = rParams.gpxRoute.getStartPointForRoute();
|
||||||
if (startOfGpx != null && rParams.start.distanceTo(startOfGpx) > 60) {
|
if (startOfGpx != null && rParams.start.distanceTo(startOfGpx) > 60) {
|
||||||
RouteCalculationParams newParams = new RouteCalculationParams();
|
LatLon end = new LatLon(startOfGpx.getLatitude(), startOfGpx.getLongitude());
|
||||||
newParams.start = rParams.start;
|
RouteCalculationResult newRes = findOfflineRouteSegment(rParams, rParams.start, end);
|
||||||
newParams.end = new LatLon(startOfGpx.getLatitude(), startOfGpx.getLongitude());
|
|
||||||
newParams.ctx = rParams.ctx;
|
|
||||||
newParams.calculationProgress = rParams.calculationProgress;
|
|
||||||
newParams.mode = rParams.mode;
|
|
||||||
newParams.type = RouteService.OSMAND;
|
|
||||||
newParams.leftSide = rParams.leftSide;
|
|
||||||
RouteCalculationResult newRes = null;
|
|
||||||
try {
|
|
||||||
newRes = findVectorMapsRoute(newParams, false);
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
if(newRes == null || !newRes.isCalculated()) {
|
if(newRes == null || !newRes.isCalculated()) {
|
||||||
rParams.gpxRoute.points.add(rParams.start);
|
rParams.gpxRoute.points.add(rParams.start);
|
||||||
} else {
|
} else {
|
||||||
|
@ -377,6 +377,27 @@ public class RouteProvider {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private RouteCalculationResult findOfflineRouteSegment(RouteCalculationParams rParams, Location start,
|
||||||
|
LatLon end) {
|
||||||
|
RouteCalculationParams newParams = new RouteCalculationParams();
|
||||||
|
newParams.start = start;
|
||||||
|
newParams.end = end;
|
||||||
|
newParams.ctx = rParams.ctx;
|
||||||
|
newParams.calculationProgress = rParams.calculationProgress;
|
||||||
|
newParams.mode = rParams.mode;
|
||||||
|
newParams.type = RouteService.OSMAND;
|
||||||
|
newParams.leftSide = rParams.leftSide;
|
||||||
|
RouteCalculationResult newRes = null;
|
||||||
|
try {
|
||||||
|
newRes = findVectorMapsRoute(newParams, false);
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
return newRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private ArrayList<Location> findGpxLocations(RouteCalculationParams pars, int[] startI, int[] endI) {
|
private ArrayList<Location> findGpxLocations(RouteCalculationParams pars, int[] startI, int[] endI) {
|
||||||
GPXRouteParams params = pars.gpxRoute;
|
GPXRouteParams params = pars.gpxRoute;
|
||||||
List<Location> gpxRoute = params.points;
|
List<Location> gpxRoute = params.points;
|
||||||
|
|
|
@ -160,6 +160,9 @@ public class MapRoutePreferencesControl extends MapControls {
|
||||||
boolean selected = gpxParam.isSelected(settings);
|
boolean selected = gpxParam.isSelected(settings);
|
||||||
if (gpxParam.id == R.string.gpx_option_reverse_route) {
|
if (gpxParam.id == R.string.gpx_option_reverse_route) {
|
||||||
rp.setReverse(selected);
|
rp.setReverse(selected);
|
||||||
|
} else if (gpxParam.id == R.string.gpx_option_calculate_first_last_segment) {
|
||||||
|
rp.setCalculateOsmAndRouteParts(selected);
|
||||||
|
settings.GPX_ROUTE_CALC_OSMAND_PARTS.set(selected);
|
||||||
} else if (gpxParam.id == R.string.gpx_option_from_start_point) {
|
} else if (gpxParam.id == R.string.gpx_option_from_start_point) {
|
||||||
rp.setPassWholeRoute(selected);
|
rp.setPassWholeRoute(selected);
|
||||||
} else if (gpxParam.id == R.string.announce_gpx_waypoints) {
|
} else if (gpxParam.id == R.string.announce_gpx_waypoints) {
|
||||||
|
@ -183,6 +186,8 @@ public class MapRoutePreferencesControl extends MapControls {
|
||||||
getString(R.string.gpx_option_reverse_route), rparams.isReverse()));
|
getString(R.string.gpx_option_reverse_route), rparams.isReverse()));
|
||||||
list.add(new GPXLocalRoutingParameter(R.string.gpx_option_from_start_point,
|
list.add(new GPXLocalRoutingParameter(R.string.gpx_option_from_start_point,
|
||||||
getString(R.string.gpx_option_from_start_point), rparams.isPassWholeRoute()));
|
getString(R.string.gpx_option_from_start_point), rparams.isPassWholeRoute()));
|
||||||
|
list.add(new GPXLocalRoutingParameter(R.string.gpx_option_calculate_first_last_segment,
|
||||||
|
getString(R.string.gpx_option_calculate_first_last_segment), rparams.isCalculateOsmAndRouteParts()));
|
||||||
list.add(new GPXLocalRoutingParameter(R.string.announce_gpx_waypoints,
|
list.add(new GPXLocalRoutingParameter(R.string.announce_gpx_waypoints,
|
||||||
getString(R.string.announce_gpx_waypoints), rparams.isAnnounceWaypoints()));
|
getString(R.string.announce_gpx_waypoints), rparams.isAnnounceWaypoints()));
|
||||||
// Temporary disabled
|
// Temporary disabled
|
||||||
|
|
Loading…
Reference in a new issue