TrackPoint: only take data from location if present.

This functionality is used by KML/KMZ imports.
This commit is contained in:
Dennis Guse
2021-06-27 09:32:13 +02:00
parent 5c72855ec5
commit 5045b9a222
@@ -111,25 +111,23 @@ public class TrackPoint {
} }
public TrackPoint(@NonNull Type type, @NonNull Location location, @NonNull Instant time) { public TrackPoint(@NonNull Type type, @NonNull Location location, @NonNull Instant time) {
this(type); this(type, time);
this.latitude = location.getLatitude(); this.latitude = location.getLatitude();
this.longitude = location.getLongitude(); this.longitude = location.getLongitude();
this.altitude = Altitude.WGS84.of(location.getAltitude()); this.altitude = location.hasAltitude() ? Altitude.WGS84.of(location.getAltitude()) : null;
this.speed = Speed.of(location.getSpeed()); this.speed = location.hasSpeed() ? Speed.of(location.getSpeed()) : null;
this.accuracy = location.getAccuracy(); this.accuracy = location.hasAccuracy() ? location.getAccuracy() : null;
//TODO Should we copy the bearing? //TODO Should we copy the bearing?
setTime(time);
} }
@VisibleForTesting
public TrackPoint(double latitude, double longitude, Altitude altitude, Instant time) { public TrackPoint(double latitude, double longitude, Altitude altitude, Instant time) {
this(Type.TRACKPOINT); this(Type.TRACKPOINT, time);
this.latitude = latitude; this.latitude = latitude;
this.longitude = longitude; this.longitude = longitude;
this.altitude = altitude; this.altitude = altitude;
this.time = time;
} }
@Deprecated //See #316 @Deprecated //See #316