diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 87f9d4e579..9d6b019cc2 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -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); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java index d78653b93a..314e299760 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java @@ -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 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 points = routeColorize.getResult(false);