forked from upstream-mirrors/OpenTracks
Bugfix: ChartFragment needs to show elevation in M/FT.
This commit is contained in:
@@ -54,7 +54,7 @@ public class ChartPointTest {
|
|||||||
ChartPoint point = new ChartPoint(statistics, TrackStubUtils.createDefaultTrackPoint(), Speed.of(10), 50, false, true);
|
ChartPoint point = new ChartPoint(statistics, TrackStubUtils.createDefaultTrackPoint(), Speed.of(10), 50, false, true);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(0.05, point.getAltitude(), 0.01);
|
assertEquals(50, point.getAltitude(), 0.01);
|
||||||
assertEquals(36, point.getSpeed(), 0.01);
|
assertEquals(36, point.getSpeed(), 0.01);
|
||||||
assertEquals(1.66, point.getPace(), 0.01);
|
assertEquals(1.66, point.getPace(), 0.01);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ public class ChartPoint {
|
|||||||
|
|
||||||
public ChartPoint(@NonNull TrackStatistics trackStatistics, @NonNull TrackPoint trackPoint, Speed smoothedSpeed, double smoothedAltitude_m, boolean chartByDistance, boolean metricUnits) {
|
public ChartPoint(@NonNull TrackStatistics trackStatistics, @NonNull TrackPoint trackPoint, Speed smoothedSpeed, double smoothedAltitude_m, boolean chartByDistance, boolean metricUnits) {
|
||||||
if (chartByDistance) {
|
if (chartByDistance) {
|
||||||
timeOrDistance = trackStatistics.getTotalDistance().to(metricUnits);
|
timeOrDistance = trackStatistics.getTotalDistance().toKM_Miles(metricUnits);
|
||||||
} else {
|
} else {
|
||||||
timeOrDistance = trackStatistics.getTotalTime().toMillis();
|
timeOrDistance = trackStatistics.getTotalTime().toMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
altitude = Distance.of(smoothedAltitude_m).to(metricUnits);
|
altitude = Distance.of(smoothedAltitude_m).toM_FT(metricUnits);
|
||||||
|
|
||||||
speed = smoothedSpeed.to(metricUnits);
|
speed = smoothedSpeed.to(metricUnits);
|
||||||
pace = smoothedSpeed.toPace(metricUnits).toMillis() * UnitConversions.MS_TO_S * UnitConversions.S_TO_MIN;
|
pace = smoothedSpeed.toPace(metricUnits).toMillis() * UnitConversions.MS_TO_S * UnitConversions.S_TO_MIN;
|
||||||
|
|||||||
@@ -993,7 +993,7 @@ public class ChartView extends View {
|
|||||||
|
|
||||||
private double getMarkerXValue(Marker marker) {
|
private double getMarkerXValue(Marker marker) {
|
||||||
if (chartByDistance) {
|
if (chartByDistance) {
|
||||||
return marker.getLength().to(metricUnits);
|
return marker.getLength().toKM_Miles(metricUnits);
|
||||||
} else {
|
} else {
|
||||||
return marker.getDuration().toMillis();
|
return marker.getDuration().toMillis();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,24 +98,12 @@ public class Distance {
|
|||||||
return toKM() * UnitConversions.KM_TO_MI;
|
return toKM() * UnitConversions.KM_TO_MI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double to(boolean metricUnit) {
|
public double toKM_Miles(boolean metricUnit) {
|
||||||
return to(metricUnit ? Unit.KM : Unit.MILES);
|
return metricUnit ? toKM() : toMI();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double to(Unit unit) {
|
public double toM_FT(boolean metricUnit) {
|
||||||
switch (unit) {
|
return metricUnit ? toM() : toFT();
|
||||||
case KM:
|
|
||||||
return toKM();
|
|
||||||
case MILES:
|
|
||||||
return toMI();
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Not implemented");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Unit {
|
|
||||||
KM,
|
|
||||||
MILES
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class PeriodicTaskExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double distance = trackStatistics.getTotalDistance().to(metricUnits);
|
double distance = trackStatistics.getTotalDistance().toKM_Miles(metricUnits);
|
||||||
|
|
||||||
// The index will be negative since the frequency is negative.
|
// The index will be negative since the frequency is negative.
|
||||||
int index = (int) (distance / taskFrequency);
|
int index = (int) (distance / taskFrequency);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class AnnouncementUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int totalDistanceId = isMetricUnits ? R.plurals.voiceTotalDistanceKilometers : R.plurals.voiceTotalDistanceMiles;
|
int totalDistanceId = isMetricUnits ? R.plurals.voiceTotalDistanceKilometers : R.plurals.voiceTotalDistanceMiles;
|
||||||
double distanceInUnit = distance.to(isMetricUnits);
|
double distanceInUnit = distance.toKM_Miles(isMetricUnits);
|
||||||
String totalDistance = context.getResources().getQuantityString(totalDistanceId, getQuantityCount(distanceInUnit), distanceInUnit);
|
String totalDistance = context.getResources().getQuantityString(totalDistanceId, getQuantityCount(distanceInUnit), distanceInUnit);
|
||||||
|
|
||||||
currentRateMsg = currentInterval == null ? "" : " " + currentRateMsg;
|
currentRateMsg = currentInterval == null ? "" : " " + currentRateMsg;
|
||||||
|
|||||||
Reference in New Issue
Block a user