Store sensor data without distance.

Fixes #1088.
This commit is contained in:
Dennis Guse
2022-07-10 18:46:19 +02:00
parent 386f017fb7
commit 5667d2d83e
4 changed files with 87 additions and 30 deletions
@@ -56,7 +56,7 @@ public class TrackPoint {
SEGMENT_START_AUTOMATIC(-1), //Start of a segment due to too much distance from previous TrackPoint
TRACKPOINT(0), //Just GPS data and may contain BLE sensor data
SENSORPOINT(2), //Just BLE sensor data; required to have speed and sensorDistance
SENSORPOINT(2), //Just BLE sensor data; may have speed and sensorDistance
SEGMENT_END_MANUAL(1); //End of a segment
@@ -10,6 +10,7 @@ import android.util.Pair;
import androidx.annotation.NonNull;
import java.time.Duration;
import java.time.ZoneOffset;
import de.dennisguse.opentracks.R;
@@ -180,8 +181,16 @@ class TrackRecordingManager implements SharedPreferences.OnSharedPreferenceChang
}
if (!trackPoint.hasLocation() && !trackPoint.hasSensorDistance()) {
Log.d(TAG, "Ignoring TrackPoint as it has no distance.");
return false;
Duration minStorageInterval = Duration.ofSeconds(10); // TODO Should be configurable.
boolean shouldStore = lastStoredTrackPoint.getTime().plus(minStorageInterval)
.isBefore(trackPoint.getTime());
if (!shouldStore) {
Log.d(TAG, "Ignoring TrackPoint as it has no distance (and sensor data is not new enough).");
return false;
} else {
insertTrackPoint(trackPoint, true);
return true;
}
}
Distance distanceToLastStoredTrackPoint;