forked from upstream-mirrors/OpenTracks
Cleanup: horizontal accuracy is now a Distance (and named consistently).
This commit is contained in:
@@ -115,7 +115,7 @@ public class TestDataUtil {
|
|||||||
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochSecond(i + 1));
|
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochSecond(i + 1));
|
||||||
trackPoint.setLatitude(INITIAL_LATITUDE + (double) i / 10000.0);
|
trackPoint.setLatitude(INITIAL_LATITUDE + (double) i / 10000.0);
|
||||||
trackPoint.setLongitude(INITIAL_LONGITUDE - (double) i / 10000.0);
|
trackPoint.setLongitude(INITIAL_LONGITUDE - (double) i / 10000.0);
|
||||||
trackPoint.setAccuracy((float) i / 100.0f);
|
trackPoint.setHorizontalAccuracy(Distance.of(i / 100.0f));
|
||||||
trackPoint.setAltitude(i * ALTITUDE_INTERVAL);
|
trackPoint.setAltitude(i * ALTITUDE_INTERVAL);
|
||||||
trackPoint.setSpeed(Speed.of(5f + (i / 10f)));
|
trackPoint.setSpeed(Speed.of(5f + (i / 10f)));
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class TestSensorDataUtil {
|
|||||||
tp.setHeartRate_bpm(hr);
|
tp.setHeartRate_bpm(hr);
|
||||||
tp.setCyclingCadence_rpm(cadence);
|
tp.setCyclingCadence_rpm(cadence);
|
||||||
tp.setPower(power);
|
tp.setPower(power);
|
||||||
tp.setAccuracy(1f);
|
tp.setHorizontalAccuracy(Distance.of(1f));
|
||||||
tp.setAltitude(1f);
|
tp.setAltitude(1f);
|
||||||
tp.setSpeed(Speed.of(5f + (i / 10f)));
|
tp.setSpeed(Speed.of(5f + (i / 10f)));
|
||||||
tp.setAltitudeGain(3f);
|
tp.setAltitudeGain(3f);
|
||||||
|
|||||||
+1
-1
@@ -138,7 +138,7 @@ public class CustomContentProviderUtilsTest {
|
|||||||
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochMilli(i))
|
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochMilli(i))
|
||||||
.setLatitude(37.0 + (double) i / 10000.0)
|
.setLatitude(37.0 + (double) i / 10000.0)
|
||||||
.setLongitude(57.0 - (double) i / 10000.0)
|
.setLongitude(57.0 - (double) i / 10000.0)
|
||||||
.setAccuracy((float) i / 100.0f)
|
.setHorizontalAccuracy(Distance.of(i / 100.0f))
|
||||||
.setAltitude(i * 2.5);
|
.setAltitude(i * 2.5);
|
||||||
trackPoints.add(trackPoint);
|
trackPoints.add(trackPoint);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package de.dennisguse.opentracks.fragments;
|
|||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.content.data.Distance;
|
||||||
import de.dennisguse.opentracks.content.data.Speed;
|
import de.dennisguse.opentracks.content.data.Speed;
|
||||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ public class TrackStubUtils {
|
|||||||
public static final long INITIAL_TIME = 1000L;
|
public static final long INITIAL_TIME = 1000L;
|
||||||
private static final double INITIAL_LATITUDE = 22;
|
private static final double INITIAL_LATITUDE = 22;
|
||||||
private static final double INITIAL_LONGITUDE = 22;
|
private static final double INITIAL_LONGITUDE = 22;
|
||||||
private static final float INITIAL_ACCURACY = 5;
|
private static final Distance INITIAL_ACCURACY = Distance.of(5);
|
||||||
private static final Speed INITIAL_SPEED = Speed.of(10);
|
private static final Speed INITIAL_SPEED = Speed.of(10);
|
||||||
private static final float INITIAL_BEARING = 3.0f;
|
private static final float INITIAL_BEARING = 3.0f;
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ public class TrackStubUtils {
|
|||||||
.setLatitude(latitude)
|
.setLatitude(latitude)
|
||||||
.setLongitude(longitude)
|
.setLongitude(longitude)
|
||||||
.setAltitude(altitude)
|
.setAltitude(altitude)
|
||||||
.setAccuracy(INITIAL_ACCURACY)
|
.setHorizontalAccuracy(INITIAL_ACCURACY)
|
||||||
.setSpeed(INITIAL_SPEED)
|
.setSpeed(INITIAL_SPEED)
|
||||||
.setBearing(INITIAL_BEARING);
|
.setBearing(INITIAL_BEARING);
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -119,10 +119,10 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
Distance sensorDistance = hasSensorDistance ? Distance.of(5) : null;
|
Distance sensorDistance = hasSensorDistance ? Distance.of(5) : null;
|
||||||
|
|
||||||
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:03Z"), 3, 14, 10, 15, 10, 1, 66, 3, 50, sensorDistance), 0);
|
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:03Z"), 3, 14, 10, 15, 10, 1, 66, 3, 50, sensorDistance), Distance.of(0));
|
||||||
service.insertMarker("Marker 1", "Marker 1 category", "Marker 1 desc", null);
|
service.insertMarker("Marker 1", "Marker 1 category", "Marker 1 desc", null);
|
||||||
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:04Z"), 3, 14.001, 10, 15, 10, 0, 66, 3, 50, sensorDistance), 0);
|
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:04Z"), 3, 14.001, 10, 15, 10, 0, 66, 3, 50, sensorDistance), Distance.of(0));
|
||||||
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:05Z"), 3, 14.002, 10, 15, 10, 0, 66, 3, 50, sensorDistance), 0);
|
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:05Z"), 3, 14.002, 10, 15, 10, 0, 66, 3, 50, sensorDistance), Distance.of(0));
|
||||||
service.insertMarker("Marker 2", "Marker 2 category", "Marker 2 desc", null);
|
service.insertMarker("Marker 2", "Marker 2 category", "Marker 2 desc", null);
|
||||||
|
|
||||||
handlerServer.setClock(Clock.fixed(Instant.parse("2020-02-02T02:02:06Z"), ZoneId.of("CET")));
|
handlerServer.setClock(Clock.fixed(Instant.parse("2020-02-02T02:02:06Z"), ZoneId.of("CET")));
|
||||||
@@ -131,9 +131,9 @@ public class ExportImportTest {
|
|||||||
handlerServer.setClock(Clock.fixed(Instant.parse("2020-02-02T02:02:20Z"), ZoneId.of("CET")));
|
handlerServer.setClock(Clock.fixed(Instant.parse("2020-02-02T02:02:20Z"), ZoneId.of("CET")));
|
||||||
service.resumeCurrentTrack();
|
service.resumeCurrentTrack();
|
||||||
|
|
||||||
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:21Z"), 3, 14.003, 10, 15, 10, 0, 66, 3, 50, sensorDistance), 0);
|
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:21Z"), 3, 14.003, 10, 15, 10, 0, 66, 3, 50, sensorDistance), Distance.of(0));
|
||||||
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:22Z"), 3, 16, 10, 15, 10, 0, 66, 3, 50, sensorDistance), 0);
|
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:22Z"), 3, 16, 10, 15, 10, 0, 66, 3, 50, sensorDistance), Distance.of(0));
|
||||||
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:23Z"), 3, 16.001, 10, 15, 10, 0, 66, 3, 50, sensorDistance), 0);
|
service.newTrackPoint(createTrackPoint(Instant.parse("2020-02-02T02:02:23Z"), 3, 16.001, 10, 15, 10, 0, 66, 3, 50, sensorDistance), Distance.of(0));
|
||||||
|
|
||||||
handlerServer.setClock(Clock.fixed(Instant.parse("2020-02-02T02:02:24Z"), ZoneId.of("CET")));
|
handlerServer.setClock(Clock.fixed(Instant.parse("2020-02-02T02:02:24Z"), ZoneId.of("CET")));
|
||||||
service.endCurrentTrack();
|
service.endCurrentTrack();
|
||||||
@@ -408,7 +408,7 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
private static TrackPoint createTrackPoint(Instant time, double latitude, double longitude, float accuracy, float speed, float altitude, float altitudeGain, float heartRate, float cyclingCadence, float power, Distance distance) {
|
private static TrackPoint createTrackPoint(Instant time, double latitude, double longitude, float accuracy, float speed, float altitude, float altitudeGain, float heartRate, float cyclingCadence, float power, Distance distance) {
|
||||||
TrackPoint tp = new TrackPoint(latitude, longitude, Altitude.WGS84.of(altitude), time);
|
TrackPoint tp = new TrackPoint(latitude, longitude, Altitude.WGS84.of(altitude), time);
|
||||||
tp.setAccuracy(accuracy);
|
tp.setHorizontalAccuracy(Distance.of(accuracy));
|
||||||
tp.setSpeed(Speed.of(speed));
|
tp.setSpeed(Speed.of(speed));
|
||||||
tp.setHeartRate_bpm(heartRate);
|
tp.setHeartRate_bpm(heartRate);
|
||||||
tp.setCyclingCadence_rpm(cyclingCadence);
|
tp.setCyclingCadence_rpm(cyclingCadence);
|
||||||
|
|||||||
+4
-4
@@ -50,12 +50,12 @@ public class TrackPointAssert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (assertAccuracy) {
|
if (assertAccuracy) {
|
||||||
Assert.assertEquals(expected.hasAccuracy(), actual.hasAccuracy());
|
Assert.assertEquals(expected.hasHorizontalAccuracy(), actual.hasHorizontalAccuracy());
|
||||||
if (expected.hasAccuracy()) {
|
if (expected.hasHorizontalAccuracy()) {
|
||||||
Assert.assertEquals(expected.getAccuracy(), actual.getAccuracy(), delta);
|
Assert.assertEquals(expected.getHorizontalAccuracy().toM(), actual.getHorizontalAccuracy().toM(), delta);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Assert.assertFalse(actual.hasAccuracy());
|
Assert.assertFalse(actual.hasHorizontalAccuracy());
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals(expected.hasSensorDistance(), actual.hasSensorDistance());
|
Assert.assertEquals(expected.hasSensorDistance(), actual.hasSensorDistance());
|
||||||
|
|||||||
+8
-7
@@ -40,20 +40,21 @@ public class TrackRecordingServiceNotificationManagerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateLocation_triggersAlertOnlyOnFirstInaccurateLocation() {
|
public void updateLocation_triggersAlertOnlyOnFirstInaccurateLocation() {
|
||||||
when(trackPointMock.hasAccuracy()).thenReturn(true);
|
when(trackPointMock.hasHorizontalAccuracy()).thenReturn(true);
|
||||||
when(trackPointMock.getAccuracy()).thenReturn(999f);
|
when(trackPointMock.getHorizontalAccuracy()).thenReturn(Distance.of(999f));
|
||||||
when(trackPointMock.getSpeed()).thenReturn(Speed.of(0));
|
when(trackPointMock.getSpeed()).thenReturn(Speed.of(0));
|
||||||
when(trackStatisticsMock.getTotalDistance()).thenReturn(Distance.of(0));
|
when(trackStatisticsMock.getTotalDistance()).thenReturn(Distance.of(0));
|
||||||
when(notificationCompatBuilder.setOnlyAlertOnce(anyBoolean())).thenReturn(notificationCompatBuilder);
|
when(notificationCompatBuilder.setOnlyAlertOnce(anyBoolean()))
|
||||||
|
.thenReturn(notificationCompatBuilder);
|
||||||
|
|
||||||
TrackRecordingServiceNotificationManager subject = new TrackRecordingServiceNotificationManager(notificationManager, notificationCompatBuilder);
|
TrackRecordingServiceNotificationManager subject = new TrackRecordingServiceNotificationManager(notificationManager, notificationCompatBuilder);
|
||||||
subject.setMetricUnits(true);
|
subject.setMetricUnits(true);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
subject.updateTrackPoint(context, trackStatisticsMock, trackPointMock, 100);
|
subject.updateTrackPoint(context, trackStatisticsMock, trackPointMock, Distance.of(100));
|
||||||
subject.updateTrackPoint(context, trackStatisticsMock, trackPointMock, 100);
|
subject.updateTrackPoint(context, trackStatisticsMock, trackPointMock, Distance.of(100));
|
||||||
subject.updateTrackPoint(context, trackStatisticsMock, trackPointMock, 1000);
|
subject.updateTrackPoint(context, trackStatisticsMock, trackPointMock, Distance.of(1000));
|
||||||
subject.updateTrackPoint(context, trackStatisticsMock, trackPointMock, 100);
|
subject.updateTrackPoint(context, trackStatisticsMock, trackPointMock, Distance.of(100));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verify(notificationCompatBuilder, times(6)).setOnlyAlertOnce(true);
|
verify(notificationCompatBuilder, times(6)).setOnlyAlertOnce(true);
|
||||||
|
|||||||
+6
-5
@@ -47,6 +47,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
|
import de.dennisguse.opentracks.content.data.Distance;
|
||||||
import de.dennisguse.opentracks.content.data.Marker;
|
import de.dennisguse.opentracks.content.data.Marker;
|
||||||
import de.dennisguse.opentracks.content.data.Speed;
|
import de.dennisguse.opentracks.content.data.Speed;
|
||||||
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
||||||
@@ -296,7 +297,7 @@ public class TrackRecordingServiceTest {
|
|||||||
handlerServer.stopGPS();
|
handlerServer.stopGPS();
|
||||||
handlerServer.setAltitudeSumManager(altitudeSumManager);
|
handlerServer.setAltitudeSumManager(altitudeSumManager);
|
||||||
|
|
||||||
handlerServer.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:02:05Z")), 50);
|
handlerServer.onNewTrackPoint(new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:02:05Z")), Distance.of(50));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertTrue(service.isRecording());
|
assertTrue(service.isRecording());
|
||||||
@@ -415,7 +416,7 @@ public class TrackRecordingServiceTest {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:02:03Z"))
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-02-02T02:02:03Z"))
|
||||||
.setLatitude(10)
|
.setLatitude(10)
|
||||||
.setLongitude(10)
|
.setLongitude(10)
|
||||||
, 50);
|
, Distance.of(50));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Marker.Id markerId = service.insertMarker(null, null, null, null);
|
Marker.Id markerId = service.insertMarker(null, null, null, null);
|
||||||
@@ -458,14 +459,14 @@ public class TrackRecordingServiceTest {
|
|||||||
/**
|
/**
|
||||||
* Inserts a location and waits for 200ms.
|
* Inserts a location and waits for 200ms.
|
||||||
*/
|
*/
|
||||||
private static void newTrackPoint(TrackRecordingService trackRecordingService, double latitude, double longitude, float accuracy, long speed, long time) throws InterruptedException {
|
private static void newTrackPoint(TrackRecordingService trackRecordingService, double latitude, double longitude, float accuracy, long speed, long time) {
|
||||||
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochMilli(time))
|
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochMilli(time))
|
||||||
.setLongitude(longitude)
|
.setLongitude(longitude)
|
||||||
.setLatitude(latitude)
|
.setLatitude(latitude)
|
||||||
.setAccuracy(accuracy)
|
.setHorizontalAccuracy(Distance.of(accuracy))
|
||||||
.setSpeed(Speed.of(speed))
|
.setSpeed(Speed.of(speed))
|
||||||
.setBearing(3.0f);
|
.setBearing(3.0f);
|
||||||
|
|
||||||
trackRecordingService.getHandlerServer().onNewTrackPoint(trackPoint, 50);
|
trackRecordingService.getHandlerServer().onNewTrackPoint(trackPoint, Distance.of(50));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-26
@@ -24,6 +24,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.content.data.Distance;
|
||||||
import de.dennisguse.opentracks.content.data.Speed;
|
import de.dennisguse.opentracks.content.data.Speed;
|
||||||
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
||||||
import de.dennisguse.opentracks.content.data.Track;
|
import de.dennisguse.opentracks.content.data.Track;
|
||||||
@@ -132,42 +133,42 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(1)
|
.setHorizontalAccuracy(Distance.of(1))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45.0001)
|
.setLatitude(45.0001)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(2)
|
.setHorizontalAccuracy(Distance.of(2))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45.0001)
|
.setLatitude(45.0001)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(3)
|
.setHorizontalAccuracy(Distance.of(3))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45.0002)
|
.setLatitude(45.0002)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(4)
|
.setHorizontalAccuracy(Distance.of(4))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45.0003)
|
.setLatitude(45.0003)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(5)
|
.setHorizontalAccuracy(Distance.of(5))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45.0004)
|
.setLatitude(45.0004)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(6)
|
.setHorizontalAccuracy(Distance.of(6))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
@@ -205,14 +206,14 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(1)
|
.setHorizontalAccuracy(Distance.of(1))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45.0005)
|
.setLatitude(45.0005)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(6)
|
.setHorizontalAccuracy(Distance.of(6))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
@@ -250,21 +251,21 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(1)
|
.setHorizontalAccuracy(Distance.of(1))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null) //TODO Why is this added? Systems is idle and not moving at all.
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null) //TODO Why is this added? Systems is idle and not moving at all.
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(2)
|
.setHorizontalAccuracy(Distance.of(2))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(6)
|
.setHorizontalAccuracy(Distance.of(6))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
@@ -303,28 +304,28 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(1)
|
.setHorizontalAccuracy(Distance.of(1))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null) //TODO Check why this trackPoint is inserted.
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null) //TODO Check why this trackPoint is inserted.
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(2)
|
.setHorizontalAccuracy(Distance.of(2))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null) //TODO Check why this trackPoint is inserted.
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null) //TODO Check why this trackPoint is inserted.
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(5)
|
.setHorizontalAccuracy(Distance.of(5))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(6)
|
.setHorizontalAccuracy(Distance.of(6))
|
||||||
.setSpeed(Speed.of(15))
|
.setSpeed(Speed.of(15))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
@@ -377,7 +378,7 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(1)
|
.setHorizontalAccuracy(Distance.of(1))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f)
|
.setAltitudeLoss(0f)
|
||||||
@@ -385,7 +386,7 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(2)
|
.setHorizontalAccuracy(Distance.of(2))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f)
|
.setAltitudeLoss(0f)
|
||||||
@@ -393,7 +394,7 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(3)
|
.setHorizontalAccuracy(Distance.of(3))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f)
|
.setAltitudeLoss(0f)
|
||||||
@@ -401,7 +402,7 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(4)
|
.setHorizontalAccuracy(Distance.of(4))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f)
|
.setAltitudeLoss(0f)
|
||||||
@@ -409,7 +410,7 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(5)
|
.setHorizontalAccuracy(Distance.of(5))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f)
|
.setAltitudeLoss(0f)
|
||||||
@@ -417,7 +418,7 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(6)
|
.setHorizontalAccuracy(Distance.of(6))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f)
|
.setAltitudeLoss(0f)
|
||||||
@@ -457,7 +458,7 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45)
|
.setLatitude(45)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(1)
|
.setHorizontalAccuracy(Distance.of(1))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
@@ -465,14 +466,14 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC, null)
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC, null)
|
||||||
.setLatitude(45.1)
|
.setLatitude(45.1)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(2)
|
.setHorizontalAccuracy(Distance.of(2))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45.1)
|
.setLatitude(45.1)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(3)
|
.setHorizontalAccuracy(Distance.of(3))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
@@ -480,14 +481,14 @@ public class TrackRecordingServiceTestLocation {
|
|||||||
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC, null)
|
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC, null)
|
||||||
.setLatitude(45.2)
|
.setLatitude(45.2)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(4)
|
.setHorizontalAccuracy(Distance.of(4))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
new TrackPoint(TrackPoint.Type.TRACKPOINT, null)
|
||||||
.setLatitude(45.2)
|
.setLatitude(45.2)
|
||||||
.setLongitude(35)
|
.setLongitude(35)
|
||||||
.setAccuracy(5)
|
.setHorizontalAccuracy(Distance.of(5))
|
||||||
.setSpeed(Speed.of(0))
|
.setSpeed(Speed.of(0))
|
||||||
.setAltitudeGain(0f)
|
.setAltitudeGain(0f)
|
||||||
.setAltitudeLoss(0f),
|
.setAltitudeLoss(0f),
|
||||||
|
|||||||
+3
-2
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
|
import de.dennisguse.opentracks.content.data.Distance;
|
||||||
import de.dennisguse.opentracks.content.data.Speed;
|
import de.dennisguse.opentracks.content.data.Speed;
|
||||||
import de.dennisguse.opentracks.content.data.Track;
|
import de.dennisguse.opentracks.content.data.Track;
|
||||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||||
@@ -238,11 +239,11 @@ public class TrackRecordingServiceTestLooper {
|
|||||||
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, service.getHandlerServer().createNow())
|
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, service.getHandlerServer().createNow())
|
||||||
.setLongitude(35.0f + i / 10.0f)
|
.setLongitude(35.0f + i / 10.0f)
|
||||||
.setLatitude(45.0f - i / 5.0f)
|
.setLatitude(45.0f - i / 5.0f)
|
||||||
.setAccuracy(5)
|
.setHorizontalAccuracy(Distance.of(5))
|
||||||
.setSpeed(Speed.of(10))
|
.setSpeed(Speed.of(10))
|
||||||
.setBearing(3.0f);
|
.setBearing(3.0f);
|
||||||
|
|
||||||
int prefAccuracy = PreferencesUtils.getRecordingGPSAccuracy(sharedPreferences, context);
|
Distance prefAccuracy = PreferencesUtils.getThresholdHorizontalAccuracy(sharedPreferences, context);
|
||||||
service.getHandlerServer().onNewTrackPoint(trackPoint, prefAccuracy);
|
service.getHandlerServer().onNewTrackPoint(trackPoint, prefAccuracy);
|
||||||
|
|
||||||
if (i % 7 == 0) {
|
if (i % 7 == 0) {
|
||||||
|
|||||||
+4
-3
@@ -11,6 +11,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.content.data.Distance;
|
||||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||||
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -48,13 +49,13 @@ public class HandlerServerTest {
|
|||||||
public void sendTrackPoint() throws InterruptedException {
|
public void sendTrackPoint() throws InterruptedException {
|
||||||
// given
|
// given
|
||||||
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, null);
|
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, null);
|
||||||
int accuracy = 50;
|
Distance horizontalAccuracyThreshold = Distance.of(50);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
subject.onNewTrackPoint(trackPoint, accuracy);
|
subject.onNewTrackPoint(trackPoint, horizontalAccuracyThreshold);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
Thread.sleep(10); // Wait for executor service
|
Thread.sleep(10); // Wait for executor service
|
||||||
verify(server).newTrackPoint(trackPoint, accuracy);
|
verify(server).newTrackPoint(trackPoint, horizontalAccuracyThreshold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-6
@@ -18,6 +18,7 @@ import org.mockito.junit.MockitoJUnitRunner;
|
|||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.content.data.Distance;
|
||||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ public class LocationHandlerTest {
|
|||||||
locationHandler.onLocationChanged(createLocation(45f, 35f, 3, 5, System.currentTimeMillis()));
|
locationHandler.onLocationChanged(createLocation(45f, 35f, 3, 5, System.currentTimeMillis()));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verify(handlerServer, times(1)).onNewTrackPoint(any(TrackPoint.class), any(Integer.class));
|
verify(handlerServer, times(1)).onNewTrackPoint(any(TrackPoint.class), any(Distance.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +83,7 @@ public class LocationHandlerTest {
|
|||||||
locationHandler.onLocationChanged(createLocation(latitude, 35f, 3, 5, System.currentTimeMillis()));
|
locationHandler.onLocationChanged(createLocation(latitude, 35f, 3, 5, System.currentTimeMillis()));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verify(handlerServer, times(0)).onNewTrackPoint(any(TrackPoint.class), any(Integer.class));
|
verify(handlerServer, times(0)).onNewTrackPoint(any(TrackPoint.class), any(Distance.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,14 +92,14 @@ public class LocationHandlerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testOnLocationChanged_poorAccuracy() {
|
public void testOnLocationChanged_poorAccuracy() {
|
||||||
// given
|
// given
|
||||||
int prefAccuracy = PreferencesUtils.getRecordingGPSAccuracy(sharedPreferences, context);
|
Distance prefAccuracy = PreferencesUtils.getThresholdHorizontalAccuracy(sharedPreferences, context);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
locationHandler.onLocationChanged(createLocation(45f, 35f, prefAccuracy + 1, 5, System.currentTimeMillis()));
|
locationHandler.onLocationChanged(createLocation(45f, 35f, (float) (prefAccuracy.toM() + 1), 5, System.currentTimeMillis()));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
// no newTrackPoint called
|
// no newTrackPoint called
|
||||||
verify(handlerServer, times(0)).onNewTrackPoint(any(TrackPoint.class), any(Integer.class));
|
verify(handlerServer, times(0)).onNewTrackPoint(any(TrackPoint.class), any(Distance.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -111,7 +112,7 @@ public class LocationHandlerTest {
|
|||||||
locationHandler.onLocationChanged(createLocation(99.0, 35.0, Long.MAX_VALUE, 15, System.currentTimeMillis()));
|
locationHandler.onLocationChanged(createLocation(99.0, 35.0, Long.MAX_VALUE, 15, System.currentTimeMillis()));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
verify(handlerServer, times(1)).onNewTrackPoint(any(TrackPoint.class), any(Integer.class));
|
verify(handlerServer, times(1)).onNewTrackPoint(any(TrackPoint.class), any(Distance.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ public final class Marker {
|
|||||||
private final Instant time;
|
private final Instant time;
|
||||||
private Double latitude;
|
private Double latitude;
|
||||||
private Double longitude;
|
private Double longitude;
|
||||||
private Float accuracy;
|
@Deprecated //Not needed
|
||||||
|
private Distance accuracy;
|
||||||
private Altitude altitude;
|
private Altitude altitude;
|
||||||
private Float bearing;
|
private Float bearing;
|
||||||
|
|
||||||
@@ -96,7 +97,7 @@ public final class Marker {
|
|||||||
public void setTrackPoint(TrackPoint trackPoint) {
|
public void setTrackPoint(TrackPoint trackPoint) {
|
||||||
this.latitude = trackPoint.getLatitude();
|
this.latitude = trackPoint.getLatitude();
|
||||||
this.longitude = trackPoint.getLongitude();
|
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.hasAltitude()) this.altitude = trackPoint.getAltitude();
|
||||||
if (trackPoint.hasBearing()) this.bearing = trackPoint.getBearing();
|
if (trackPoint.hasBearing()) this.bearing = trackPoint.getBearing();
|
||||||
}
|
}
|
||||||
@@ -173,7 +174,7 @@ public final class Marker {
|
|||||||
location.setBearing(bearing);
|
location.setBearing(bearing);
|
||||||
}
|
}
|
||||||
if (hasAccuracy()) {
|
if (hasAccuracy()) {
|
||||||
location.setAccuracy(accuracy);
|
location.setAccuracy((float) accuracy.toM());
|
||||||
}
|
}
|
||||||
if (hasAltitude()) {
|
if (hasAltitude()) {
|
||||||
location.setAltitude(altitude.toM());
|
location.setAltitude(altitude.toM());
|
||||||
@@ -202,11 +203,11 @@ public final class Marker {
|
|||||||
return accuracy != null;
|
return accuracy != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getAccuracy() {
|
public Distance getAccuracy() {
|
||||||
return accuracy;
|
return accuracy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccuracy(Float accuracy) {
|
public void setAccuracy(Distance accuracy) {
|
||||||
this.accuracy = accuracy;
|
this.accuracy = accuracy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class TrackPoint {
|
|||||||
|
|
||||||
private Double latitude;
|
private Double latitude;
|
||||||
private Double longitude;
|
private Double longitude;
|
||||||
private Float accuracy;
|
private Distance horizontalAccuracy;
|
||||||
private Altitude altitude;
|
private Altitude altitude;
|
||||||
private Speed speed;
|
private Speed speed;
|
||||||
private Float bearing;
|
private Float bearing;
|
||||||
@@ -112,7 +112,7 @@ public class TrackPoint {
|
|||||||
this.longitude = location.getLongitude();
|
this.longitude = location.getLongitude();
|
||||||
this.altitude = location.hasAltitude() ? Altitude.WGS84.of(location.getAltitude()) : null;
|
this.altitude = location.hasAltitude() ? Altitude.WGS84.of(location.getAltitude()) : null;
|
||||||
this.speed = location.hasSpeed() ? Speed.of(location.getSpeed()) : 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?
|
//TODO Should we copy the bearing?
|
||||||
}
|
}
|
||||||
@@ -197,8 +197,8 @@ public class TrackPoint {
|
|||||||
if (hasBearing()) {
|
if (hasBearing()) {
|
||||||
location.setBearing(bearing);
|
location.setBearing(bearing);
|
||||||
}
|
}
|
||||||
if (hasAccuracy()) {
|
if (hasHorizontalAccuracy()) {
|
||||||
location.setAccuracy(accuracy);
|
location.setAccuracy((float) horizontalAccuracy.toM());
|
||||||
}
|
}
|
||||||
if (hasAltitude()) {
|
if (hasAltitude()) {
|
||||||
location.setAltitude(altitude.toM());
|
location.setAltitude(altitude.toM());
|
||||||
@@ -293,16 +293,16 @@ public class TrackPoint {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAccuracy() {
|
public boolean hasHorizontalAccuracy() {
|
||||||
return accuracy != null;
|
return horizontalAccuracy != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAccuracy() {
|
public Distance getHorizontalAccuracy() {
|
||||||
return accuracy;
|
return horizontalAccuracy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TrackPoint setAccuracy(float horizontalAccuracy) {
|
public TrackPoint setHorizontalAccuracy(Distance horizontalAccuracy) {
|
||||||
this.accuracy = horizontalAccuracy;
|
this.horizontalAccuracy = horizontalAccuracy;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,8 +318,8 @@ public class TrackPoint {
|
|||||||
return Distance.of(getLocation().distanceTo(previous.getLocation()));
|
return Distance.of(getLocation().distanceTo(previous.getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean fulfillsAccuracy(int poorAccuracy) {
|
public boolean fulfillsAccuracy(Distance thresholdHorizontalAccuracy) {
|
||||||
return hasAccuracy() && accuracy < poorAccuracy;
|
return hasHorizontalAccuracy() && horizontalAccuracy.lessThan(thresholdHorizontalAccuracy);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Bearing requires a location; what do we do if we don't have any?
|
//TODO Bearing requires a location; what do we do if we don't have any?
|
||||||
@@ -397,11 +397,11 @@ public class TrackPoint {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result += ": lat=" + getLatitude() + " lng=" + getLongitude();
|
result += ": lat=" + getLatitude() + " lng=" + getLongitude();
|
||||||
if (!hasAccuracy()) {
|
if (!hasHorizontalAccuracy()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result + " acc=" + getAccuracy();
|
return result + " acc=" + getHorizontalAccuracy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Id {
|
public static class Id {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public interface TrackPointsColumns extends BaseColumns {
|
|||||||
|
|
||||||
String TIME = "time";
|
String TIME = "time";
|
||||||
String ALTITUDE = "elevation";
|
String ALTITUDE = "elevation";
|
||||||
String ACCURACY = "accuracy";
|
String HORIZONTAL_ACCURACY = "accuracy";
|
||||||
String SPEED = "speed";
|
String SPEED = "speed";
|
||||||
String BEARING = "bearing";
|
String BEARING = "bearing";
|
||||||
String SENSOR_HEARTRATE = "sensor_heartrate";
|
String SENSOR_HEARTRATE = "sensor_heartrate";
|
||||||
@@ -69,7 +69,7 @@ public interface TrackPointsColumns extends BaseColumns {
|
|||||||
+ LATITUDE + " INTEGER, "
|
+ LATITUDE + " INTEGER, "
|
||||||
+ TIME + " INTEGER, "
|
+ TIME + " INTEGER, "
|
||||||
+ ALTITUDE + " FLOAT, "
|
+ ALTITUDE + " FLOAT, "
|
||||||
+ ACCURACY + " FLOAT, "
|
+ HORIZONTAL_ACCURACY + " FLOAT, "
|
||||||
+ SPEED + " FLOAT, "
|
+ SPEED + " FLOAT, "
|
||||||
+ BEARING + " FLOAT, "
|
+ BEARING + " FLOAT, "
|
||||||
+ SENSOR_HEARTRATE + " FLOAT, "
|
+ SENSOR_HEARTRATE + " FLOAT, "
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ class CachedTrackPointsIndexes {
|
|||||||
latitudeIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.LATITUDE);
|
latitudeIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.LATITUDE);
|
||||||
timeIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.TIME);
|
timeIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.TIME);
|
||||||
altitudeIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.ALTITUDE);
|
altitudeIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.ALTITUDE);
|
||||||
accuracyIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.ACCURACY);
|
accuracyIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.HORIZONTAL_ACCURACY);
|
||||||
speedIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.SPEED);
|
speedIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.SPEED);
|
||||||
bearingIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.BEARING);
|
bearingIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.BEARING);
|
||||||
sensorHeartRateIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.SENSOR_HEARTRATE);
|
sensorHeartRateIndex = cursor.getColumnIndexOrThrow(TrackPointsColumns.SENSOR_HEARTRATE);
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ public class ContentProviderUtils {
|
|||||||
marker.setAltitude(Altitude.WGS84.of(cursor.getFloat(altitudeIndex)));
|
marker.setAltitude(Altitude.WGS84.of(cursor.getFloat(altitudeIndex)));
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(accuracyIndex)) {
|
if (!cursor.isNull(accuracyIndex)) {
|
||||||
marker.setAccuracy(cursor.getFloat(accuracyIndex));
|
marker.setAccuracy(Distance.of(cursor.getFloat(accuracyIndex)));
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(bearingIndex)) {
|
if (!cursor.isNull(bearingIndex)) {
|
||||||
marker.setBearing(cursor.getFloat(bearingIndex));
|
marker.setBearing(cursor.getFloat(bearingIndex));
|
||||||
@@ -472,7 +472,7 @@ public class ContentProviderUtils {
|
|||||||
values.put(MarkerColumns.ALTITUDE, marker.getAltitude().toM());
|
values.put(MarkerColumns.ALTITUDE, marker.getAltitude().toM());
|
||||||
}
|
}
|
||||||
if (marker.hasAccuracy()) {
|
if (marker.hasAccuracy()) {
|
||||||
values.put(MarkerColumns.ACCURACY, marker.getAccuracy());
|
values.put(MarkerColumns.ACCURACY, marker.getAccuracy().toM());
|
||||||
}
|
}
|
||||||
if (marker.hasBearing()) {
|
if (marker.hasBearing()) {
|
||||||
values.put(MarkerColumns.BEARING, marker.getBearing());
|
values.put(MarkerColumns.BEARING, marker.getBearing());
|
||||||
@@ -520,7 +520,7 @@ public class ContentProviderUtils {
|
|||||||
trackPoint.setAltitude(Altitude.WGS84.of(cursor.getFloat(indexes.altitudeIndex)));
|
trackPoint.setAltitude(Altitude.WGS84.of(cursor.getFloat(indexes.altitudeIndex)));
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(indexes.accuracyIndex)) {
|
if (!cursor.isNull(indexes.accuracyIndex)) {
|
||||||
trackPoint.setAccuracy(cursor.getFloat(indexes.accuracyIndex));
|
trackPoint.setHorizontalAccuracy(Distance.of(cursor.getFloat(indexes.accuracyIndex)));
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(indexes.speedIndex)) {
|
if (!cursor.isNull(indexes.speedIndex)) {
|
||||||
trackPoint.setSpeed(Speed.of(cursor.getFloat(indexes.speedIndex)));
|
trackPoint.setSpeed(Speed.of(cursor.getFloat(indexes.speedIndex)));
|
||||||
@@ -681,8 +681,8 @@ public class ContentProviderUtils {
|
|||||||
if (trackPoint.hasAltitude()) {
|
if (trackPoint.hasAltitude()) {
|
||||||
values.put(TrackPointsColumns.ALTITUDE, trackPoint.getAltitude().toM());
|
values.put(TrackPointsColumns.ALTITUDE, trackPoint.getAltitude().toM());
|
||||||
}
|
}
|
||||||
if (trackPoint.hasAccuracy()) {
|
if (trackPoint.hasHorizontalAccuracy()) {
|
||||||
values.put(TrackPointsColumns.ACCURACY, trackPoint.getAccuracy());
|
values.put(TrackPointsColumns.HORIZONTAL_ACCURACY, trackPoint.getHorizontalAccuracy().toM());
|
||||||
}
|
}
|
||||||
if (trackPoint.hasSpeed()) {
|
if (trackPoint.hasSpeed()) {
|
||||||
values.put(TrackPointsColumns.SPEED, trackPoint.getSpeed().toMPS());
|
values.put(TrackPointsColumns.SPEED, trackPoint.getSpeed().toMPS());
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newTrackPoint(TrackPoint trackPoint, int recordingGpsAccuracy) {
|
public void newTrackPoint(TrackPoint trackPoint, Distance thresholdHorizontalAccuracy) {
|
||||||
if (!isRecording() || isPaused()) {
|
if (!isRecording() || isPaused()) {
|
||||||
Log.w(TAG, "Ignore newTrackPoint. Not recording or paused.");
|
Log.w(TAG, "Ignore newTrackPoint. Not recording or paused.");
|
||||||
return;
|
return;
|
||||||
@@ -504,7 +504,7 @@ public class TrackRecordingService extends Service implements HandlerServer.Hand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationManager.updateTrackPoint(this, track.getTrackStatistics(), trackPoint, recordingGpsAccuracy);
|
notificationManager.updateTrackPoint(this, track.getTrackStatistics(), trackPoint, thresholdHorizontalAccuracy);
|
||||||
|
|
||||||
//TODO Figure out how to avoid loading the lastValidTrackPoint from the database
|
//TODO Figure out how to avoid loading the lastValidTrackPoint from the database
|
||||||
TrackPoint lastValidTrackPoint = getLastValidTrackPointInCurrentSegment(track.getId());
|
TrackPoint lastValidTrackPoint = getLastValidTrackPointInCurrentSegment(track.getId());
|
||||||
|
|||||||
+4
-4
@@ -65,12 +65,12 @@ class TrackRecordingServiceNotificationManager {
|
|||||||
updateNotification();
|
updateNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTrackPoint(Context context, TrackStatistics trackStatistics, TrackPoint trackPoint, int recordingGpsAccuracy) {
|
void updateTrackPoint(Context context, TrackStatistics trackStatistics, TrackPoint trackPoint, Distance recordingGpsAccuracy) {
|
||||||
String formattedAccuracy = context.getString(R.string.value_none);
|
String formattedAccuracy = context.getString(R.string.value_none);
|
||||||
if (trackPoint.hasAccuracy()) {
|
if (trackPoint.hasHorizontalAccuracy()) {
|
||||||
formattedAccuracy = StringUtils.formatDistance(context, Distance.of(trackPoint.getAccuracy()), metricUnits);
|
formattedAccuracy = StringUtils.formatDistance(context, trackPoint.getHorizontalAccuracy(), metricUnits);
|
||||||
|
|
||||||
boolean currentLocationWasAccurate = trackPoint.getAccuracy() < recordingGpsAccuracy;
|
boolean currentLocationWasAccurate = trackPoint.getHorizontalAccuracy().lessThan(recordingGpsAccuracy);
|
||||||
boolean shouldAlert = !currentLocationWasAccurate && previousLocationWasAccurate;
|
boolean shouldAlert = !currentLocationWasAccurate && previousLocationWasAccurate;
|
||||||
notificationBuilder.setOnlyAlertOnce(!shouldAlert);
|
notificationBuilder.setOnlyAlertOnce(!shouldAlert);
|
||||||
previousLocationWasAccurate = currentLocationWasAccurate;
|
previousLocationWasAccurate = currentLocationWasAccurate;
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ import android.content.SharedPreferences;
|
|||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.content.data.Distance;
|
||||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||||
|
|
||||||
@@ -24,8 +26,7 @@ class GpsStatus {
|
|||||||
// The duration that GpsStatus waits from minimal interval to consider GPS lost.
|
// The duration that GpsStatus waits from minimal interval to consider GPS lost.
|
||||||
private static final Duration SIGNAL_LOST_THRESHOLD = Duration.ofSeconds(10);
|
private static final Duration SIGNAL_LOST_THRESHOLD = Duration.ofSeconds(10);
|
||||||
|
|
||||||
// Threshold for accuracy.
|
private Distance thresholdHorizontalAccuracy;
|
||||||
private double signalBadThreshold; //TODO Distance?
|
|
||||||
// Threshold for time without points.
|
// Threshold for time without points.
|
||||||
private Duration signalLostThreshold;
|
private Duration signalLostThreshold;
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ class GpsStatus {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
||||||
SharedPreferences sharedPreferences = PreferencesUtils.getSharedPreferences(context);
|
SharedPreferences sharedPreferences = PreferencesUtils.getSharedPreferences(context);
|
||||||
signalBadThreshold = PreferencesUtils.getRecordingDistanceInterval(sharedPreferences, context).toM();
|
thresholdHorizontalAccuracy = PreferencesUtils.getRecordingDistanceInterval(sharedPreferences, context);
|
||||||
|
|
||||||
Duration minRecordingInterval = Duration.ofSeconds(PreferencesUtils.getMinRecordingInterval(sharedPreferences, context));
|
Duration minRecordingInterval = Duration.ofSeconds(PreferencesUtils.getMinRecordingInterval(sharedPreferences, context));
|
||||||
signalLostThreshold = !minRecordingInterval.isNegative() ? SIGNAL_LOST_THRESHOLD.plus(minRecordingInterval) : SIGNAL_LOST_THRESHOLD;
|
signalLostThreshold = !minRecordingInterval.isNegative() ? SIGNAL_LOST_THRESHOLD.plus(minRecordingInterval) : SIGNAL_LOST_THRESHOLD;
|
||||||
@@ -97,8 +98,8 @@ class GpsStatus {
|
|||||||
*
|
*
|
||||||
* @param value New preference value to signalBadThreshold.
|
* @param value New preference value to signalBadThreshold.
|
||||||
*/
|
*/
|
||||||
public void onRecordingDistanceChanged(int value) {
|
public void onRecordingDistanceChanged(@NonNull Distance value) {
|
||||||
signalBadThreshold = value;
|
thresholdHorizontalAccuracy = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,13 +148,13 @@ class GpsStatus {
|
|||||||
gpsStatus = GpsStatusValue.GPS_SIGNAL_LOST;
|
gpsStatus = GpsStatusValue.GPS_SIGNAL_LOST;
|
||||||
sendStatus(oldStatus, gpsStatus);
|
sendStatus(oldStatus, gpsStatus);
|
||||||
stopStatusRunner();
|
stopStatusRunner();
|
||||||
} else if (lastTrackPoint.getAccuracy() > signalBadThreshold && gpsStatus != GpsStatusValue.GPS_SIGNAL_BAD) {
|
} else if (lastTrackPoint.fulfillsAccuracy(thresholdHorizontalAccuracy) && gpsStatus != GpsStatusValue.GPS_SIGNAL_BAD) {
|
||||||
// Too little accuracy -> bad signal.
|
// Too little accuracy -> bad signal.
|
||||||
GpsStatusValue oldStatus = gpsStatus;
|
GpsStatusValue oldStatus = gpsStatus;
|
||||||
gpsStatus = GpsStatusValue.GPS_SIGNAL_BAD;
|
gpsStatus = GpsStatusValue.GPS_SIGNAL_BAD;
|
||||||
sendStatus(oldStatus, gpsStatus);
|
sendStatus(oldStatus, gpsStatus);
|
||||||
startStatusRunner();
|
startStatusRunner();
|
||||||
} else if (lastTrackPoint.getAccuracy() <= signalBadThreshold && gpsStatus != GpsStatusValue.GPS_SIGNAL_FIX) {
|
} else if (lastTrackPoint.fulfillsAccuracy(thresholdHorizontalAccuracy) && gpsStatus != GpsStatusValue.GPS_SIGNAL_FIX) {
|
||||||
// Gps okay.
|
// Gps okay.
|
||||||
GpsStatusValue oldStatus = gpsStatus;
|
GpsStatusValue oldStatus = gpsStatus;
|
||||||
gpsStatus = GpsStatusValue.GPS_SIGNAL_FIX;
|
gpsStatus = GpsStatusValue.GPS_SIGNAL_FIX;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.content.data.Distance;
|
||||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||||
import de.dennisguse.opentracks.services.sensors.AltitudeSumManager;
|
import de.dennisguse.opentracks.services.sensors.AltitudeSumManager;
|
||||||
@@ -110,7 +111,7 @@ public class HandlerServer {
|
|||||||
locationHandler.onSharedPreferenceChanged(context, preferences, key);
|
locationHandler.onSharedPreferenceChanged(context, preferences, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNewTrackPoint(TrackPoint trackPoint, int recordingGpsAccuracy) {
|
public void onNewTrackPoint(TrackPoint trackPoint, Distance thresholdHorizontalAccuracy) {
|
||||||
// if (serviceExecutor == null || serviceExecutor.isTerminated() || serviceExecutor.isShutdown()) {
|
// if (serviceExecutor == null || serviceExecutor.isTerminated() || serviceExecutor.isShutdown()) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
@@ -119,8 +120,8 @@ public class HandlerServer {
|
|||||||
fillAndReset(trackPoint);
|
fillAndReset(trackPoint);
|
||||||
|
|
||||||
|
|
||||||
// serviceExecutor.execute(() -> service.newTrackPoint(trackPoint, recordingGpsAccuracy));
|
// serviceExecutor.execute(() -> service.newTrackPoint(trackPoint, thresholdHorizontalAccuracy));
|
||||||
service.newTrackPoint(trackPoint, recordingGpsAccuracy);
|
service.newTrackPoint(trackPoint, thresholdHorizontalAccuracy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TrackPoint createSegmentStartManual() {
|
public TrackPoint createSegmentStartManual() {
|
||||||
@@ -176,7 +177,7 @@ public class HandlerServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface HandlerServerInterface {
|
public interface HandlerServerInterface {
|
||||||
void newTrackPoint(TrackPoint trackPoint, int gpsAccuracy);
|
void newTrackPoint(TrackPoint trackPoint, Distance thresholdHorizontalAccuracy);
|
||||||
|
|
||||||
void newGpsStatus(GpsStatusValue gpsStatusValue);
|
void newGpsStatus(GpsStatusValue gpsStatusValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
|
import de.dennisguse.opentracks.content.data.Distance;
|
||||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||||
import de.dennisguse.opentracks.util.LocationUtils;
|
import de.dennisguse.opentracks.util.LocationUtils;
|
||||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||||
@@ -26,7 +27,7 @@ class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
|||||||
private GpsStatus gpsStatus;
|
private GpsStatus gpsStatus;
|
||||||
private LocationListenerPolicy locationListenerPolicy;
|
private LocationListenerPolicy locationListenerPolicy;
|
||||||
private Duration currentRecordingInterval;
|
private Duration currentRecordingInterval;
|
||||||
private int recordingGpsAccuracy;
|
private Distance thresholdHorizontalAccuracy;
|
||||||
private TrackPoint lastValidTrackPoint;
|
private TrackPoint lastValidTrackPoint;
|
||||||
|
|
||||||
public LocationHandler(HandlerServer handlerServer) {
|
public LocationHandler(HandlerServer handlerServer) {
|
||||||
@@ -69,7 +70,7 @@ class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
|||||||
registerLocationListener();
|
registerLocationListener();
|
||||||
}
|
}
|
||||||
if (PreferencesUtils.isKey(context, R.string.recording_gps_accuracy_key, key)) {
|
if (PreferencesUtils.isKey(context, R.string.recording_gps_accuracy_key, key)) {
|
||||||
recordingGpsAccuracy = PreferencesUtils.getRecordingGPSAccuracy(sharedPreferences, context);
|
thresholdHorizontalAccuracy = PreferencesUtils.getThresholdHorizontalAccuracy(sharedPreferences, context);
|
||||||
}
|
}
|
||||||
if (PreferencesUtils.isKey(context, R.string.min_recording_interval_key, key)) {
|
if (PreferencesUtils.isKey(context, R.string.min_recording_interval_key, key)) {
|
||||||
if (gpsStatus != null) {
|
if (gpsStatus != null) {
|
||||||
@@ -78,7 +79,7 @@ class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
|||||||
}
|
}
|
||||||
if (PreferencesUtils.isKey(context, R.string.recording_distance_interval_key, key)) {
|
if (PreferencesUtils.isKey(context, R.string.recording_distance_interval_key, key)) {
|
||||||
if (gpsStatus != null) {
|
if (gpsStatus != null) {
|
||||||
gpsStatus.onRecordingDistanceChanged((int) PreferencesUtils.getRecordingDistanceInterval(sharedPreferences, context).toM()); //TODO Use Distance?
|
gpsStatus.onRecordingDistanceChanged(PreferencesUtils.getRecordingDistanceInterval(sharedPreferences, context));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,7 @@ class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onLocationChanged(@NonNull Location location) {
|
public void onLocationChanged(@NonNull Location location) {
|
||||||
TrackPoint trackPoint = new TrackPoint(location, handlerServer.createNow());
|
TrackPoint trackPoint = new TrackPoint(location, handlerServer.createNow());
|
||||||
boolean isAccurate = trackPoint.fulfillsAccuracy(recordingGpsAccuracy);
|
boolean isAccurate = trackPoint.fulfillsAccuracy(thresholdHorizontalAccuracy);
|
||||||
boolean isValid = LocationUtils.isValidLocation(location);
|
boolean isValid = LocationUtils.isValidLocation(location);
|
||||||
|
|
||||||
if (gpsStatus != null) {
|
if (gpsStatus != null) {
|
||||||
@@ -119,7 +120,7 @@ class LocationHandler implements LocationListener, GpsStatus.GpsStatusListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastValidTrackPoint = trackPoint;
|
lastValidTrackPoint = trackPoint;
|
||||||
handlerServer.onNewTrackPoint(trackPoint, recordingGpsAccuracy);
|
handlerServer.onNewTrackPoint(trackPoint, thresholdHorizontalAccuracy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -247,9 +247,9 @@ public class PreferencesUtils {
|
|||||||
return Integer.parseInt(context.getResources().getString(R.string.min_recording_interval_default));
|
return Integer.parseInt(context.getResources().getString(R.string.min_recording_interval_default));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getRecordingGPSAccuracy(SharedPreferences sharedPreferences, Context context) {
|
public static Distance getThresholdHorizontalAccuracy(SharedPreferences sharedPreferences, Context context) {
|
||||||
final int RECORDING_GPS_ACCURACY = Integer.parseInt(context.getResources().getString(R.string.recording_gps_accuracy_default));
|
final int RECORDING_GPS_ACCURACY = Integer.parseInt(context.getResources().getString(R.string.recording_gps_accuracy_default));
|
||||||
return getInt(sharedPreferences, context, R.string.recording_gps_accuracy_key, RECORDING_GPS_ACCURACY);
|
return Distance.of(getInt(sharedPreferences, context, R.string.recording_gps_accuracy_key, RECORDING_GPS_ACCURACY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldInstantExportAfterWorkout(SharedPreferences sharedPreferences, Context context) {
|
public static boolean shouldInstantExportAfterWorkout(SharedPreferences sharedPreferences, Context context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user