diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java index defa934878d..a16add0cc8a 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java @@ -1079,9 +1079,12 @@ public List setPoints(GpxRouteApproximation gpxApproximation, List return routePoints; } - private boolean needDuplicatePoint(List gpxPoints, int i) { - List routeToTarget = gpxPoints.get(i).routeToTarget; - List routeToTargetNext = gpxPoints.get(i + 1).routeToTarget; + private boolean needDuplicatePoint(List gpxPoints, int index) { + if (index == gpxPoints.size() - 1) { + return false; + } + List routeToTarget = gpxPoints.get(index).routeToTarget; + List routeToTargetNext = gpxPoints.get(index + 1).routeToTarget; return routeToTarget.get(routeToTarget.size() - 1).getEndPoint() .equals(routeToTargetNext.get(0).getStartPoint()); }