Fix chart

This commit is contained in:
Alexey Kulish 2017-03-04 00:44:58 +03:00
parent faa01e4edc
commit 9fbc5e1348

View file

@ -1041,6 +1041,7 @@ public class GpxUiHelper {
} else if (elev > prevElev) { } else if (elev > prevElev) {
shift = -1f; shift = -1f;
} else if (prevElev == elev && i < lastIndex) { } else if (prevElev == elev && i < lastIndex) {
values.add(new Entry(nextX, entry.getY()));
continue; continue;
} }
} }
@ -1071,24 +1072,24 @@ public class GpxUiHelper {
newValues.add(e); newValues.add(e);
lastEntry = e; lastEntry = e;
} }
*/
List<Point2D> points = new ArrayList<>(newValues.size()); List<Point2D> points = new ArrayList<>(values.size());
for (Entry e : newValues) { for (Entry e : values) {
points.add(new Point2D(e.getX(), e.getY())); points.add(new Point2D(e.getX(), e.getY()));
} }
List<Segment> spline = calculateSpline(points); List<Segment> spline = calculateSpline(points);
if (spline != null) { if (spline != null) {
int count = 8; int count = 8;
newValues = new ArrayList<>(); values = new ArrayList<>();
for (Segment s : spline) { for (Segment s : spline) {
Point2D p = new Point2D(); Point2D p = new Point2D();
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
s.calc((double) i / (double) count, p); s.calc((double) i / (double) count, p);
newValues.add(new Entry((float) p.x, (float) p.y)); values.add(new Entry((float) p.x, (float) p.y));
} }
} }
} }
*/
OrderedLineDataSet dataSet = new OrderedLineDataSet(values, "", GPXDataSetType.ALTITUDE); OrderedLineDataSet dataSet = new OrderedLineDataSet(values, "", GPXDataSetType.ALTITUDE);
dataSet.priority = (float) (analysis.avgElevation - analysis.minElevation) * convEle; dataSet.priority = (float) (analysis.avgElevation - analysis.minElevation) * convEle;
@ -1362,6 +1363,7 @@ public class GpxUiHelper {
} else if (elev > prevElev) { } else if (elev > prevElev) {
shift = -1f; shift = -1f;
} else if (prevElev == elev && i < lastIndex) { } else if (prevElev == elev && i < lastIndex) {
values.add(new Entry(nextX, entry.getY()));
continue; continue;
} }
} }
@ -1511,7 +1513,7 @@ public class GpxUiHelper {
int index = (int) ((GREEN_PROXIMITY / STEP) / 2); int index = (int) ((GREEN_PROXIMITY / STEP) / 2);
for (int k = 0; k < calculatedGreenDist.length; k++) { for (int k = 0; k < calculatedGreenDist.length; k++) {
calculatedGreenDist[k] = calculatedDist[index + k]; calculatedGreenDist[k] = calculatedDist[index + k];
calculatedGreenH[k] = (calculatedH[k] - calculatedH[ 2 * index + k]) * 100 / GREEN_PROXIMITY; calculatedGreenH[k] = (calculatedH[ 2 * index + k] - calculatedH[k]) * 100 / GREEN_PROXIMITY;
if (Double.isNaN(calculatedGreenH[k])) { if (Double.isNaN(calculatedGreenH[k])) {
calculatedGreenH[k] = 0; calculatedGreenH[k] = 0;
} }