Remove snappedToRoadPoints from layer

This commit is contained in:
Alex 2017-08-23 18:20:35 +03:00
parent 2871edbb55
commit 9a3cafc431
3 changed files with 6 additions and 23 deletions

View file

@ -20,7 +20,6 @@ import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
@ -29,7 +28,6 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
private OsmandMapTileView view; private OsmandMapTileView view;
private boolean inMeasurementMode; private boolean inMeasurementMode;
private List<WptPt> snappedToRoadPoints = new LinkedList<>();
private Bitmap centerIconDay; private Bitmap centerIconDay;
private Bitmap centerIconNight; private Bitmap centerIconNight;
private Bitmap pointIcon; private Bitmap pointIcon;
@ -118,10 +116,6 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
this.inMeasurementMode = inMeasurementMode; this.inMeasurementMode = inMeasurementMode;
} }
public List<WptPt> getSnappedToRoadPoints() {
return snappedToRoadPoints;
}
String getDistanceSt() { String getDistanceSt() {
float dist = 0; float dist = 0;
List<WptPt> measurementPoints = editingCtx.getPoints(); List<WptPt> measurementPoints = editingCtx.getPoints();
@ -255,12 +249,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
} }
} }
List<WptPt> drawPoints; List<WptPt> drawPoints = editingCtx.getPoints();
if (snappedToRoadPoints.size() > 0) {
drawPoints = snappedToRoadPoints;
} else {
drawPoints = editingCtx.getPoints();
}
if (drawPoints.size() > 0) { if (drawPoints.size() > 0) {
path.reset(); path.reset();

View file

@ -9,7 +9,6 @@ import java.util.List;
public class ClearPointsCommand extends MeasurementModeCommand { public class ClearPointsCommand extends MeasurementModeCommand {
private List<WptPt> points; private List<WptPt> points;
private List<WptPt> snappedToRoadPoints;
public ClearPointsCommand(MeasurementToolLayer measurementLayer) { public ClearPointsCommand(MeasurementToolLayer measurementLayer) {
this.measurementLayer = measurementLayer; this.measurementLayer = measurementLayer;
@ -18,11 +17,8 @@ public class ClearPointsCommand extends MeasurementModeCommand {
@Override @Override
public boolean execute() { public boolean execute() {
List<WptPt> pts = measurementLayer.getEditingCtx().getPoints(); List<WptPt> pts = measurementLayer.getEditingCtx().getPoints();
List<WptPt> snappedPts = measurementLayer.getSnappedToRoadPoints();
points = new LinkedList<>(pts); points = new LinkedList<>(pts);
snappedToRoadPoints = new LinkedList<>(snappedPts);
pts.clear(); pts.clear();
snappedPts.clear();
measurementLayer.refreshMap(); measurementLayer.refreshMap();
return true; return true;
} }
@ -30,14 +26,12 @@ public class ClearPointsCommand extends MeasurementModeCommand {
@Override @Override
public void undo() { public void undo() {
measurementLayer.getEditingCtx().getPoints().addAll(points); measurementLayer.getEditingCtx().getPoints().addAll(points);
measurementLayer.getSnappedToRoadPoints().addAll(snappedToRoadPoints);
measurementLayer.refreshMap(); measurementLayer.refreshMap();
} }
@Override @Override
public void redo() { public void redo() {
measurementLayer.getEditingCtx().getPoints().clear(); measurementLayer.getEditingCtx().getPoints().clear();
measurementLayer.getSnappedToRoadPoints().clear();
measurementLayer.refreshMap(); measurementLayer.refreshMap();
} }

View file

@ -16,21 +16,21 @@ public class SnapToRoadCommand extends MeasurementModeCommand {
@Override @Override
public boolean execute() { public boolean execute() {
measurementLayer.getSnappedToRoadPoints().clear(); // measurementLayer.getSnappedToRoadPoints().clear();
measurementLayer.getSnappedToRoadPoints().addAll(snappedPoints); // measurementLayer.getSnappedToRoadPoints().addAll(snappedPoints);
measurementLayer.refreshMap(); // measurementLayer.refreshMap();
return true; return true;
} }
@Override @Override
public void undo() { public void undo() {
measurementLayer.getSnappedToRoadPoints().clear(); // measurementLayer.getSnappedToRoadPoints().clear();
measurementLayer.refreshMap(); measurementLayer.refreshMap();
} }
@Override @Override
public void redo() { public void redo() {
measurementLayer.getSnappedToRoadPoints().addAll(snappedPoints); // measurementLayer.getSnappedToRoadPoints().addAll(snappedPoints);
measurementLayer.refreshMap(); measurementLayer.refreshMap();
} }