Fix chart (wrong elevation values)

This commit is contained in:
Alexey Kulish 2017-03-09 16:29:16 +03:00
parent 4a428b6958
commit 156bb571c7
4 changed files with 35 additions and 36 deletions

View file

@ -6,6 +6,7 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.ColorInt;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.data.LocationPoint;
@ -92,14 +93,14 @@ public class GPXUtilities {
}
public static class Elevation {
public double distance;
public float distance;
public int time;
public double elevation;
public float elevation;
}
public static class Speed {
public double distance;
public float distance;
public int time;
public double speed;
public float speed;
}
public static class WptPt extends GPXExtensions implements LocationPoint {
@ -363,9 +364,9 @@ public class GPXUtilities {
minElevation = Math.min(elevation, minElevation);
maxElevation = Math.max(elevation, maxElevation);
elevation1.elevation = elevation;
elevation1.elevation = (float) elevation;
} else {
elevation1.elevation = 0;
elevation1.elevation = Float.NaN;
}
float speed = (float) point.speed;

View file

@ -211,8 +211,6 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
}
}
lastHeight = h;
} else if (lastHeight != HEIGHT_UNDEFINED) {
point.ele = lastHeight;
}
seg.points.add(point);
}

View file

@ -1024,33 +1024,35 @@ public class GpxUiHelper {
float x;
for (Elevation e : elevationData) {
i++;
x = axisType == GPXDataSetAxisType.TIME ? e.time : (float) e.distance;
x = axisType == GPXDataSetAxisType.TIME ? e.time : e.distance;
if (x > 0) {
nextX += x / divX;
elev = (float) e.elevation;
if (prevElevOrig != -80000) {
if (elev > prevElevOrig) {
elev -= 1f;
} else if (prevElevOrig == elev && i < lastIndex) {
hasSameY = true;
lastXSameY = nextX;
continue;
if (!Float.isNaN(e.elevation)) {
elev = e.elevation;
if (prevElevOrig != -80000) {
if (elev > prevElevOrig) {
elev -= 1f;
} else if (prevElevOrig == elev && i < lastIndex) {
hasSameY = true;
lastXSameY = nextX;
continue;
}
if (prevElev == elev && i < lastIndex) {
hasSameY = true;
lastXSameY = nextX;
continue;
}
if (hasSameY) {
values.add(new Entry(lastXSameY, lastEntry.getY()));
}
hasSameY = false;
}
if (prevElev == elev && i < lastIndex) {
hasSameY = true;
lastXSameY = nextX;
continue;
}
if (hasSameY) {
values.add(new Entry(lastXSameY, lastEntry.getY()));
}
hasSameY = false;
prevElevOrig = e.elevation;
prevElev = elev;
nextY = elev * convEle;
lastEntry = new Entry(nextX, nextY);
values.add(lastEntry);
}
prevElevOrig = (float) e.elevation;
prevElev = elev;
nextY = elev * convEle;
lastEntry = new Entry(nextX, nextY);
values.add(lastEntry);
}
}
return values;
@ -1198,7 +1200,7 @@ public class GpxUiHelper {
float nextY;
float x;
for (Speed s : speedData) {
x = axisType == GPXDataSetAxisType.TIME ? s.time : (float) s.distance;
x = axisType == GPXDataSetAxisType.TIME ? s.time : s.distance;
if (x > 0) {
if (axisType == GPXDataSetAxisType.TIME && x > 60) {
values.add(new Entry(nextX + 1, 0));
@ -1206,9 +1208,9 @@ public class GpxUiHelper {
}
nextX += x / divX;
if (Float.isNaN(divSpeed)) {
nextY = (float) (s.speed * mulSpeed);
nextY = s.speed * mulSpeed;
} else {
nextY = (float) (divSpeed / s.speed);
nextY = divSpeed / s.speed;
}
if (nextY < 0) {
nextY = 0;

View file

@ -244,8 +244,6 @@ public class RouteCalculationResult {
}
}
lastHeight = h;
} else if (lastHeight != HEIGHT_UNDEFINED) {
n.setAltitude(lastHeight);
}
locations.add(n);
attachAlarmInfo(alarms, s, i, locations.size());