Cleanup: horizontal accuracy is now a Distance (and named consistently).

This commit is contained in:
Dennis Guse
2021-07-15 18:51:52 +02:00
parent 0f6480197b
commit db24639829
23 changed files with 127 additions and 116 deletions
@@ -49,7 +49,8 @@ public final class Marker {
private final Instant time;
private Double latitude;
private Double longitude;
private Float accuracy;
@Deprecated //Not needed
private Distance accuracy;
private Altitude altitude;
private Float bearing;
@@ -96,7 +97,7 @@ public final class Marker {
public void setTrackPoint(TrackPoint trackPoint) {
this.latitude = trackPoint.getLatitude();
this.longitude = trackPoint.getLongitude();
if (trackPoint.hasAccuracy()) this.accuracy = trackPoint.getAccuracy();
if (trackPoint.hasHorizontalAccuracy()) this.accuracy = trackPoint.getHorizontalAccuracy();
if (trackPoint.hasAltitude()) this.altitude = trackPoint.getAltitude();
if (trackPoint.hasBearing()) this.bearing = trackPoint.getBearing();
}
@@ -173,7 +174,7 @@ public final class Marker {
location.setBearing(bearing);
}
if (hasAccuracy()) {
location.setAccuracy(accuracy);
location.setAccuracy((float) accuracy.toM());
}
if (hasAltitude()) {
location.setAltitude(altitude.toM());
@@ -202,11 +203,11 @@ public final class Marker {
return accuracy != null;
}
public Float getAccuracy() {
public Distance getAccuracy() {
return accuracy;
}
public void setAccuracy(Float accuracy) {
public void setAccuracy(Distance accuracy) {
this.accuracy = accuracy;
}
@@ -53,7 +53,7 @@ public class TrackPoint {
private Double latitude;
private Double longitude;
private Float accuracy;
private Distance horizontalAccuracy;
private Altitude altitude;
private Speed speed;
private Float bearing;
@@ -112,7 +112,7 @@ public class TrackPoint {
this.longitude = location.getLongitude();
this.altitude = location.hasAltitude() ? Altitude.WGS84.of(location.getAltitude()) : null;
this.speed = location.hasSpeed() ? Speed.of(location.getSpeed()) : null;
this.accuracy = location.hasAccuracy() ? location.getAccuracy() : null;
this.horizontalAccuracy = location.hasAccuracy() ? Distance.of(location.getAccuracy()) : null;
//TODO Should we copy the bearing?
}
@@ -197,8 +197,8 @@ public class TrackPoint {
if (hasBearing()) {
location.setBearing(bearing);
}
if (hasAccuracy()) {
location.setAccuracy(accuracy);
if (hasHorizontalAccuracy()) {
location.setAccuracy((float) horizontalAccuracy.toM());
}
if (hasAltitude()) {
location.setAltitude(altitude.toM());
@@ -293,16 +293,16 @@ public class TrackPoint {
return this;
}
public boolean hasAccuracy() {
return accuracy != null;
public boolean hasHorizontalAccuracy() {
return horizontalAccuracy != null;
}
public float getAccuracy() {
return accuracy;
public Distance getHorizontalAccuracy() {
return horizontalAccuracy;
}
public TrackPoint setAccuracy(float horizontalAccuracy) {
this.accuracy = horizontalAccuracy;
public TrackPoint setHorizontalAccuracy(Distance horizontalAccuracy) {
this.horizontalAccuracy = horizontalAccuracy;
return this;
}
@@ -318,8 +318,8 @@ public class TrackPoint {
return Distance.of(getLocation().distanceTo(previous.getLocation()));
}
public boolean fulfillsAccuracy(int poorAccuracy) {
return hasAccuracy() && accuracy < poorAccuracy;
public boolean fulfillsAccuracy(Distance thresholdHorizontalAccuracy) {
return hasHorizontalAccuracy() && horizontalAccuracy.lessThan(thresholdHorizontalAccuracy);
}
//TODO Bearing requires a location; what do we do if we don't have any?
@@ -397,11 +397,11 @@ public class TrackPoint {
return result;
}
result += ": lat=" + getLatitude() + " lng=" + getLongitude();
if (!hasAccuracy()) {
if (!hasHorizontalAccuracy()) {
return result;
}
return result + " acc=" + getAccuracy();
return result + " acc=" + getHorizontalAccuracy();
}
public static class Id {
@@ -45,7 +45,7 @@ public interface TrackPointsColumns extends BaseColumns {
String TIME = "time";
String ALTITUDE = "elevation";
String ACCURACY = "accuracy";
String HORIZONTAL_ACCURACY = "accuracy";
String SPEED = "speed";
String BEARING = "bearing";
String SENSOR_HEARTRATE = "sensor_heartrate";
@@ -69,7 +69,7 @@ public interface TrackPointsColumns extends BaseColumns {
+ LATITUDE + " INTEGER, "
+ TIME + " INTEGER, "
+ ALTITUDE + " FLOAT, "
+ ACCURACY + " FLOAT, "
+ HORIZONTAL_ACCURACY + " FLOAT, "
+ SPEED + " FLOAT, "
+ BEARING + " FLOAT, "
+ SENSOR_HEARTRATE + " FLOAT, "