Fix issue 412. Add 3 options to follow GPX track
This commit is contained in:
parent
57bb4d9fcf
commit
d52e5ce89e
4 changed files with 56 additions and 40 deletions
|
@ -1,5 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="gpx_option_reverse_route">Reverse GPX route</string>
|
||||
<string name="gpx_option_destination_point">Use current destination point</string>
|
||||
<string name="gpx_option_from_start_point">Pass whole track</string>
|
||||
<string name="tip_rotation_switching">Map rotating</string>
|
||||
<string name="tip_rotation_switching_t">You can choose how will be map rotated in \'Main Menu\' -> \'Settings\' -> \'General Settings\' -> \'Map rotation\'.
|
||||
\nThe choices are:
|
||||
|
@ -255,8 +258,7 @@
|
|||
<string name="map_index">Map</string>
|
||||
<string name="voice">Voice</string>
|
||||
<string name="no_vector_map_loaded">Vector maps were not loaded</string>
|
||||
<string name="gpx_reverse_route">Reverse route</string>
|
||||
<string name="gpx_direct_route">Original route</string>
|
||||
|
||||
<string name="map_route_by_gpx">Route using GPX</string>
|
||||
<string name="gpx_files_not_found">GPX files not found in /tracks directory</string>
|
||||
<string name="layer_gpx_layer">GPX tracks...</string>
|
||||
|
|
|
@ -37,6 +37,7 @@ import android.content.ActivityNotFoundException;
|
|||
import android.content.ComponentName;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Color;
|
||||
|
@ -1177,12 +1178,20 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
@Override
|
||||
public boolean processResult(final GPXFileResult result) {
|
||||
Builder builder = new AlertDialog.Builder(MapActivity.this);
|
||||
builder.setItems(new String[]{getString(R.string.gpx_direct_route), getString(R.string.gpx_reverse_route)},
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
final boolean[] props = new boolean[]{false, false, false};
|
||||
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) }, 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 = which == 1;
|
||||
boolean reverse = props[0];
|
||||
boolean passWholeWay = props[2];
|
||||
ArrayList<List<Location>> locations = result.locations;
|
||||
List<Location> l = new ArrayList<Location>();
|
||||
for(List<Location> s : locations){
|
||||
|
@ -1191,29 +1200,32 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
if(reverse){
|
||||
Collections.reverse(l);
|
||||
}
|
||||
|
||||
Location loc = getLastKnownLocation();
|
||||
if(passWholeWay && loc != null){
|
||||
l.add(0, loc);
|
||||
}
|
||||
Location startForRouting = getLastKnownLocation();
|
||||
if(startForRouting == null && !l.isEmpty()){
|
||||
startForRouting = l.get(0);
|
||||
}
|
||||
LatLon endPoint = endForRouting;
|
||||
if(/*endForRouting == null && */!l.isEmpty()){
|
||||
if((endPoint == null || !props[1]) && !l.isEmpty()){
|
||||
LatLon point = new LatLon(l.get(l.size() - 1).getLatitude(), l.get(l.size() - 1).getLongitude());
|
||||
settings.setPointToNavigate(point.getLatitude(), point.getLongitude());
|
||||
endPoint = point;
|
||||
mapLayers.getNavigationLayer().setPointToNavigate(point);
|
||||
}
|
||||
mapView.refreshMap();
|
||||
if(endForRouting != null){
|
||||
if(endPoint != null){
|
||||
settings.FOLLOW_TO_THE_ROUTE.set(true);
|
||||
routingHelper.setFollowingMode(true);
|
||||
routingHelper.setFinalAndCurrentLocation(endPoint, startForRouting, l);
|
||||
((OsmandApplication)getApplication()).showDialogInitializingCommandPlayer(MapActivity.this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
builder.show();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -241,12 +241,14 @@ public class MapActivityLayers {
|
|||
final OsmandSettings settings = getApplication().getSettings();
|
||||
layersList.add(getString(R.string.layer_map));
|
||||
layersList.add(getString(R.string.layer_poi));
|
||||
layersList.add(getString(R.string.layer_transport));
|
||||
layersList.add(getString(R.string.layer_osm_bugs));
|
||||
layersList.add(getString(R.string.layer_favorites));
|
||||
layersList.add(getString(R.string.layer_gpx_layer));
|
||||
layersList.add(getString(R.string.layer_overlay));
|
||||
layersList.add(getString(R.string.layer_underlay));
|
||||
layersList.add(getString(R.string.layer_gpx_layer));
|
||||
layersList.add(getString(R.string.layer_transport));
|
||||
layersList.add(getString(R.string.layer_osm_bugs));
|
||||
|
||||
|
||||
final int routeInfoInd = routeInfoLayer.couldBeVisible() ? layersList.size() : -1;
|
||||
if(routeInfoLayer.couldBeVisible()){
|
||||
layersList.add(getString(R.string.layer_route));
|
||||
|
@ -261,12 +263,12 @@ public class MapActivityLayers {
|
|||
final boolean[] selected = new boolean[layersList.size()];
|
||||
Arrays.fill(selected, true);
|
||||
selected[1] = settings.SHOW_POI_OVER_MAP.get();
|
||||
selected[2] = settings.SHOW_TRANSPORT_OVER_MAP.get();
|
||||
selected[3] = settings.SHOW_OSM_BUGS.get();
|
||||
selected[4] = settings.SHOW_FAVORITES.get();
|
||||
selected[2] = settings.SHOW_FAVORITES.get();
|
||||
selected[3] = overlayLayer.getMap() != null;
|
||||
selected[4] = underlayLayer.getMap() != null;
|
||||
selected[5] = gpxLayer.isVisible();
|
||||
selected[6] = overlayLayer.getMap() != null;
|
||||
selected[7] = underlayLayer.getMap() != null;
|
||||
selected[6] = settings.SHOW_TRANSPORT_OVER_MAP.get();
|
||||
selected[7] = settings.SHOW_OSM_BUGS.get();
|
||||
selected[trafficInd] = trafficLayer.isVisible();
|
||||
if(routeInfoInd != -1){
|
||||
selected[routeInfoInd] = routeInfoLayer.isUserDefinedVisible();
|
||||
|
@ -289,11 +291,25 @@ public class MapActivityLayers {
|
|||
}
|
||||
settings.SHOW_POI_OVER_MAP.set(isChecked);
|
||||
} else if(item == 2){
|
||||
settings.SHOW_TRANSPORT_OVER_MAP.set(isChecked);
|
||||
} else if(item == 3){
|
||||
settings.SHOW_OSM_BUGS.set(isChecked);
|
||||
} else if(item == 4){
|
||||
settings.SHOW_FAVORITES.set(isChecked);
|
||||
} else if(item == 3){
|
||||
if(overlayLayer.getMap() != null){
|
||||
settings.MAP_OVERLAY.set(null);
|
||||
updateMapSource(mapView, null);
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY,
|
||||
overlayLayer);
|
||||
}
|
||||
} else if(item == 4){
|
||||
if(underlayLayer.getMap() != null){
|
||||
settings.MAP_UNDERLAY.set(null);
|
||||
updateMapSource(mapView, null);
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY,
|
||||
mapTileLayer, mapVectorLayer);
|
||||
}
|
||||
} else if(item == 5){
|
||||
if(gpxLayer.isVisible()){
|
||||
getApplication().setGpxFileToDisplay(null);
|
||||
|
@ -303,23 +319,9 @@ public class MapActivityLayers {
|
|||
showGPXFileLayer(mapView);
|
||||
}
|
||||
} else if(item == 6){
|
||||
if(overlayLayer.getMap() != null){
|
||||
settings.MAP_OVERLAY.set(null);
|
||||
updateMapSource(mapView, null);
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY,
|
||||
overlayLayer);
|
||||
}
|
||||
settings.SHOW_TRANSPORT_OVER_MAP.set(isChecked);
|
||||
} else if(item == 7){
|
||||
if(underlayLayer.getMap() != null){
|
||||
settings.MAP_UNDERLAY.set(null);
|
||||
updateMapSource(mapView, null);
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY,
|
||||
mapTileLayer, mapVectorLayer);
|
||||
}
|
||||
settings.SHOW_OSM_BUGS.set(isChecked);
|
||||
} else if(item == routeInfoInd){
|
||||
routeInfoLayer.setVisible(isChecked);
|
||||
} else if(item == transportRouteInfoInd){
|
||||
|
|
|
@ -202,7 +202,7 @@ public class RouteProvider {
|
|||
if (d < minDist) {
|
||||
endI = i + 1;
|
||||
// slightly modify to allow last point to be added
|
||||
minDist = d + 10;
|
||||
minDist = d - 40;
|
||||
}
|
||||
}
|
||||
res = new RouteCalculationResult(new ArrayList<Location>(gpxRoute.subList(startI, endI)), null, start, end, null);
|
||||
|
|
Loading…
Reference in a new issue