Fix plan route options
This commit is contained in:
parent
40edfa2a3f
commit
25f564393b
7 changed files with 228 additions and 130 deletions
|
@ -315,10 +315,14 @@ public class GPXUtilities {
|
||||||
getExtensionsToWrite().put(PROFILE_TYPE_EXTENSION, profileType);
|
getExtensionsToWrite().put(PROFILE_TYPE_EXTENSION, profileType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeProfileType() {
|
||||||
|
getExtensionsToWrite().remove(PROFILE_TYPE_EXTENSION);
|
||||||
|
}
|
||||||
|
|
||||||
public int getTrkPtIndex() {
|
public int getTrkPtIndex() {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(getExtensionsToRead().get(TRKPT_INDEX_EXTENSION));
|
return Integer.parseInt(getExtensionsToRead().get(TRKPT_INDEX_EXTENSION));
|
||||||
}catch(NumberFormatException e){
|
} catch (NumberFormatException e) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import net.osmand.plus.routing.RouteCalculationResult;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.router.RouteCalculationProgress;
|
import net.osmand.router.RouteCalculationProgress;
|
||||||
import net.osmand.router.RoutePlannerFrontEnd;
|
|
||||||
import net.osmand.router.RoutePlannerFrontEnd.GpxPoint;
|
import net.osmand.router.RoutePlannerFrontEnd.GpxPoint;
|
||||||
import net.osmand.router.RoutePlannerFrontEnd.GpxRouteApproximation;
|
import net.osmand.router.RoutePlannerFrontEnd.GpxRouteApproximation;
|
||||||
import net.osmand.router.RouteSegmentResult;
|
import net.osmand.router.RouteSegmentResult;
|
||||||
|
@ -32,11 +31,11 @@ import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationType.*;
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode.*;
|
||||||
|
|
||||||
public class MeasurementEditingContext {
|
public class MeasurementEditingContext {
|
||||||
|
|
||||||
public enum CalculationType {
|
public enum CalculationMode {
|
||||||
NEXT_SEGMENT,
|
NEXT_SEGMENT,
|
||||||
WHOLE_TRACK
|
WHOLE_TRACK
|
||||||
}
|
}
|
||||||
|
@ -58,8 +57,7 @@ public class MeasurementEditingContext {
|
||||||
private boolean inSnapToRoadMode;
|
private boolean inSnapToRoadMode;
|
||||||
private boolean needUpdateCacheForSnap;
|
private boolean needUpdateCacheForSnap;
|
||||||
private int calculatedPairs;
|
private int calculatedPairs;
|
||||||
private CalculationType calculationType = WHOLE_TRACK;
|
private CalculationMode calculationMode = WHOLE_TRACK;
|
||||||
|
|
||||||
private SnapToRoadProgressListener progressListener;
|
private SnapToRoadProgressListener progressListener;
|
||||||
private ApplicationMode snapToRoadAppMode;
|
private ApplicationMode snapToRoadAppMode;
|
||||||
private RouteCalculationProgress calculationProgress;
|
private RouteCalculationProgress calculationProgress;
|
||||||
|
@ -91,7 +89,7 @@ public class MeasurementEditingContext {
|
||||||
updateCacheForSnapIfNeeded(true);
|
updateCacheForSnapIfNeeded(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSelectedPointPosition() {
|
public int getSelectedPointPosition() {
|
||||||
return selectedPointPosition;
|
return selectedPointPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +109,7 @@ public class MeasurementEditingContext {
|
||||||
this.inAddPointMode = inAddPointMode;
|
this.inAddPointMode = inAddPointMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInSnapToRoadMode(boolean inSnapToRoadMode) {
|
public void setInSnapToRoadMode(boolean inSnapToRoadMode) {
|
||||||
this.inSnapToRoadMode = inSnapToRoadMode;
|
this.inSnapToRoadMode = inSnapToRoadMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,12 +129,12 @@ public class MeasurementEditingContext {
|
||||||
return newGpxData != null && newGpxData.getGpxFile() != null && newGpxData.getGpxFile().hasRtePt();
|
return newGpxData != null && newGpxData.getGpxFile() != null && newGpxData.getGpxFile().hasRtePt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalculationType getCalculationType() {
|
public CalculationMode getCalculationMode() {
|
||||||
return calculationType;
|
return calculationMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCalculationType(CalculationType calculationType) {
|
public void setCalculationMode(CalculationMode calculationMode) {
|
||||||
this.calculationType = calculationType;
|
this.calculationMode = calculationMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setProgressListener(SnapToRoadProgressListener progressListener) {
|
void setProgressListener(SnapToRoadProgressListener progressListener) {
|
||||||
|
@ -147,17 +145,15 @@ public class MeasurementEditingContext {
|
||||||
return snapToRoadAppMode;
|
return snapToRoadAppMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSnapToRoadAppMode(ApplicationMode snapToRoadAppMode) {
|
public void setSnapToRoadAppMode(ApplicationMode snapToRoadAppMode) {
|
||||||
if (this.snapToRoadAppMode != null && snapToRoadAppMode != null
|
|
||||||
&& !this.snapToRoadAppMode.getStringKey().equals(snapToRoadAppMode.getStringKey())) {
|
|
||||||
if (calculationType == WHOLE_TRACK) {
|
|
||||||
snappedToRoadPoints.clear();
|
|
||||||
updateCacheForSnapIfNeeded(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.snapToRoadAppMode = snapToRoadAppMode;
|
this.snapToRoadAppMode = snapToRoadAppMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearSnappedToRoadPoints() {
|
||||||
|
snappedToRoadPoints.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TrkSegment getBeforeTrkSegmentLine() {
|
TrkSegment getBeforeTrkSegmentLine() {
|
||||||
if (beforeCacheForSnap != null) {
|
if (beforeCacheForSnap != null) {
|
||||||
return beforeCacheForSnap;
|
return beforeCacheForSnap;
|
||||||
|
@ -241,7 +237,7 @@ public class MeasurementEditingContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scheduleRouteCalculateIfNotEmpty() {
|
public void scheduleRouteCalculateIfNotEmpty() {
|
||||||
needUpdateCacheForSnap = true;
|
needUpdateCacheForSnap = true;
|
||||||
if (application == null || (before.points.size() == 0 && after.points.size() == 0)) {
|
if (application == null || (before.points.size() == 0 && after.points.size() == 0)) {
|
||||||
return;
|
return;
|
||||||
|
@ -411,9 +407,23 @@ public class MeasurementEditingContext {
|
||||||
final RouteCalculationParams params = new RouteCalculationParams();
|
final RouteCalculationParams params = new RouteCalculationParams();
|
||||||
params.inSnapToRoadMode = true;
|
params.inSnapToRoadMode = true;
|
||||||
params.start = start;
|
params.start = start;
|
||||||
|
|
||||||
|
ApplicationMode currentPointSnapToRoadMode;
|
||||||
|
if (calculationMode == NEXT_SEGMENT) {
|
||||||
|
currentPointSnapToRoadMode = ApplicationMode.valueOfStringKey(currentPair.first.getProfileType(),
|
||||||
|
null);
|
||||||
|
} else {
|
||||||
|
currentPointSnapToRoadMode = snapToRoadAppMode;
|
||||||
|
}
|
||||||
params.end = end;
|
params.end = end;
|
||||||
RoutingHelper.applyApplicationSettings(params, application.getSettings(), snapToRoadAppMode);
|
if (currentPointSnapToRoadMode == null) {
|
||||||
params.mode = snapToRoadAppMode;
|
ApplicationMode straightLine = ApplicationMode.AIRCRAFT;
|
||||||
|
RoutingHelper.applyApplicationSettings(params, application.getSettings(), straightLine);
|
||||||
|
params.mode = straightLine;
|
||||||
|
} else {
|
||||||
|
RoutingHelper.applyApplicationSettings(params, application.getSettings(), currentPointSnapToRoadMode);
|
||||||
|
params.mode = currentPointSnapToRoadMode;
|
||||||
|
}
|
||||||
params.ctx = application;
|
params.ctx = application;
|
||||||
params.calculationProgress = calculationProgress = new RouteCalculationProgress();
|
params.calculationProgress = calculationProgress = new RouteCalculationProgress();
|
||||||
params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
|
params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
|
||||||
|
@ -539,8 +549,14 @@ public class MeasurementEditingContext {
|
||||||
params.start = start;
|
params.start = start;
|
||||||
params.end = end;
|
params.end = end;
|
||||||
params.intermediates = intermediates;
|
params.intermediates = intermediates;
|
||||||
RoutingHelper.applyApplicationSettings(params, application.getSettings(), snapToRoadAppMode);
|
if (snapToRoadAppMode == null) {
|
||||||
params.mode = snapToRoadAppMode;
|
ApplicationMode straightLine = ApplicationMode.AIRCRAFT;
|
||||||
|
RoutingHelper.applyApplicationSettings(params, application.getSettings(), straightLine);
|
||||||
|
params.mode = straightLine;
|
||||||
|
} else {
|
||||||
|
RoutingHelper.applyApplicationSettings(params, application.getSettings(), snapToRoadAppMode);
|
||||||
|
params.mode = snapToRoadAppMode;
|
||||||
|
}
|
||||||
params.ctx = application;
|
params.ctx = application;
|
||||||
params.calculationProgress = calculationProgress = new RouteCalculationProgress();
|
params.calculationProgress = calculationProgress = new RouteCalculationProgress();
|
||||||
params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
|
params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
|
||||||
|
|
|
@ -16,7 +16,6 @@ import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
@ -69,6 +68,7 @@ import net.osmand.plus.measurementtool.SelectedPointBottomSheetDialogFragment.Se
|
||||||
import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter;
|
import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter;
|
||||||
import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter.MeasurementAdapterListener;
|
import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter.MeasurementAdapterListener;
|
||||||
import net.osmand.plus.measurementtool.command.AddPointCommand;
|
import net.osmand.plus.measurementtool.command.AddPointCommand;
|
||||||
|
import net.osmand.plus.measurementtool.command.ChangeRouteModeCommand;
|
||||||
import net.osmand.plus.measurementtool.command.ClearPointsCommand;
|
import net.osmand.plus.measurementtool.command.ClearPointsCommand;
|
||||||
import net.osmand.plus.measurementtool.command.MovePointCommand;
|
import net.osmand.plus.measurementtool.command.MovePointCommand;
|
||||||
import net.osmand.plus.measurementtool.command.RemovePointCommand;
|
import net.osmand.plus.measurementtool.command.RemovePointCommand;
|
||||||
|
@ -95,7 +95,7 @@ import java.util.Locale;
|
||||||
|
|
||||||
import static net.osmand.IndexConstants.GPX_FILE_EXT;
|
import static net.osmand.IndexConstants.GPX_FILE_EXT;
|
||||||
import static net.osmand.plus.measurementtool.GpxApproximationFragment.GpxApproximationFragmentListener;
|
import static net.osmand.plus.measurementtool.GpxApproximationFragment.GpxApproximationFragmentListener;
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationType;
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode;
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.ExportAsGpxListener;
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.ExportAsGpxListener;
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.SnapToRoadProgressListener;
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.SnapToRoadProgressListener;
|
||||||
import static net.osmand.plus.measurementtool.SelectFileBottomSheet.Mode.ADD_TO_TRACK;
|
import static net.osmand.plus.measurementtool.SelectFileBottomSheet.Mode.ADD_TO_TRACK;
|
||||||
|
@ -224,7 +224,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||||
pointsListContainer = view.findViewById(R.id.points_list_container);
|
pointsListContainer = view.findViewById(R.id.points_list_container);
|
||||||
if (portrait && pointsListContainer != null) {
|
if (portrait && pointsListContainer != null) {
|
||||||
final int backgroundColor = ContextCompat.getColor(mapActivity, nightMode ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
|
final int backgroundColor = ContextCompat.getColor(mapActivity, nightMode
|
||||||
|
? R.color.activity_background_color_dark
|
||||||
|
: R.color.activity_background_color_light);
|
||||||
pointsListContainer.setBackgroundColor(backgroundColor);
|
pointsListContainer.setBackgroundColor(backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,13 +313,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
editingCtx.getCommandManager().undo();
|
editingCtx.getCommandManager().undo();
|
||||||
updateUndoRedoButton(editingCtx.getCommandManager().canUndo(), undoBtn);
|
updateUndoRedoButton(editingCtx.getCommandManager().canUndo(), undoBtn);
|
||||||
hidePointsListIfNoPoints();
|
|
||||||
if (editingCtx.getPointsCount() > 0) {
|
|
||||||
enable(upDownBtn);
|
|
||||||
}
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
updateUndoRedoButton(true, redoBtn);
|
updateUndoRedoButton(true, redoBtn);
|
||||||
updateDistancePointsText();
|
updateUndoRedoCommonStuff();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -328,13 +325,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
editingCtx.getCommandManager().redo();
|
editingCtx.getCommandManager().redo();
|
||||||
updateUndoRedoButton(editingCtx.getCommandManager().canRedo(), redoBtn);
|
updateUndoRedoButton(editingCtx.getCommandManager().canRedo(), redoBtn);
|
||||||
hidePointsListIfNoPoints();
|
|
||||||
if (editingCtx.getPointsCount() > 0) {
|
|
||||||
enable(upDownBtn);
|
|
||||||
}
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
updateUndoRedoButton(true, undoBtn);
|
updateUndoRedoButton(true, undoBtn);
|
||||||
updateDistancePointsText();
|
updateUndoRedoCommonStuff();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -447,14 +439,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toolBarController.setOnSwitchCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
||||||
if (!checked) {
|
|
||||||
disableSnapToRoadMode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mapActivity.showTopToolbar(toolBarController);
|
mapActivity.showTopToolbar(toolBarController);
|
||||||
|
|
||||||
adapter = new MeasurementToolAdapter(getMapActivity(), editingCtx.getPoints(),
|
adapter = new MeasurementToolAdapter(getMapActivity(), editingCtx.getPoints(),
|
||||||
|
@ -470,6 +454,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
pointsRv.setLayoutManager(new LinearLayoutManager(getContext()));
|
pointsRv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
pointsRv.setAdapter(adapter);
|
pointsRv.setAdapter(adapter);
|
||||||
|
|
||||||
|
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
|
||||||
|
snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
|
||||||
|
snapToRoadBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
startSnapToRoad(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
snapToRoadBtn.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
initMeasurementMode(newGpxData);
|
initMeasurementMode(newGpxData);
|
||||||
|
|
||||||
if (planRouteMode && savedInstanceState == null) {
|
if (planRouteMode && savedInstanceState == null) {
|
||||||
|
@ -479,19 +473,28 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateUndoRedoCommonStuff() {
|
||||||
|
hidePointsListIfNoPoints();
|
||||||
|
if (editingCtx.getPointsCount() > 0) {
|
||||||
|
enable(upDownBtn);
|
||||||
|
}
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
updateDistancePointsText();
|
||||||
|
updateSnapToRoadControls();
|
||||||
|
}
|
||||||
|
|
||||||
private void initMeasurementMode(NewGpxData newGpxData) {
|
private void initMeasurementMode(NewGpxData newGpxData) {
|
||||||
editingCtx.getCommandManager().resetMeasurementLayer(getMapActivity().getMapLayers().getMeasurementToolLayer());
|
editingCtx.getCommandManager().resetMeasurementLayer(getMapActivity().getMapLayers().getMeasurementToolLayer());
|
||||||
enterMeasurementMode();
|
enterMeasurementMode();
|
||||||
showSnapToRoadControls();
|
updateSnapToRoadControls();
|
||||||
if (newGpxData != null && !gpxPointsAdded) {
|
if (newGpxData != null && !gpxPointsAdded) {
|
||||||
List<WptPt> points = newGpxData.getGpxFile().getRoutePoints();
|
List<WptPt> points = newGpxData.getGpxFile().getRoutePoints();
|
||||||
|
ApplicationMode snapToRoadAppMode = null;
|
||||||
if (!points.isEmpty()) {
|
if (!points.isEmpty()) {
|
||||||
ApplicationMode snapToRoadAppMode = ApplicationMode
|
snapToRoadAppMode = ApplicationMode
|
||||||
.valueOfStringKey(points.get(points.size() - 1).getProfileType(), null);
|
.valueOfStringKey(points.get(points.size() - 1).getProfileType(), null);
|
||||||
if (snapToRoadAppMode != null) {
|
|
||||||
enableSnapToRoadMode(snapToRoadAppMode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
enableSnapToRoadMode(snapToRoadAppMode);
|
||||||
ActionType actionType = newGpxData.getActionType();
|
ActionType actionType = newGpxData.getActionType();
|
||||||
if (actionType == ActionType.ADD_ROUTE_POINTS) {
|
if (actionType == ActionType.ADD_ROUTE_POINTS) {
|
||||||
displayRoutePoints();
|
displayRoutePoints();
|
||||||
|
@ -639,7 +642,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
if (editingCtx.isNewData() || editingCtx.hasRoutePoints()) {
|
if (editingCtx.isNewData() || editingCtx.hasRoutePoints()) {
|
||||||
RouteBetweenPointsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
RouteBetweenPointsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||||
this, editingCtx.getCalculationType(),
|
this, editingCtx.getCalculationMode(),
|
||||||
editingCtx.getSnapToRoadAppMode());
|
editingCtx.getSnapToRoadAppMode());
|
||||||
} else {
|
} else {
|
||||||
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
|
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
|
||||||
|
@ -772,9 +775,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteOnClick() {
|
public void deleteOnClick() {
|
||||||
if (measurementLayer != null) {
|
removePoint(measurementLayer, editingCtx.getSelectedPointPosition());
|
||||||
removePoint(measurementLayer, editingCtx.getSelectedPointPosition());
|
|
||||||
}
|
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,21 +827,17 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChangeApplicationMode(ApplicationMode mode) {
|
public void onChangeApplicationMode(ApplicationMode mode, CalculationMode calculationMode) {
|
||||||
if (mode == null) {
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
disableSnapToRoadMode();
|
if (measurementLayer != null) {
|
||||||
editingCtx.setSnapToRoadAppMode(null);
|
editingCtx.getCommandManager().execute(new ChangeRouteModeCommand(measurementLayer, mode, calculationMode));
|
||||||
showSnapToRoadControls();
|
updateUndoRedoButton(false, redoBtn);
|
||||||
} else {
|
disable(upDownBtn);
|
||||||
enableSnapToRoadMode(mode);
|
updateSnapToRoadControls();
|
||||||
|
updateDistancePointsText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChangeCalculationType(CalculationType calculationType) {
|
|
||||||
editingCtx.setCalculationType(calculationType);
|
|
||||||
}
|
|
||||||
|
|
||||||
private StartPlanRouteListener createStartPlanRouteListener() {
|
private StartPlanRouteListener createStartPlanRouteListener() {
|
||||||
return new StartPlanRouteListener() {
|
return new StartPlanRouteListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -946,14 +943,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removePoint(MeasurementToolLayer layer, int position) {
|
private void removePoint(MeasurementToolLayer measurementLayer, int position) {
|
||||||
editingCtx.getCommandManager().execute(new RemovePointCommand(layer, position));
|
if (measurementLayer != null) {
|
||||||
adapter.notifyDataSetChanged();
|
editingCtx.getCommandManager().execute(new RemovePointCommand(measurementLayer, position));
|
||||||
updateUndoRedoButton(true, undoBtn);
|
adapter.notifyDataSetChanged();
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(true, undoBtn);
|
||||||
updateDistancePointsText();
|
updateUndoRedoButton(false, redoBtn);
|
||||||
saved = false;
|
updateDistancePointsText();
|
||||||
hidePointsListIfNoPoints();
|
saved = false;
|
||||||
|
hidePointsListIfNoPoints();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SaveAsNewTrackFragmentListener createSaveAsNewTrackFragmentListener() {
|
private SaveAsNewTrackFragmentListener createSaveAsNewTrackFragmentListener() {
|
||||||
|
@ -980,9 +979,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemoveClick(int position) {
|
public void onRemoveClick(int position) {
|
||||||
if (measurementLayer != null) {
|
removePoint(measurementLayer, position);
|
||||||
removePoint(measurementLayer, position);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1026,10 +1023,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
editingCtx.setSnapToRoadAppMode(appMode);
|
editingCtx.setSnapToRoadAppMode(appMode);
|
||||||
editingCtx.setInSnapToRoadMode(true);
|
editingCtx.setInSnapToRoadMode(true);
|
||||||
editingCtx.scheduleRouteCalculateIfNotEmpty();
|
editingCtx.scheduleRouteCalculateIfNotEmpty();
|
||||||
showSnapToRoadControls();
|
updateSnapToRoadControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSnapToRoadControls() {
|
private void updateSnapToRoadControls() {
|
||||||
final MapActivity mapActivity = getMapActivity();
|
final MapActivity mapActivity = getMapActivity();
|
||||||
final ApplicationMode appMode = editingCtx.getSnapToRoadAppMode();
|
final ApplicationMode appMode = editingCtx.getSnapToRoadAppMode();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
@ -1040,15 +1037,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode));
|
icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode));
|
||||||
}
|
}
|
||||||
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
|
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
|
||||||
snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
|
|
||||||
snapToRoadBtn.setImageDrawable(icon);
|
snapToRoadBtn.setImageDrawable(icon);
|
||||||
snapToRoadBtn.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
startSnapToRoad(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
snapToRoadBtn.setVisibility(View.VISIBLE);
|
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1124,7 +1113,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
private void showAddToTrackDialog(final MapActivity mapActivity) {
|
private void showAddToTrackDialog(final MapActivity mapActivity) {
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
SelectFileBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
|
SelectFileBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
|
||||||
createAddToTrackFileListener(),ADD_TO_TRACK);
|
createAddToTrackFileListener(), ADD_TO_TRACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1223,14 +1212,14 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
||||||
}
|
}
|
||||||
mapActivity.showTopToolbar(toolBarController);
|
mapActivity.showTopToolbar(toolBarController);
|
||||||
|
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
|
||||||
|
AndroidUiHelper.setVisibility(mapActivity, enable ? View.VISIBLE : View.GONE,
|
||||||
|
R.id.move_point_text,
|
||||||
|
R.id.move_point_controls);
|
||||||
|
mainIcon.setImageDrawable(getActiveIcon(enable
|
||||||
|
? R.drawable.ic_action_move_point
|
||||||
|
: R.drawable.ic_action_ruler));
|
||||||
}
|
}
|
||||||
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
|
|
||||||
AndroidUiHelper.setVisibility(mapActivity, enable ? View.VISIBLE : View.GONE,
|
|
||||||
R.id.move_point_text,
|
|
||||||
R.id.move_point_controls);
|
|
||||||
mainIcon.setImageDrawable(getActiveIcon(enable
|
|
||||||
? R.drawable.ic_action_move_point
|
|
||||||
: R.drawable.ic_action_ruler));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchAddPointBeforeAfterMode(boolean enable) {
|
private void switchAddPointBeforeAfterMode(boolean enable) {
|
||||||
|
@ -1243,13 +1232,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
||||||
}
|
}
|
||||||
mapActivity.showTopToolbar(toolBarController);
|
mapActivity.showTopToolbar(toolBarController);
|
||||||
}
|
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
|
||||||
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
|
AndroidUiHelper.setVisibility(mapActivity, enable ? View.VISIBLE : View.GONE,
|
||||||
AndroidUiHelper.setVisibility(mapActivity,enable ? View.VISIBLE : View.GONE,
|
R.id.add_point_before_after_text,
|
||||||
R.id.add_point_before_after_text,
|
R.id.add_point_before_after_controls);
|
||||||
R.id.add_point_before_after_controls);
|
if (!enable) {
|
||||||
if (!enable) {
|
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_ruler));
|
||||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_ruler));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationType;
|
import net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -35,22 +35,22 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.*;
|
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.*;
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationType.NEXT_SEGMENT;
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode.NEXT_SEGMENT;
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationType.WHOLE_TRACK;
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode.WHOLE_TRACK;
|
||||||
|
|
||||||
public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(RouteBetweenPointsBottomSheetDialogFragment.class);
|
private static final Log LOG = PlatformUtil.getLog(RouteBetweenPointsBottomSheetDialogFragment.class);
|
||||||
public static final String TAG = RouteBetweenPointsBottomSheetDialogFragment.class.getSimpleName();
|
public static final String TAG = RouteBetweenPointsBottomSheetDialogFragment.class.getSimpleName();
|
||||||
public static final int STRAIGHT_LINE_TAG = -1;
|
public static final int STRAIGHT_LINE_TAG = -1;
|
||||||
public static final String CALCULATION_TYPE_KEY = "calculation_type";
|
public static final String CALCULATION_MODE_KEY = "calculation_type";
|
||||||
public static final String ROUTE_APP_MODE_KEY = "route_app_mode";
|
public static final String ROUTE_APP_MODE_KEY = "route_app_mode";
|
||||||
|
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
private boolean portrait;
|
private boolean portrait;
|
||||||
private boolean snapToRoadEnabled;
|
private boolean snapToRoadEnabled = true;
|
||||||
private TextView btnDescription;
|
private TextView btnDescription;
|
||||||
private CalculationType calculationType = WHOLE_TRACK;
|
private CalculationMode calculationMode = WHOLE_TRACK;
|
||||||
private ApplicationMode snapToRoadAppMode;
|
private ApplicationMode snapToRoadAppMode;
|
||||||
|
|
||||||
private LinearLayout customRadioButton;
|
private LinearLayout customRadioButton;
|
||||||
|
@ -61,10 +61,10 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
snapToRoadAppMode = ApplicationMode.valueOfStringKey(args.getString(ROUTE_APP_MODE_KEY), null);
|
snapToRoadAppMode = ApplicationMode.valueOfStringKey(args.getString(ROUTE_APP_MODE_KEY), null);
|
||||||
calculationType = (CalculationType) args.get(CALCULATION_TYPE_KEY);
|
calculationMode = (CalculationMode) args.get(CALCULATION_MODE_KEY);
|
||||||
}
|
}
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
calculationType = (CalculationType) savedInstanceState.get(CALCULATION_TYPE_KEY);
|
calculationMode = (CalculationMode) savedInstanceState.get(CALCULATION_MODE_KEY);
|
||||||
}
|
}
|
||||||
OsmandApplication app = requiredMyApplication();
|
OsmandApplication app = requiredMyApplication();
|
||||||
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||||
|
@ -108,7 +108,7 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
|
||||||
}
|
}
|
||||||
Fragment fragment = getTargetFragment();
|
Fragment fragment = getTargetFragment();
|
||||||
if (fragment instanceof RouteBetweenPointsFragmentListener) {
|
if (fragment instanceof RouteBetweenPointsFragmentListener) {
|
||||||
((RouteBetweenPointsFragmentListener) fragment).onChangeApplicationMode(mode);
|
((RouteBetweenPointsFragmentListener) fragment).onChangeApplicationMode(mode, calculationMode);
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
|
||||||
updateModeButtons(WHOLE_TRACK);
|
updateModeButtons(WHOLE_TRACK);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateModeButtons(calculationType);
|
updateModeButtons(calculationMode);
|
||||||
return mainView;
|
return mainView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,19 +150,15 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
|
||||||
container.addView(row);
|
container.addView(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateModeButtons(CalculationType calculationType) {
|
private void updateModeButtons(CalculationMode calculationMode) {
|
||||||
if (calculationType == NEXT_SEGMENT) {
|
if (calculationMode == NEXT_SEGMENT) {
|
||||||
UiUtilities.updateCustomRadioButtons(getMyApplication(), customRadioButton, nightMode, LEFT);
|
UiUtilities.updateCustomRadioButtons(getMyApplication(), customRadioButton, nightMode, LEFT);
|
||||||
btnDescription.setText(R.string.rourte_between_points_next_segment_button_desc);
|
btnDescription.setText(R.string.rourte_between_points_next_segment_button_desc);
|
||||||
} else {
|
} else {
|
||||||
btnDescription.setText(R.string.rourte_between_points_whole_track_button_desc);
|
btnDescription.setText(R.string.rourte_between_points_whole_track_button_desc);
|
||||||
UiUtilities.updateCustomRadioButtons(getMyApplication(), customRadioButton, nightMode, RIGHT);
|
UiUtilities.updateCustomRadioButtons(getMyApplication(), customRadioButton, nightMode, RIGHT);
|
||||||
}
|
}
|
||||||
setCalculationType(calculationType);
|
setCalculationMode(calculationMode);
|
||||||
Fragment fragment = getTargetFragment();
|
|
||||||
if (fragment instanceof RouteBetweenPointsFragmentListener) {
|
|
||||||
((RouteBetweenPointsFragmentListener) fragment).onChangeCalculationType(calculationType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addProfileView(LinearLayout container, View.OnClickListener onClickListener, Object tag,
|
private void addProfileView(LinearLayout container, View.OnClickListener onClickListener, Object tag,
|
||||||
|
@ -197,7 +193,7 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putSerializable(CALCULATION_TYPE_KEY, calculationType);
|
outState.putSerializable(CALCULATION_MODE_KEY, calculationMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -209,18 +205,18 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCalculationType(CalculationType calculationType) {
|
public void setCalculationMode(CalculationMode calculationMode) {
|
||||||
this.calculationType = calculationType;
|
this.calculationMode = calculationMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(FragmentManager fm, Fragment targetFragment, CalculationType calculationType,
|
public static void showInstance(FragmentManager fm, Fragment targetFragment, CalculationMode calculationMode,
|
||||||
ApplicationMode applicationMode) {
|
ApplicationMode applicationMode) {
|
||||||
try {
|
try {
|
||||||
if (!fm.isStateSaved()) {
|
if (!fm.isStateSaved()) {
|
||||||
RouteBetweenPointsBottomSheetDialogFragment fragment = new RouteBetweenPointsBottomSheetDialogFragment();
|
RouteBetweenPointsBottomSheetDialogFragment fragment = new RouteBetweenPointsBottomSheetDialogFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(ROUTE_APP_MODE_KEY, applicationMode != null ? applicationMode.getStringKey() : null);
|
args.putString(ROUTE_APP_MODE_KEY, applicationMode != null ? applicationMode.getStringKey() : null);
|
||||||
args.putSerializable(CALCULATION_TYPE_KEY, calculationType);
|
args.putSerializable(CALCULATION_MODE_KEY, calculationMode);
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
fragment.setTargetFragment(targetFragment, 0);
|
fragment.setTargetFragment(targetFragment, 0);
|
||||||
fragment.show(fm, TAG);
|
fragment.show(fm, TAG);
|
||||||
|
@ -234,8 +230,7 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetDial
|
||||||
|
|
||||||
void onCloseRouteDialog(boolean snapToRoadEnabled);
|
void onCloseRouteDialog(boolean snapToRoadEnabled);
|
||||||
|
|
||||||
void onChangeApplicationMode(ApplicationMode mode);
|
void onChangeApplicationMode(ApplicationMode mode, CalculationMode calculationMode);
|
||||||
|
|
||||||
void onChangeCalculationType(CalculationType calculationType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class AddPointCommand extends MeasurementModeCommand {
|
||||||
point = new WptPt();
|
point = new WptPt();
|
||||||
point.lat = latLon.getLatitude();
|
point.lat = latLon.getLatitude();
|
||||||
point.lon = latLon.getLongitude();
|
point.lon = latLon.getLongitude();
|
||||||
|
point.setProfileType(measurementLayer.getEditingCtx().getSnapToRoadAppMode().getStringKey());
|
||||||
}
|
}
|
||||||
this.center = center;
|
this.center = center;
|
||||||
position = measurementLayer.getEditingCtx().getPointsCount();
|
position = measurementLayer.getEditingCtx().getPointsCount();
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
package net.osmand.plus.measurementtool.command;
|
||||||
|
|
||||||
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.plus.measurementtool.MeasurementEditingContext;
|
||||||
|
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.*;
|
||||||
|
|
||||||
|
public class ChangeRouteModeCommand extends MeasurementModeCommand {
|
||||||
|
|
||||||
|
private List<WptPt> points;
|
||||||
|
int pointIdx;
|
||||||
|
ApplicationMode oldMode;
|
||||||
|
ApplicationMode newMode;
|
||||||
|
CalculationMode oldCalculationMode;
|
||||||
|
CalculationMode newCalculationMode;
|
||||||
|
|
||||||
|
|
||||||
|
public ChangeRouteModeCommand(MeasurementToolLayer measurementLayer, ApplicationMode newMode,
|
||||||
|
CalculationMode newCalculationMode) {
|
||||||
|
this.measurementLayer = measurementLayer;
|
||||||
|
this.newMode = newMode;
|
||||||
|
this.newCalculationMode = newCalculationMode;
|
||||||
|
MeasurementEditingContext editingCtx = measurementLayer.getEditingCtx();
|
||||||
|
oldMode = editingCtx.getSnapToRoadAppMode();
|
||||||
|
oldCalculationMode = editingCtx.getCalculationMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute() {
|
||||||
|
MeasurementEditingContext editingCtx = measurementLayer.getEditingCtx();
|
||||||
|
points = new LinkedList<>(editingCtx.getPoints());
|
||||||
|
pointIdx = points.size() - 1;
|
||||||
|
if (pointIdx > 0 && newCalculationMode != CalculationMode.WHOLE_TRACK) {
|
||||||
|
if (newMode != null) {
|
||||||
|
points.get(pointIdx).setProfileType(newMode.getStringKey());
|
||||||
|
} else {
|
||||||
|
points.get(pointIdx).removeProfileType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
editingCtx.setCalculationMode(newCalculationMode);
|
||||||
|
editingCtx.setInSnapToRoadMode(true);
|
||||||
|
editingCtx.setSnapToRoadAppMode(newMode);
|
||||||
|
if (newCalculationMode == CalculationMode.WHOLE_TRACK) {
|
||||||
|
editingCtx.clearSnappedToRoadPoints();
|
||||||
|
}
|
||||||
|
editingCtx.setNeedUpdateCacheForSnap(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
MeasurementEditingContext editingCtx = measurementLayer.getEditingCtx();
|
||||||
|
editingCtx.getPoints().clear();
|
||||||
|
editingCtx.addPoints(points);
|
||||||
|
editingCtx.setSnapToRoadAppMode(oldMode);
|
||||||
|
if (newCalculationMode == CalculationMode.WHOLE_TRACK) {
|
||||||
|
editingCtx.clearSnappedToRoadPoints();
|
||||||
|
}
|
||||||
|
editingCtx.setCalculationMode(oldCalculationMode);
|
||||||
|
editingCtx.setInSnapToRoadMode(true);
|
||||||
|
editingCtx.setNeedUpdateCacheForSnap(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void redo() {
|
||||||
|
MeasurementEditingContext editingCtx = measurementLayer.getEditingCtx();
|
||||||
|
if (pointIdx > 0) {
|
||||||
|
if (newMode != null) {
|
||||||
|
points.get(pointIdx).setProfileType(newMode.getStringKey());
|
||||||
|
} else {
|
||||||
|
points.get(pointIdx).removeProfileType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
editingCtx.setInSnapToRoadMode(true);
|
||||||
|
editingCtx.setCalculationMode(newCalculationMode);
|
||||||
|
editingCtx.setSnapToRoadAppMode(newMode);
|
||||||
|
if (newCalculationMode == CalculationMode.WHOLE_TRACK) {
|
||||||
|
editingCtx.clearSnappedToRoadPoints();
|
||||||
|
}
|
||||||
|
editingCtx.setNeedUpdateCacheForSnap(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
MeasurementCommandType getType() {
|
||||||
|
return MeasurementCommandType.CHANGE_ROUTE_MODE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,7 @@ public abstract class MeasurementModeCommand implements Command {
|
||||||
MOVE_POINT,
|
MOVE_POINT,
|
||||||
REMOVE_POINT,
|
REMOVE_POINT,
|
||||||
REORDER_POINT,
|
REORDER_POINT,
|
||||||
SNAP_TO_ROAD
|
SNAP_TO_ROAD,
|
||||||
|
CHANGE_ROUTE_MODE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue