Fix charts

This commit is contained in:
Alexey Kulish 2017-02-24 22:52:22 +03:00
parent 61c87ad4b1
commit bac0d4f89a

View file

@ -1018,10 +1018,17 @@ public class GpxUiHelper {
List<Elevation> elevationData = analysis.elevationData; List<Elevation> elevationData = analysis.elevationData;
float nextX = 0; float nextX = 0;
float nextY; float nextY;
float prevElev = -80000;
float gist = 1.5f;
for (Elevation e : elevationData) { for (Elevation e : elevationData) {
if (e.distance > 0) { if (e.distance > 0) {
nextX += (float) e.distance / divX; nextX += (float) e.distance / divX;
nextY = (float) (e.elevation * convEle); nextY = (float) (e.elevation * convEle);
if (Math.abs(prevElev - e.elevation) < gist) {
continue;
} else {
prevElev = (float) e.elevation;
}
values.add(new Entry(nextX, nextY)); values.add(new Entry(nextX, nextY));
} }
} }
@ -1253,6 +1260,8 @@ public class GpxUiHelper {
float nextYRaw; float nextYRaw;
float prevXRaw; float prevXRaw;
float prevYRaw; float prevYRaw;
float prevElev = -80000;
float gist = 1.5f;
if (elevationData.size() > 1) { if (elevationData.size() > 1) {
Elevation e0 = elevationData.get(0); Elevation e0 = elevationData.get(0);
nextXRaw = e0.distance > 0 ? (float) e0.distance : 0f; nextXRaw = e0.distance > 0 ? (float) e0.distance : 0f;
@ -1266,6 +1275,12 @@ public class GpxUiHelper {
if (e.distance > 0) { if (e.distance > 0) {
nextXRaw += e.distance; nextXRaw += e.distance;
nextYRaw = (float) e.elevation; nextYRaw = (float) e.elevation;
if (Math.abs(prevElev - nextYRaw) < gist) {
nextX += (float) e.distance / divX;
continue;
} else {
prevElev = nextYRaw;
}
if (nextX == 0) { if (nextX == 0) {
prevXRaw = nextXRaw; prevXRaw = nextXRaw;
prevYRaw = nextYRaw; prevYRaw = nextYRaw;