diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java index baa624da4c..aa72954fae 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java @@ -191,7 +191,7 @@ public class MeasurementEditingContext { after = new TrkSegment(); } - public void recreateSegments(int position) { + public void splitSegments(int position) { before = new TrkSegment(); before.points.addAll(measurementPoints.subList(0, position)); addBeforeRenders(); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 623b8c36ef..d281fd5594 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -607,7 +607,7 @@ public class MeasurementToolFragment extends Fragment { public void moveOnClick() { if (measurementLayer != null) { measurementLayer.enterMovingPointMode(); - editingCtx.recreateSegments(editingCtx.getSelectedPointPosition()); + editingCtx.splitSegments(editingCtx.getSelectedPointPosition()); } switchMovePointMode(true); } @@ -624,7 +624,7 @@ public class MeasurementToolFragment extends Fragment { public void addPointAfterOnClick() { if (measurementLayer != null) { editingCtx.setSelectedPointPosition(editingCtx.getSelectedPointPosition() + 1); - editingCtx.recreateSegments(editingCtx.getSelectedPointPosition()); + editingCtx.splitSegments(editingCtx.getSelectedPointPosition()); measurementLayer.enterAddingPointAfterMode(); } switchAddPointAfterMode(true); @@ -633,7 +633,7 @@ public class MeasurementToolFragment extends Fragment { @Override public void addPointBeforeOnClick() { if (measurementLayer != null) { - editingCtx.recreateSegments(editingCtx.getSelectedPointPosition()); + editingCtx.splitSegments(editingCtx.getSelectedPointPosition()); measurementLayer.enterAddingPointBeforeMode(); } switchAddPointBeforeMode(true); @@ -884,7 +884,7 @@ public class MeasurementToolFragment extends Fragment { if (measurementLayer != null) { if (addPointToPosition(editingCtx.getSelectedPointPosition())) { editingCtx.setSelectedPointPosition(editingCtx.getSelectedPointPosition() + 1); - editingCtx.recreateSegments(editingCtx.getSelectedPointPosition()); + editingCtx.splitSegments(editingCtx.getSelectedPointPosition()); measurementLayer.refreshMap(); } } @@ -916,7 +916,7 @@ public class MeasurementToolFragment extends Fragment { MeasurementToolLayer measurementLayer = getMeasurementLayer(); if (measurementLayer != null) { if (addPointToPosition(editingCtx.getSelectedPointPosition())) { - editingCtx.recreateSegments(editingCtx.getSelectedPointPosition()); + editingCtx.splitSegments(editingCtx.getSelectedPointPosition()); measurementLayer.refreshMap(); } } @@ -1040,7 +1040,7 @@ public class MeasurementToolFragment extends Fragment { MeasurementToolLayer measurementLayer = getMeasurementLayer(); if (measurementLayer != null) { added = commandManager.execute(new AddPointCommand(measurementLayer, position)); - editingCtx.recreateSegments(position); + editingCtx.splitSegments(position); doAddOrMovePointCommonStuff(); } return added; diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java index e621dcb5b1..7c0f3f5902 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java @@ -249,6 +249,11 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL ty.add(tb.getCenterPixelY()); } if (after.points.size() > 0) { + if (before.points.size() == 0) { + path.moveTo(tb.getCenterPixelX(), tb.getCenterPixelY()); + tx.add(tb.getCenterPixelX()); + ty.add(tb.getCenterPixelY()); + } WptPt pt = after.points.get(0); int locX = tb.getPixXFromLonNoRot(pt.lon); int locY = tb.getPixYFromLatNoRot(pt.lat);