Skip to content

Commit

Permalink
Merge pull request #20965 from osmandapp/Fix_gradient_route_gap_in_na…
Browse files Browse the repository at this point in the history
…vigation

Fix gaps in gradient route during navigation
  • Loading branch information
alex-osm authored Oct 2, 2024
2 parents beda3a3 + f12c530 commit 1a6fd37
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWay.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ protected List<List<DrawPathData31>> cutStartOfCachedPath(@NonNull MapRendererVi
boolean previousVisible) {
List<List<DrawPathData31>> croppedPathsData31 = new ArrayList<>();
boolean drawNext = false;
float passedDist = 0;
int firstX31 = -1;
int firstY31 = -1;
boolean renew = true;
for (List<DrawPathData31> pathsDataList : pathsData31Cache) {
if (drawNext) {
croppedPathsData31.add(pathsDataList);
Expand All @@ -394,19 +398,16 @@ protected List<List<DrawPathData31>> cutStartOfCachedPath(@NonNull MapRendererVi
}
List<DrawPathData31> 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<Integer> ind = new ArrayList<>();
List<Integer> tx = new ArrayList<>();
List<Integer> ty = new ArrayList<>();
List<Float> heights = new ArrayList<>();
List<Integer> 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) {
Expand Down Expand Up @@ -434,13 +435,18 @@ protected List<List<DrawPathData31>> 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);
Expand All @@ -452,10 +458,16 @@ protected List<List<DrawPathData31>> 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;
Expand Down

0 comments on commit 1a6fd37

Please sign in to comment.