mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
fix: always use GPSCoordinate.hasAltitude to check if altitude value is valid
Altitude is a floating point value that supports NaN so it is too easy to use the wrong comparison operation.
This commit is contained in:
+1
-1
@@ -72,7 +72,7 @@ public class DefaultWorkoutCharts {
|
||||
}
|
||||
|
||||
// Elevation
|
||||
if (point.getLocation() != null && point.getLocation().getAltitude() != GPSCoordinate.UNKNOWN_ALTITUDE) {
|
||||
if (point.getLocation() != null && point.getLocation().hasAltitude()) {
|
||||
elevationDataPoints.add(new Entry(tsShorten, (float) point.getLocation().getAltitude()));
|
||||
if (point.getLocation().getAltitude() != 0) {
|
||||
// Some devices provide all points at zero
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ public class BangleJSWorkoutParser implements ActivitySummaryParser, ActivityTra
|
||||
if (p.getSteps() > 0) {
|
||||
accStride.add(distanceDiff / p.getSteps());
|
||||
}
|
||||
if (p.getLocation() != null && p.getLocation().getAltitude() != GPSCoordinate.UNKNOWN_ALTITUDE) {
|
||||
if (p.getLocation() != null && p.getLocation().hasAltitude()) {
|
||||
accAltitude.add(p.getLocation().getAltitude());
|
||||
}
|
||||
totalTime += timeDiff;
|
||||
|
||||
@@ -126,9 +126,9 @@ public class GPSCoordinate implements Parcelable {
|
||||
}
|
||||
|
||||
public double getAltitudeDifference(GPSCoordinate source) {
|
||||
if (this.getAltitude() == UNKNOWN_ALTITUDE)
|
||||
if (!hasAltitude())
|
||||
return 0;
|
||||
if (source.getAltitude() == UNKNOWN_ALTITUDE)
|
||||
if (!source.hasAltitude())
|
||||
return 0;
|
||||
return this.getAltitude() - source.getAltitude();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user