forked from upstream-mirrors/OpenTracks
Bugfix: GPS-based data in UI should not drop back to zero.
Likely introduced b9ed5e28e0.
This commit is contained in:
@@ -21,7 +21,6 @@ import android.os.Parcelable;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -93,7 +92,6 @@ public class TrackPoint {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Refactor constructors
|
|
||||||
public TrackPoint(@NonNull Type type, @NonNull Instant time) {
|
public TrackPoint(@NonNull Type type, @NonNull Instant time) {
|
||||||
this(null, type, Position.of(time));
|
this(null, type, Position.of(time));
|
||||||
}
|
}
|
||||||
@@ -218,13 +216,6 @@ public class TrackPoint {
|
|||||||
return position.altitude();
|
return position.altitude();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@VisibleForTesting
|
|
||||||
public TrackPoint setAltitude(double altitude_m) {
|
|
||||||
setAltitude(Altitude.WGS84.of(altitude_m));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TrackPoint setAltitude(Altitude altitude) {
|
public TrackPoint setAltitude(Altitude altitude) {
|
||||||
position = position.with(altitude);
|
position = position.with(altitude);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class AggregatorGPS extends Aggregator<Position, Position> {
|
|||||||
* TODO: this behavior can be changed if TrackRecordingManager.insertTrackPoint() would strip GPS data if it was already saved. This would simplify TrackPointCreator.createCurrentTrackPoint()
|
* TODO: this behavior can be changed if TrackRecordingManager.insertTrackPoint() would strip GPS data if it was already saved. This would simplify TrackPointCreator.createCurrentTrackPoint()
|
||||||
*/
|
*/
|
||||||
aggregatedValue = Position.empty();
|
aggregatedValue = Position.empty();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|||||||
@@ -107,7 +107,9 @@ public class TrackPointCreator implements SharedPreferences.OnSharedPreferenceCh
|
|||||||
public Pair<TrackPoint, SensorDataSet> createCurrentTrackPoint(@Nullable TrackPoint lastTrackPointUISpeed, @Nullable TrackPoint lastTrackPointUIAltitude, @Nullable TrackPoint lastStoredTrackPointWithLocation) {
|
public Pair<TrackPoint, SensorDataSet> createCurrentTrackPoint(@Nullable TrackPoint lastTrackPointUISpeed, @Nullable TrackPoint lastTrackPointUIAltitude, @Nullable TrackPoint lastStoredTrackPointWithLocation) {
|
||||||
TrackPoint currentTrackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, createNow());
|
TrackPoint currentTrackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, createNow());
|
||||||
|
|
||||||
if (lastStoredTrackPointWithLocation != null && lastStoredTrackPointWithLocation.hasLocation()) {
|
SensorDataSet sensorDataSet = addSensorData(currentTrackPoint);
|
||||||
|
|
||||||
|
if (!currentTrackPoint.hasLocation() && lastStoredTrackPointWithLocation != null && lastStoredTrackPointWithLocation.hasLocation()) {
|
||||||
//We are taking the coordinates from the last stored TrackPoint, so the distance is monotonously increasing.
|
//We are taking the coordinates from the last stored TrackPoint, so the distance is monotonously increasing.
|
||||||
currentTrackPoint.setPosition(lastStoredTrackPointWithLocation.getPosition());
|
currentTrackPoint.setPosition(lastStoredTrackPointWithLocation.getPosition());
|
||||||
}
|
}
|
||||||
@@ -120,8 +122,6 @@ public class TrackPointCreator implements SharedPreferences.OnSharedPreferenceCh
|
|||||||
currentTrackPoint.setAltitude(lastTrackPointUIAltitude.getAltitude());
|
currentTrackPoint.setAltitude(lastTrackPointUIAltitude.getAltitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
SensorDataSet sensorDataSet = addSensorData(currentTrackPoint);
|
|
||||||
|
|
||||||
return new Pair<>(currentTrackPoint, sensorDataSet);
|
return new Pair<>(currentTrackPoint, sensorDataSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user