KML description: max/min elevation will not show if have invalid values (unknow).

This commit is contained in:
Román
2020-04-16 18:53:49 +02:00
parent fa9cb3903c
commit 54b9c4370b
4 changed files with 51 additions and 2 deletions
@@ -126,10 +126,14 @@ public class DescriptionGenerator {
writePace(stats.getMaxSpeed(), builder, R.string.description_fastest_pace_in_minute, lineBreak);
// Max elevation
writeElevation(stats.getMaxElevation(), builder, R.string.description_max_elevation, lineBreak);
if (stats.hasElevationMax()) {
writeElevation(stats.getMaxElevation(), builder, R.string.description_max_elevation, lineBreak);
}
// Min elevation
writeElevation(stats.getMinElevation(), builder, R.string.description_min_elevation, lineBreak);
if (stats.hasElevationMin()) {
writeElevation(stats.getMinElevation(), builder, R.string.description_min_elevation, lineBreak);
}
// Elevation gain
writeElevation(stats.getTotalElevationGain(), builder, R.string.description_elevation_gain, lineBreak);
@@ -313,6 +313,9 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
*/
protected TrackPoint getTrackPoint() throws SAXException {
TrackPoint trackPoint = createTrackPoint();
if (trackPoint == null) {
throw new SAXException(createErrorMessage("Invalid location detected: " + trackPoint));
}
// Calculate derived attributes from the previous point
if (trackData.lastLocationInCurrentSegment != null && trackData.lastLocationInCurrentSegment.getTime() != 0) {
@@ -176,6 +176,10 @@ public class TrackStatistics {
this.maxSpeed_mps = maxSpeed;
}
public boolean hasElevationMin() {
return !Double.isInfinite(getMinElevation());
}
/**
* Gets the minimum elevation.
* This is calculated from the smoothed elevation, so this can actually be more than the current elevation.
@@ -193,6 +197,10 @@ public class TrackStatistics {
elevationExtremities.setMin(elevation);
}
public boolean hasElevationMax() {
return !Double.isInfinite(getMaxElevation());
}
/**
* Gets the maximum elevation.
* This is calculated from the smoothed elevation, so this can actually be less than the current elevation.