Fix reverse route

This commit is contained in:
max-klaus 2020-12-08 16:15:02 +03:00
parent c949f98329
commit e60b99d2d4

View file

@ -32,8 +32,22 @@ public class ReversePointsCommand extends MeasurementModeCommand {
MeasurementEditingContext editingCtx = getEditingCtx(); MeasurementEditingContext editingCtx = getEditingCtx();
oldPoints = new ArrayList<>(editingCtx.getPoints()); oldPoints = new ArrayList<>(editingCtx.getPoints());
oldRoadSegmentData = editingCtx.getRoadSegmentData(); oldRoadSegmentData = editingCtx.getRoadSegmentData();
newPoints = new ArrayList<>(oldPoints); newPoints = new ArrayList<>(oldPoints.size());
Collections.reverse(newPoints); for (int i = oldPoints.size() - 1; i >= 0; i--) {
WptPt point = oldPoints.get(i);
WptPt prevPoint = i > 0 ? oldPoints.get(i - 1) : null;
WptPt newPoint = new WptPt(point);
newPoint.copyExtensions(point);
if (prevPoint != null) {
String profileType = prevPoint.getProfileType();
if (profileType != null) {
newPoint.setProfileType(profileType);
} else {
newPoint.removeProfileType();
}
}
newPoints.add(newPoint);
}
executeCommand(); executeCommand();
return true; return true;
} }