diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWay.java index 2a308669968..51ede650e68 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWay.java @@ -386,6 +386,10 @@ protected List> cutStartOfCachedPath(@NonNull MapRendererVi boolean previousVisible) { List> croppedPathsData31 = new ArrayList<>(); boolean drawNext = false; + float passedDist = 0; + int firstX31 = -1; + int firstY31 = -1; + boolean renew = true; for (List pathsDataList : pathsData31Cache) { if (drawNext) { croppedPathsData31.add(pathsDataList); @@ -394,19 +398,16 @@ protected List> cutStartOfCachedPath(@NonNull MapRendererVi } List newPathsDataList = new ArrayList<>(); for (DrawPathData31 pathData : pathsDataList) { - if (drawNext) { + if (drawNext && startLocationIndexCached == -1) { newPathsDataList.add(pathData); continue; } - if (pathData.indexes.contains(startLocationIndex)) { + if (pathData.indexes.size() < 3 || pathData.indexes.contains(startLocationIndex)) { List ind = new ArrayList<>(); List tx = new ArrayList<>(); List ty = new ArrayList<>(); List heights = new ArrayList<>(); List indexes = pathData.indexes; - float passedDist = 0; - int firstX31 = -1; - int firstY31 = -1; for (int i = 0; i < indexes.size(); i++) { Integer index = indexes.get(i); if (previousVisible && index >= INITIAL_POINT_INDEX_SHIFT) { @@ -434,13 +435,18 @@ protected List> cutStartOfCachedPath(@NonNull MapRendererVi } } if (previousVisible) { - if (startLocationIndexCached != -1 && !this.points.isEmpty() && firstX31 != -1) { - GeometryWayPoint firstPnt = this.points.get(0); - double distDiff = MapUtils.measuredDist31(firstX31, firstY31, firstPnt.tx31, firstPnt.ty31); - updatePathLine(passedDist + (float) (distDiff)); - return null; + if (startLocationIndexCached != -1) { + if (!this.points.isEmpty() && firstX31 != -1) { + GeometryWayPoint firstPnt = this.points.get(0); + passedDist += (float) MapUtils.measuredDist31(firstX31, firstY31, firstPnt.tx31, firstPnt.ty31); + renew = false; + } + } else { + startLocationIndexCached = startLocationIndex; } - startLocationIndexCached = startLocationIndex; + } + if (!renew) { + break; } if (tx.size() > 1) { DrawPathData31 newPathData = new DrawPathData31(ind, tx, ty, pathData.style); @@ -452,10 +458,16 @@ protected List> cutStartOfCachedPath(@NonNull MapRendererVi drawNext = true; } } + if (!renew) { + break; + } croppedPathsData31.add(newPathsDataList); drawPathLine(tb, newPathsDataList); } - + if (!renew) { + updatePathLine(passedDist); + return null; + } if (shouldDrawArrows()) { VectorLinesCollection vectorLinesCollection = this.vectorLinesCollection; VectorLineArrowsProvider vectorLineArrowsProvider = this.vectorLineArrowsProvider;