Fix plan route (reading saved route)

This commit is contained in:
max-klaus 2020-12-06 14:48:15 +03:00
parent cbcf33146d
commit 86e32e5cc3
2 changed files with 7 additions and 9 deletions

View file

@ -315,7 +315,7 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
int[] turnLanes = TurnType.lanesFromString(bundle.getString("turnLanes", null)); int[] turnLanes = TurnType.lanesFromString(bundle.getString("turnLanes", null));
turnType.setLanes(turnLanes); turnType.setLanes(turnLanes);
} }
object.id = bundle.getLong("id", object.id); object.id = bundle.getLong("id", object.id) << 6;
object.types = bundle.getIntArray("types", null); object.types = bundle.getIntArray("types", null);
object.pointTypes = bundle.getIntIntArray("pointTypes", null); object.pointTypes = bundle.getIntIntArray("pointTypes", null);
object.nameIds = bundle.getIntArray("names", null); object.nameIds = bundle.getIntArray("names", null);

View file

@ -523,15 +523,15 @@ public class MeasurementEditingContext {
public void splitPoints(int selectedPointPosition, boolean after) { public void splitPoints(int selectedPointPosition, boolean after) {
int pointIndex = after ? selectedPointPosition : selectedPointPosition - 1; int pointIndex = after ? selectedPointPosition : selectedPointPosition - 1;
if (pointIndex >= 0 && pointIndex < before.points.size()) { if (pointIndex >= 0 && pointIndex + 1 < before.points.size()) {
WptPt point = before.points.get(pointIndex); WptPt point = before.points.get(pointIndex);
WptPt newPoint = new WptPt(); WptPt nextPoint = before.points.get(pointIndex + 1);
newPoint.lat = point.lat; WptPt newPoint = new WptPt(point);
newPoint.lon = point.lon;
newPoint.copyExtensions(point); newPoint.copyExtensions(point);
newPoint.setGap(); newPoint.setGap();
before.points.remove(pointIndex); before.points.remove(pointIndex);
before.points.add(pointIndex, newPoint); before.points.add(pointIndex, newPoint);
roadSegmentData.remove(new Pair<>(point, nextPoint));
updateSegmentsForSnap(false); updateSegmentsForSnap(false);
} }
} }
@ -549,9 +549,7 @@ public class MeasurementEditingContext {
gapIndex = selectedPointPosition; gapIndex = selectedPointPosition;
} }
if (gapPoint != null) { if (gapPoint != null) {
WptPt newPoint = new WptPt(); WptPt newPoint = new WptPt(gapPoint);
newPoint.lat = gapPoint.lat;
newPoint.lon = gapPoint.lon;
newPoint.copyExtensions(gapPoint); newPoint.copyExtensions(gapPoint);
newPoint.removeProfileType(); newPoint.removeProfileType();
before.points.remove(gapIndex); before.points.remove(gapIndex);
@ -786,7 +784,7 @@ public class MeasurementEditingContext {
pairPoints.add(points.get(j)); pairPoints.add(points.get(j));
prevPointIndex = j; prevPointIndex = j;
} }
if (points.size() > prevPointIndex + 1) { if (points.size() > prevPointIndex + 1 && i == routePoints.size() - 2) {
pairPoints.add(points.get(prevPointIndex + 1)); pairPoints.add(points.get(prevPointIndex + 1));
} }
Iterator<RouteSegmentResult> it = routeSegments.iterator(); Iterator<RouteSegmentResult> it = routeSegments.iterator();