Fix spoiled points

This commit is contained in:
cepprice 2021-04-16 11:02:27 +05:00
parent 149b89090b
commit aa6b04a924
2 changed files with 22 additions and 1 deletions

View file

@ -2139,16 +2139,29 @@ public class GpxUiHelper {
float h = (float) l.getAltitude();
point.ele = h;
if (lastHeight == HEIGHT_UNDEFINED && seg.points.size() > 0) {
for (GPXUtilities.WptPt pt : seg.points) {
for (int i = seg.points.size() - 1; i >= 0; i--) {
GPXUtilities.WptPt pt = seg.points.get(i);
if (Double.isNaN(pt.ele)) {
pt.ele = h;
}
}
}
lastHeight = h;
} else {
lastHeight = HEIGHT_UNDEFINED;
}
seg.points.add(point);
}
if (lastHeight == HEIGHT_UNDEFINED && gpx.hasAltitude) {
int start = seg.points.size() - 1;
while (start > 0 && Double.isNaN(seg.points.get(start).ele)) {
start--;
}
double ele = seg.points.get(start).ele;
for (int i = start + 1; i < seg.points.size(); i++) {
seg.points.get(i).ele = ele;
}
}
track.segments.add(seg);
gpx.tracks.add(track);
}

View file

@ -4,6 +4,7 @@ import android.graphics.Bitmap;
import android.graphics.Paint;
import android.graphics.PointF;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.Location;
import net.osmand.data.RotatedTileBox;
@ -71,6 +72,13 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
updateWay(locations, tb);
}
// Start point can have wrong zero altitude
List<GPXUtilities.WptPt> pts = gpxFile.tracks.get(0).segments.get(0).points;
GPXUtilities.WptPt firstPt = pts.get(0);
if (firstPt.ele == 0) {
firstPt.ele = pts.get(1).ele;
}
RouteColorize routeColorize = new RouteColorize(tb.getZoom(), gpxFile, null, scaleType.toColorizationType(), 0);
List<RouteColorizationPoint> points = routeColorize.getResult(false);