Fix using rtept as intermediates recalculation

This commit is contained in:
Victor Shcherb 2015-04-25 18:00:27 +02:00
parent 92ec8bbb4a
commit f92438d334
4 changed files with 17 additions and 6 deletions

View file

@ -31,7 +31,6 @@ import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;

View file

@ -175,6 +175,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
measurementPoints.add(new LinkedList<GPXUtilities.WptPt>());
} else if (id == R.string.distance_measurement_clear_route) {
distanceMeasurementMode = 0;
originalGPX = null;
measurementPoints.clear();
calculateDistance();
} else if (id == R.string.shared_string_save_as_gpx) {

View file

@ -52,8 +52,8 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
pointAtUI.setColor(0xa0FF3344);
pointAtUI.setStyle(Paint.Style.FILL);
poi = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_origin);
bug = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_destination);
poi = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi);
bug = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_poi);
paintIcon = new Paint();

View file

@ -354,8 +354,7 @@ public class RouteProvider {
// get the closest point to start and to end
GPXRouteParams gpxParams = routeParams.gpxRoute;
if(routeParams.gpxRoute.useIntermediatePointsRTE){
final List<Location> intermediates = gpxParams.points;
return calculateOsmAndRouteWithIntermediatePoints(routeParams, intermediates);
return calculateOsmAndRouteWithIntermediatePoints(routeParams, gpxParams.points);
}
List<Location> gpxRoute ;
int[] startI = new int[]{0};
@ -399,7 +398,19 @@ public class RouteProvider {
rp.onlyStartPointChanged = routeParams.onlyStartPointChanged;
rp.previousToRecalculate = routeParams.previousToRecalculate;
rp.intermediates = new ArrayList<LatLon>();
for(Location w : intermediates) {
int closest = 0;
double maxDist = Double.POSITIVE_INFINITY;
for (int i = 0; i < intermediates.size(); i++) {
Location loc = intermediates.get(i);
double dist = MapUtils.getDistance(loc.getLatitude(), loc.getLongitude(), rp.start.getLatitude(),
rp.start.getLongitude());
if (dist <= maxDist) {
closest = i;
maxDist = dist;
}
}
for(int i = closest; i< intermediates.size() ; i++ ){
Location w = intermediates.get(i);
rp.intermediates.add(new LatLon(w.getLatitude(), w.getLongitude()));
}
return findVectorMapsRoute(rp, false);