From bac0d4f89aa3eea95eb1899b0f6a18f5fb5ed9de Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 24 Feb 2017 22:52:22 +0300 Subject: [PATCH] Fix charts --- .../src/net/osmand/plus/helpers/GpxUiHelper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index c5dbe16475..a442878ccb 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -1018,10 +1018,17 @@ public class GpxUiHelper { List elevationData = analysis.elevationData; float nextX = 0; float nextY; + float prevElev = -80000; + float gist = 1.5f; for (Elevation e : elevationData) { if (e.distance > 0) { nextX += (float) e.distance / divX; nextY = (float) (e.elevation * convEle); + if (Math.abs(prevElev - e.elevation) < gist) { + continue; + } else { + prevElev = (float) e.elevation; + } values.add(new Entry(nextX, nextY)); } } @@ -1253,6 +1260,8 @@ public class GpxUiHelper { float nextYRaw; float prevXRaw; float prevYRaw; + float prevElev = -80000; + float gist = 1.5f; if (elevationData.size() > 1) { Elevation e0 = elevationData.get(0); nextXRaw = e0.distance > 0 ? (float) e0.distance : 0f; @@ -1266,6 +1275,12 @@ public class GpxUiHelper { if (e.distance > 0) { nextXRaw += e.distance; nextYRaw = (float) e.elevation; + if (Math.abs(prevElev - nextYRaw) < gist) { + nextX += (float) e.distance / divX; + continue; + } else { + prevElev = nextYRaw; + } if (nextX == 0) { prevXRaw = nextXRaw; prevYRaw = nextYRaw;