mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-10 21:13:11 +02:00
Added elevation loss via barometer (like elevation gain). Fixes #547.
This commit is contained in:
@@ -665,6 +665,7 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
try {
|
||||
if (elevationSumManager != null) {
|
||||
trackPoint.setElevationGain(elevationSumManager.getElevationGain_m());
|
||||
trackPoint.setElevationLoss(elevationSumManager.getElevationLoss_m());
|
||||
elevationSumManager.reset();
|
||||
}
|
||||
contentProviderUtils.insertTrackPoint(trackPoint, track.getId());
|
||||
@@ -680,7 +681,6 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
voiceExecutor.update();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the recording track time.
|
||||
*
|
||||
@@ -718,6 +718,17 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
||||
return elevationSumManager.getElevationGain_m();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the relative elevation loss (since last trackpoint).
|
||||
*/
|
||||
Float getElevationLoss_m() {
|
||||
if (elevationSumManager == null || !elevationSumManager.isConnected()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return elevationSumManager.getElevationLoss_m();
|
||||
}
|
||||
|
||||
private void showNotification(boolean isGpsStarted) {
|
||||
if (isRecording()) {
|
||||
Intent intent = IntentUtils.newIntent(this, TrackRecordingActivity.class)
|
||||
|
||||
@@ -104,6 +104,11 @@ class TrackRecordingServiceBinder extends android.os.Binder implements TrackReco
|
||||
return trackRecordingService.getElevationGain_m();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getElevationLoss_m() {
|
||||
return trackRecordingService.getElevationLoss_m();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@Override
|
||||
public void setRemoteSensorManager(BluetoothRemoteSensorManager remoteSensorManager) {
|
||||
|
||||
@@ -78,6 +78,13 @@ public interface TrackRecordingServiceInterface {
|
||||
*/
|
||||
Float getElevationGain_m();
|
||||
|
||||
/**
|
||||
* Gets the current elevation loss.
|
||||
*
|
||||
* @return elevation loss in m or null.
|
||||
*/
|
||||
Float getElevationLoss_m();
|
||||
|
||||
@VisibleForTesting
|
||||
void setRemoteSensorManager(BluetoothRemoteSensorManager remoteSensorManager);
|
||||
|
||||
|
||||
@@ -112,6 +112,6 @@ public class ElevationSumManager implements SensorEventListener {
|
||||
|
||||
lastSeenSensorValue_hPa = value_hPa;
|
||||
|
||||
Log.v(TAG, "elevation gain: " + elevationGain_m);
|
||||
Log.v(TAG, "elevation gain: " + elevationGain_m + ", elevation loss: " + elevationLoss_m);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user