Remove measurementsPoints
This commit is contained in:
parent
45bb24baeb
commit
b6893b4b46
7 changed files with 130 additions and 111 deletions
|
@ -50,8 +50,6 @@ public class MeasurementEditingContext {
|
||||||
private Queue<Pair<WptPt, WptPt>> snapToRoadPairsToCalculate = new LinkedList<>();
|
private Queue<Pair<WptPt, WptPt>> snapToRoadPairsToCalculate = new LinkedList<>();
|
||||||
private Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints = new ConcurrentHashMap<>();
|
private Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private List<WptPt> measurementPoints = new LinkedList<>();
|
|
||||||
|
|
||||||
public void setApplication(OsmandApplication application) {
|
public void setApplication(OsmandApplication application) {
|
||||||
this.application = application;
|
this.application = application;
|
||||||
}
|
}
|
||||||
|
@ -60,24 +58,6 @@ public class MeasurementEditingContext {
|
||||||
return commandManager;
|
return commandManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBefore(TrkSegment before) {
|
|
||||||
this.before = before;
|
|
||||||
addBeforeRenders();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAfter(TrkSegment after) {
|
|
||||||
this.after = after;
|
|
||||||
addAfterRenders();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addBeforeRenders() {
|
|
||||||
before.renders.add(new Renderable.StandardTrack(before.points, 17.2));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addAfterRenders() {
|
|
||||||
after.renders.add(new Renderable.StandardTrack(after.points, 17.2));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInMovePointMode() {
|
public boolean isInMovePointMode() {
|
||||||
return inMovePointMode;
|
return inMovePointMode;
|
||||||
}
|
}
|
||||||
|
@ -142,14 +122,6 @@ public class MeasurementEditingContext {
|
||||||
return snappedToRoadPoints;
|
return snappedToRoadPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WptPt> getPoints() {
|
|
||||||
return measurementPoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPointsCount() {
|
|
||||||
return measurementPoints.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TrkSegment getBeforeTrkSegmentLine() {
|
public TrkSegment getBeforeTrkSegmentLine() {
|
||||||
// check if all segments calculated for snap to road
|
// check if all segments calculated for snap to road
|
||||||
// if(beforeCacheForSnap != null) {
|
// if(beforeCacheForSnap != null) {
|
||||||
|
@ -163,48 +135,83 @@ public class MeasurementEditingContext {
|
||||||
return after;
|
return after;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recreateSegments() {
|
// public void recreateSegments() {
|
||||||
before = new TrkSegment();
|
// List<WptPt> points = new ArrayList<>();
|
||||||
if (measurementPoints.size() > 1) {
|
// points.addAll(before.points);
|
||||||
for (int i = 0; i < measurementPoints.size() - 1; i++) {
|
// points.addAll(after.points);
|
||||||
Pair<WptPt, WptPt> pair = new Pair<>(measurementPoints.get(i), measurementPoints.get(i + 1));
|
// before.points.clear();
|
||||||
List<WptPt> pts = snappedToRoadPoints.get(pair);
|
// if (points.size() > 1) {
|
||||||
if (pts != null) {
|
// for (int i = 0; i < points.size() - 1; i++) {
|
||||||
before.points.addAll(pts);
|
// Pair<WptPt, WptPt> pair = new Pair<>(points.get(i), points.get(i + 1));
|
||||||
} else {
|
// List<WptPt> pts = snappedToRoadPoints.get(pair);
|
||||||
if (inSnapToRoadMode) {
|
// if (pts != null) {
|
||||||
scheduleRouteCalculateIfNotEmpty();
|
// before.points.addAll(pts);
|
||||||
}
|
// } else {
|
||||||
before.points.addAll(Arrays.asList(pair.first, pair.second));
|
// if (inSnapToRoadMode) {
|
||||||
}
|
// scheduleRouteCalculateIfNotEmpty();
|
||||||
}
|
// }
|
||||||
} else {
|
// before.points.addAll(Arrays.asList(pair.first, pair.second));
|
||||||
before.points.addAll(measurementPoints);
|
// }
|
||||||
}
|
// }
|
||||||
addBeforeRenders();
|
// } else {
|
||||||
after = new TrkSegment();
|
// before.points.addAll(points);
|
||||||
|
// }
|
||||||
|
// after.points.clear();
|
||||||
|
// }
|
||||||
|
|
||||||
|
public List<WptPt> getPoints() {
|
||||||
|
return getBeforePoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WptPt> getBeforePoints() {
|
||||||
|
return before.points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WptPt> getAfterPoints() {
|
||||||
|
return after.points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPointsCount() {
|
||||||
|
return before.points.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void splitSegments(int position) {
|
public void splitSegments(int position) {
|
||||||
before = new TrkSegment();
|
List<WptPt> points = new ArrayList<>();
|
||||||
before.points.addAll(measurementPoints.subList(0, position));
|
points.addAll(before.points);
|
||||||
addBeforeRenders();
|
points.addAll(after.points);
|
||||||
after = new TrkSegment();
|
before.points.clear();
|
||||||
after.points.addAll(measurementPoints.subList(position, measurementPoints.size()));
|
before.points.addAll(points.subList(0, position));
|
||||||
addAfterRenders();
|
after.points.clear();
|
||||||
|
after.points.addAll(points.subList(position, points.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPoint(WptPt pt) {
|
||||||
|
before.points.add(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPoint(int position, WptPt pt) {
|
||||||
|
before.points.add(position, pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPoints(List<WptPt> points) {
|
||||||
|
before.points.addAll(points);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WptPt removePoint(int position) {
|
||||||
|
return before.points.remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearSegments() {
|
public void clearSegments() {
|
||||||
before = new TrkSegment();
|
before.points.clear();
|
||||||
after = new TrkSegment();
|
after.points.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void scheduleRouteCalculateIfNotEmpty() {
|
void scheduleRouteCalculateIfNotEmpty() {
|
||||||
if (application == null || measurementPoints.size() < 1) {
|
if (application == null || before.points.size() < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < measurementPoints.size() - 1; i++) {
|
for (int i = 0; i < before.points.size() - 1; i++) {
|
||||||
Pair<WptPt, WptPt> pair = new Pair<>(measurementPoints.get(i), measurementPoints.get(i + 1));
|
Pair<WptPt, WptPt> pair = new Pair<>(before.points.get(i), before.points.get(i + 1));
|
||||||
if (snappedToRoadPoints.get(pair) == null && !snapToRoadPairsToCalculate.contains(pair)) {
|
if (snappedToRoadPoints.get(pair) == null && !snapToRoadPairsToCalculate.contains(pair)) {
|
||||||
snapToRoadPairsToCalculate.add(pair);
|
snapToRoadPairsToCalculate.add(pair);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +283,7 @@ public class MeasurementEditingContext {
|
||||||
pts.add(pt);
|
pts.add(pt);
|
||||||
}
|
}
|
||||||
snappedToRoadPoints.put(currentPair, pts);
|
snappedToRoadPoints.put(currentPair, pts);
|
||||||
recreateSegments();
|
// recreateSegments();
|
||||||
progressListener.refreshMap();
|
progressListener.refreshMap();
|
||||||
if (!snapToRoadPairsToCalculate.isEmpty()) {
|
if (!snapToRoadPairsToCalculate.isEmpty()) {
|
||||||
application.getRoutingHelper().startRouteCalculationThread(getParams(), true, true);
|
application.getRoutingHelper().startRouteCalculationThread(getParams(), true, true);
|
||||||
|
|
|
@ -303,7 +303,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
editingCtx.getCommandManager().undo();
|
editingCtx.getCommandManager().undo();
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
if (editingCtx.getCommandManager().canUndo()) {
|
if (editingCtx.getCommandManager().canUndo()) {
|
||||||
enable(undoBtn);
|
enable(undoBtn);
|
||||||
} else {
|
} else {
|
||||||
|
@ -324,7 +324,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
editingCtx.getCommandManager().redo();
|
editingCtx.getCommandManager().redo();
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
if (editingCtx.getCommandManager().canRedo()) {
|
if (editingCtx.getCommandManager().canRedo()) {
|
||||||
enable(redoBtn);
|
enable(redoBtn);
|
||||||
} else {
|
} else {
|
||||||
|
@ -625,7 +625,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
removePoint(measurementLayer, editingCtx.getSelectedPointPosition());
|
removePoint(measurementLayer, editingCtx.getSelectedPointPosition());
|
||||||
}
|
}
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
private void removePoint(MeasurementToolLayer layer, int position) {
|
private void removePoint(MeasurementToolLayer layer, int position) {
|
||||||
editingCtx.getCommandManager().execute(new RemovePointCommand(layer, position));
|
editingCtx.getCommandManager().execute(new RemovePointCommand(layer, position));
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
disable(redoBtn);
|
disable(redoBtn);
|
||||||
updateText();
|
updateText();
|
||||||
|
@ -749,7 +749,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
toPosition = holder.getAdapterPosition();
|
toPosition = holder.getAdapterPosition();
|
||||||
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
|
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
|
||||||
editingCtx.getCommandManager().execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition));
|
editingCtx.getCommandManager().execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition));
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
disable(redoBtn);
|
disable(redoBtn);
|
||||||
updateText();
|
updateText();
|
||||||
|
@ -811,7 +811,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
GPXFile gpx = newGpxData.getGpxFile();
|
GPXFile gpx = newGpxData.getGpxFile();
|
||||||
List<WptPt> points = gpx.getRoutePoints();
|
List<WptPt> points = gpx.getRoutePoints();
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
editingCtx.getPoints().addAll(points);
|
editingCtx.addPoints(points);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
@ -823,7 +823,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
TrkSegment segment = newGpxData.getTrkSegment();
|
TrkSegment segment = newGpxData.getTrkSegment();
|
||||||
List<WptPt> points = segment.points;
|
List<WptPt> points = segment.points;
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
editingCtx.getPoints().addAll(points);
|
editingCtx.addPoints(points);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
@ -868,7 +868,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
WptPt oldPoint = editingCtx.getOriginalPointToMove();
|
WptPt oldPoint = editingCtx.getOriginalPointToMove();
|
||||||
int position = editingCtx.getSelectedPointPosition();
|
int position = editingCtx.getSelectedPointPosition();
|
||||||
editingCtx.getCommandManager().execute(new MovePointCommand(measurementLayer, oldPoint, newPoint, position));
|
editingCtx.getCommandManager().execute(new MovePointCommand(measurementLayer, oldPoint, newPoint, position));
|
||||||
editingCtx.getPoints().add(position, newPoint);
|
editingCtx.addPoint(newPoint);
|
||||||
doAddOrMovePointCommonStuff();
|
doAddOrMovePointCommonStuff();
|
||||||
measurementLayer.exitMovePointMode(false);
|
measurementLayer.exitMovePointMode(false);
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
|
@ -898,7 +898,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
private void applyAddPointAfterMode() {
|
private void applyAddPointAfterMode() {
|
||||||
switchAddPointAfterMode(false);
|
switchAddPointAfterMode(false);
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
measurementLayer.exitAddPointAfterMode();
|
measurementLayer.exitAddPointAfterMode();
|
||||||
|
@ -909,7 +909,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
private void cancelAddPointAfterMode() {
|
private void cancelAddPointAfterMode() {
|
||||||
switchAddPointAfterMode(false);
|
switchAddPointAfterMode(false);
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
||||||
if (measurementToolLayer != null) {
|
if (measurementToolLayer != null) {
|
||||||
measurementToolLayer.exitAddPointAfterMode();
|
measurementToolLayer.exitAddPointAfterMode();
|
||||||
|
@ -930,7 +930,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
private void applyAddPointBeforeMode() {
|
private void applyAddPointBeforeMode() {
|
||||||
switchAddPointBeforeMode(false);
|
switchAddPointBeforeMode(false);
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
measurementLayer.exitAddPointBeforeMode();
|
measurementLayer.exitAddPointBeforeMode();
|
||||||
|
@ -941,7 +941,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
private void cancelAddPointBeforeMode() {
|
private void cancelAddPointBeforeMode() {
|
||||||
switchAddPointBeforeMode(false);
|
switchAddPointBeforeMode(false);
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
||||||
if (measurementToolLayer != null) {
|
if (measurementToolLayer != null) {
|
||||||
measurementToolLayer.exitAddPointBeforeMode();
|
measurementToolLayer.exitAddPointBeforeMode();
|
||||||
|
@ -1019,7 +1019,6 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
editingCtx.getCommandManager().execute(new AddPointCommand(measurementLayer, false));
|
editingCtx.getCommandManager().execute(new AddPointCommand(measurementLayer, false));
|
||||||
editingCtx.recreateSegments();
|
|
||||||
doAddOrMovePointCommonStuff();
|
doAddOrMovePointCommonStuff();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +1027,6 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
editingCtx.getCommandManager().execute(new AddPointCommand(measurementLayer, true));
|
editingCtx.getCommandManager().execute(new AddPointCommand(measurementLayer, true));
|
||||||
editingCtx.recreateSegments();
|
|
||||||
doAddOrMovePointCommonStuff();
|
doAddOrMovePointCommonStuff();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1473,7 +1471,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
private void dismiss(MapActivity mapActivity) {
|
private void dismiss(MapActivity mapActivity) {
|
||||||
try {
|
try {
|
||||||
editingCtx.getPoints().clear();
|
editingCtx.clearSegments();
|
||||||
if (pointsListOpened) {
|
if (pointsListOpened) {
|
||||||
hidePointsList();
|
hidePointsList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,10 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.views.ContextMenuLayer;
|
import net.osmand.plus.views.ContextMenuLayer;
|
||||||
import net.osmand.plus.views.OsmandMapLayer;
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.plus.views.Renderable;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
@ -100,11 +102,11 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
|
|
||||||
String getDistanceSt() {
|
String getDistanceSt() {
|
||||||
float dist = 0;
|
float dist = 0;
|
||||||
List<WptPt> measurementPoints = editingCtx.getPoints();
|
List<WptPt> points = editingCtx.getPoints();
|
||||||
if (measurementPoints.size() > 0) {
|
if (points.size() > 0) {
|
||||||
for (int i = 1; i < measurementPoints.size(); i++) {
|
for (int i = 1; i < points.size(); i++) {
|
||||||
dist += MapUtils.getDistance(measurementPoints.get(i - 1).lat, measurementPoints.get(i - 1).lon,
|
dist += MapUtils.getDistance(points.get(i - 1).lat, points.get(i - 1).lon,
|
||||||
measurementPoints.get(i).lat, measurementPoints.get(i).lon);
|
points.get(i).lat, points.get(i).lon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OsmAndFormatter.getFormattedDistance(dist, view.getApplication());
|
return OsmAndFormatter.getFormattedDistance(dist, view.getApplication());
|
||||||
|
@ -151,7 +153,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
void enterMovingPointMode() {
|
void enterMovingPointMode() {
|
||||||
editingCtx.setInMovePointMode(true);
|
editingCtx.setInMovePointMode(true);
|
||||||
moveMapToPoint(editingCtx.getSelectedPointPosition());
|
moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||||
WptPt pt = editingCtx.getPoints().remove(editingCtx.getSelectedPointPosition());
|
WptPt pt = editingCtx.removePoint(editingCtx.getSelectedPointPosition());
|
||||||
editingCtx.setOriginalPointToMove(pt);
|
editingCtx.setOriginalPointToMove(pt);
|
||||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
|
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
|
||||||
}
|
}
|
||||||
|
@ -199,9 +201,13 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
lineAttrs.updatePaints(view, settings, tb);
|
lineAttrs.updatePaints(view, settings, tb);
|
||||||
|
|
||||||
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
|
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
|
||||||
|
before.renders.clear();
|
||||||
|
before.renders.add(new Renderable.StandardTrack(before.points, 17.2));
|
||||||
before.drawRenderers(view.getZoom(), lineAttrs.paint, canvas, tb);
|
before.drawRenderers(view.getZoom(), lineAttrs.paint, canvas, tb);
|
||||||
|
|
||||||
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
|
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
|
||||||
|
after.renders.clear();
|
||||||
|
after.renders.add(new Renderable.StandardTrack(after.points, 17.2));
|
||||||
after.drawRenderers(view.getZoom(), lineAttrs.paint, canvas, tb);
|
after.drawRenderers(view.getZoom(), lineAttrs.paint, canvas, tb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,11 +269,13 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
canvas.drawPath(path, lineAttrs.paint);
|
canvas.drawPath(path, lineAttrs.paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<WptPt> measurementPoints = editingCtx.getPoints();
|
List<WptPt> points = new ArrayList<>();
|
||||||
|
points.addAll(editingCtx.getBeforePoints());
|
||||||
|
points.addAll(editingCtx.getAfterPoints());
|
||||||
overlapped = false;
|
overlapped = false;
|
||||||
int drawn = 0;
|
int drawn = 0;
|
||||||
for (int i = 0; i < measurementPoints.size(); i++) {
|
for (int i = 0; i < points.size(); i++) {
|
||||||
WptPt pt = measurementPoints.get(i);
|
WptPt pt = points.get(i);
|
||||||
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
||||||
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
||||||
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
||||||
|
@ -279,13 +287,13 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (overlapped) {
|
if (overlapped) {
|
||||||
WptPt pt = measurementPoints.get(0);
|
WptPt pt = points.get(0);
|
||||||
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
||||||
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
||||||
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
||||||
canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint);
|
canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint);
|
||||||
}
|
}
|
||||||
pt = measurementPoints.get(measurementPoints.size() - 1);
|
pt = points.get(points.size() - 1);
|
||||||
locX = tb.getPixXFromLonNoRot(pt.lon);
|
locX = tb.getPixXFromLonNoRot(pt.lon);
|
||||||
locY = tb.getPixYFromLatNoRot(pt.lat);
|
locY = tb.getPixYFromLatNoRot(pt.lat);
|
||||||
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
||||||
|
@ -293,8 +301,8 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < measurementPoints.size(); i++) {
|
for (int i = 0; i < points.size(); i++) {
|
||||||
WptPt pt = measurementPoints.get(i);
|
WptPt pt = points.get(i);
|
||||||
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
||||||
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
||||||
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
||||||
|
@ -317,9 +325,9 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
editingCtx.setInMovePointMode(false);
|
editingCtx.setInMovePointMode(false);
|
||||||
if (saveOriginalPoint) {
|
if (saveOriginalPoint) {
|
||||||
WptPt pt = editingCtx.getOriginalPointToMove();
|
WptPt pt = editingCtx.getOriginalPointToMove();
|
||||||
editingCtx.getPoints().add(editingCtx.getSelectedPointPosition(), pt);
|
editingCtx.addPoint(pt);
|
||||||
}
|
}
|
||||||
editingCtx.recreateSegments();
|
// editingCtx.recreateSegments();
|
||||||
editingCtx.setOriginalPointToMove(null);
|
editingCtx.setOriginalPointToMove(null);
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
}
|
}
|
||||||
|
@ -344,7 +352,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
canvas.rotate(tb.getRotate(), center.x, center.y);
|
canvas.rotate(tb.getRotate(), center.x, center.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WptPt addCenterPoint(int position) {
|
public WptPt addCenterPoint() {
|
||||||
RotatedTileBox tb = view.getCurrentRotatedTileBox();
|
RotatedTileBox tb = view.getCurrentRotatedTileBox();
|
||||||
LatLon l = tb.getLatLonFromPixel(tb.getCenterPixelX(), tb.getCenterPixelY());
|
LatLon l = tb.getLatLonFromPixel(tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||||
WptPt pt = new WptPt();
|
WptPt pt = new WptPt();
|
||||||
|
@ -352,22 +360,24 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
pt.lon = l.getLongitude();
|
pt.lon = l.getLongitude();
|
||||||
boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt);
|
boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt);
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
editingCtx.getPoints().add(position, pt);
|
editingCtx.addPoint(pt);
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WptPt addPoint(int position) {
|
public WptPt addPoint() {
|
||||||
if (pressedPointLatLon != null) {
|
if (pressedPointLatLon != null) {
|
||||||
WptPt pt = new WptPt();
|
WptPt pt = new WptPt();
|
||||||
pt.lat = pressedPointLatLon.getLatitude();
|
double lat = pressedPointLatLon.getLatitude();
|
||||||
pt.lon = pressedPointLatLon.getLongitude();
|
double lon = pressedPointLatLon.getLongitude();
|
||||||
|
pt.lat = lat;
|
||||||
|
pt.lon = lon;
|
||||||
pressedPointLatLon = null;
|
pressedPointLatLon = null;
|
||||||
boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt);
|
boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt);
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
editingCtx.getPoints().add(position, pt);
|
editingCtx.addPoint(pt);
|
||||||
moveMapToPoint(position);
|
moveMapToLatLon(lat, lon);
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,6 +393,10 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void moveMapToLatLon(double lat, double lon) {
|
||||||
|
view.getAnimatedDraggingThread().startMoving(lat, lon, view.getZoom(), true);
|
||||||
|
}
|
||||||
|
|
||||||
public void moveMapToPoint(int pos) {
|
public void moveMapToPoint(int pos) {
|
||||||
if (editingCtx.getPointsCount() > 0) {
|
if (editingCtx.getPointsCount() > 0) {
|
||||||
if (pos >= editingCtx.getPointsCount()) {
|
if (pos >= editingCtx.getPointsCount()) {
|
||||||
|
@ -391,7 +405,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
WptPt pt = editingCtx.getPoints().get(pos);
|
WptPt pt = editingCtx.getPoints().get(pos);
|
||||||
view.getAnimatedDraggingThread().startMoving(pt.getLatitude(), pt.getLongitude(), view.getZoom(), true);
|
moveMapToLatLon(pt.getLatitude(), pt.getLongitude());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@ public class AddPointCommand extends MeasurementModeCommand {
|
||||||
@Override
|
@Override
|
||||||
public boolean execute() {
|
public boolean execute() {
|
||||||
if (center) {
|
if (center) {
|
||||||
point = measurementLayer.addCenterPoint(position);
|
point = measurementLayer.addCenterPoint();
|
||||||
} else {
|
} else {
|
||||||
point = measurementLayer.addPoint(position);
|
point = measurementLayer.addPoint();
|
||||||
}
|
}
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
return point != null;
|
return point != null;
|
||||||
|
@ -34,13 +34,13 @@ public class AddPointCommand extends MeasurementModeCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo() {
|
public void undo() {
|
||||||
measurementLayer.getEditingCtx().getPoints().remove(position);
|
measurementLayer.getEditingCtx().removePoint(position);
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void redo() {
|
public void redo() {
|
||||||
measurementLayer.getEditingCtx().getPoints().add(position, point);
|
measurementLayer.getEditingCtx().addPoint(position, point);
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
measurementLayer.moveMapToPoint(position);
|
measurementLayer.moveMapToPoint(position);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,13 @@ public class ClearPointsCommand extends MeasurementModeCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo() {
|
public void undo() {
|
||||||
measurementLayer.getEditingCtx().getPoints().addAll(points);
|
measurementLayer.getEditingCtx().addPoints(points);
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void redo() {
|
public void redo() {
|
||||||
measurementLayer.getEditingCtx().getPoints().clear();
|
measurementLayer.getEditingCtx().clearSegments();
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,15 +23,15 @@ public class MovePointCommand extends MeasurementModeCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo() {
|
public void undo() {
|
||||||
measurementLayer.getEditingCtx().getPoints().remove(position);
|
measurementLayer.getEditingCtx().removePoint(position);
|
||||||
measurementLayer.getEditingCtx().getPoints().add(position, oldPoint);
|
measurementLayer.getEditingCtx().addPoint(position, oldPoint);
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void redo() {
|
public void redo() {
|
||||||
measurementLayer.getEditingCtx().getPoints().remove(position);
|
measurementLayer.getEditingCtx().removePoint(position);
|
||||||
measurementLayer.getEditingCtx().getPoints().add(position, newPoint);
|
measurementLayer.getEditingCtx().addPoint(position, newPoint);
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,21 +15,21 @@ public class RemovePointCommand extends MeasurementModeCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute() {
|
public boolean execute() {
|
||||||
point = measurementLayer.getEditingCtx().getPoints().remove(position);
|
point = measurementLayer.getEditingCtx().removePoint(position);
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo() {
|
public void undo() {
|
||||||
measurementLayer.getEditingCtx().getPoints().add(position, point);
|
measurementLayer.getEditingCtx().addPoint(position, point);
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
measurementLayer.moveMapToPoint(position);
|
measurementLayer.moveMapToPoint(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void redo() {
|
public void redo() {
|
||||||
measurementLayer.getEditingCtx().getPoints().remove(position);
|
measurementLayer.getEditingCtx().removePoint(position);
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue