Save snap to road
This commit is contained in:
parent
56df79a343
commit
146d955431
2 changed files with 43 additions and 27 deletions
|
@ -112,7 +112,8 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
private enum SaveType {
|
private enum SaveType {
|
||||||
ROUTE_POINT,
|
ROUTE_POINT,
|
||||||
LINE
|
LINE,
|
||||||
|
SNAP_TO_ROAD
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEditingCtx(MeasurementEditingContext editingCtx) {
|
private void setEditingCtx(MeasurementEditingContext editingCtx) {
|
||||||
|
@ -459,12 +460,12 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
cancelModes();
|
||||||
exitMeasurementMode();
|
exitMeasurementMode();
|
||||||
adapter.setAdapterListener(null);
|
adapter.setAdapterListener(null);
|
||||||
if (pointsListOpened) {
|
if (pointsListOpened) {
|
||||||
hidePointsList();
|
hidePointsList();
|
||||||
}
|
}
|
||||||
closeModes();
|
|
||||||
MeasurementToolLayer layer = getMeasurementLayer();
|
MeasurementToolLayer layer = getMeasurementLayer();
|
||||||
if (layer != null) {
|
if (layer != null) {
|
||||||
layer.setOnSingleTapListener(null);
|
layer.setOnSingleTapListener(null);
|
||||||
|
@ -837,7 +838,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
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.addPoint(newPoint);
|
editingCtx.addPoint(newPoint);
|
||||||
measurementLayer.exitMovePointMode(false);
|
exitMovePointMode(false);
|
||||||
doAddOrMovePointCommonStuff();
|
doAddOrMovePointCommonStuff();
|
||||||
measurementLayer.refreshMap();
|
measurementLayer.refreshMap();
|
||||||
}
|
}
|
||||||
|
@ -845,22 +846,28 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
private void cancelMovePointMode() {
|
private void cancelMovePointMode() {
|
||||||
switchMovePointMode(false);
|
switchMovePointMode(false);
|
||||||
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
exitMovePointMode(true);
|
||||||
if (measurementToolLayer != null) {
|
MapActivity mapActivity = getMapActivity();
|
||||||
measurementToolLayer.exitMovePointMode(true);
|
if (mapActivity != null) {
|
||||||
measurementToolLayer.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeModes() {
|
void exitMovePointMode(boolean saveOriginalPoint) {
|
||||||
if (editingCtx.getOriginalPointToMove() != null) {
|
if (saveOriginalPoint) {
|
||||||
switchMovePointMode(false);
|
WptPt pt = editingCtx.getOriginalPointToMove();
|
||||||
} else if (editingCtx.getSelectedPointPosition() != -1) {
|
editingCtx.addPoint(pt);
|
||||||
switchAddPointBeforeAfterMode(false);
|
|
||||||
}
|
}
|
||||||
MeasurementToolLayer layer = getMeasurementLayer();
|
editingCtx.setOriginalPointToMove(null);
|
||||||
if (layer != null && editingCtx.getOriginalPointToMove() != null) {
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
layer.exitMovePointMode(true);
|
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelModes() {
|
||||||
|
if (editingCtx.getOriginalPointToMove() != null) {
|
||||||
|
cancelMovePointMode();
|
||||||
|
} else if (editingCtx.getSelectedPointPosition() != -1) {
|
||||||
|
cancelAddPointBeforeOrAfterMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,7 +1163,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
closeModes();
|
cancelModes();
|
||||||
MapActivity activity = getMapActivity();
|
MapActivity activity = getMapActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
progressDialog = new ProgressDialog(activity);
|
progressDialog = new ProgressDialog(activity);
|
||||||
|
@ -1184,6 +1191,19 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
Route rt = new Route();
|
Route rt = new Route();
|
||||||
gpx.routes.add(rt);
|
gpx.routes.add(rt);
|
||||||
rt.points.addAll(points);
|
rt.points.addAll(points);
|
||||||
|
} else if (saveType == SaveType.SNAP_TO_ROAD) {
|
||||||
|
TrkSegment segmentToSave = new TrkSegment();
|
||||||
|
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
|
||||||
|
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
|
||||||
|
segmentToSave.points.addAll(before.points);
|
||||||
|
segmentToSave.points.addAll(after.points);
|
||||||
|
Track track = new Track();
|
||||||
|
track.segments.add(segmentToSave);
|
||||||
|
gpx.tracks.add(track);
|
||||||
|
|
||||||
|
Route rt = new Route();
|
||||||
|
rt.points.addAll(points);
|
||||||
|
gpx.routes.add(rt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
|
@ -1398,7 +1418,13 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
fileName = name + "_" + (++ind) + GPX_SUFFIX;
|
fileName = name + "_" + (++ind) + GPX_SUFFIX;
|
||||||
fout = new File(dir, fileName);
|
fout = new File(dir, fileName);
|
||||||
}
|
}
|
||||||
saveNewGpx(dir, fileName, showOnMapToggle.isChecked(), SaveType.LINE, true);
|
SaveType saveType;
|
||||||
|
if (editingCtx.isInSnapToRoadMode()) {
|
||||||
|
saveType = SaveType.SNAP_TO_ROAD;
|
||||||
|
} else {
|
||||||
|
saveType = SaveType.LINE;
|
||||||
|
}
|
||||||
|
saveNewGpx(dir, fileName, showOnMapToggle.isChecked(), saveType, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -300,16 +300,6 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void exitMovePointMode(boolean saveOriginalPoint) {
|
|
||||||
if (saveOriginalPoint) {
|
|
||||||
WptPt pt = editingCtx.getOriginalPointToMove();
|
|
||||||
editingCtx.addPoint(pt);
|
|
||||||
}
|
|
||||||
editingCtx.setOriginalPointToMove(null);
|
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
|
||||||
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawCenterIcon(Canvas canvas, RotatedTileBox tb, QuadPoint center, boolean nightMode) {
|
private void drawCenterIcon(Canvas canvas, RotatedTileBox tb, QuadPoint center, boolean nightMode) {
|
||||||
canvas.rotate(-tb.getRotate(), center.x, center.y);
|
canvas.rotate(-tb.getRotate(), center.x, center.y);
|
||||||
if (nightMode) {
|
if (nightMode) {
|
||||||
|
|
Loading…
Reference in a new issue