forked from upstream-mirrors/OpenTracks
Removed Waypoint default constructor used by testing.
This avoids a null check for Waypoint.getLocation().
This commit is contained in:
@@ -16,11 +16,6 @@
|
||||
|
||||
package de.dennisguse.opentracks.content.data;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.dennisguse.opentracks.stats.TrackStatistics;
|
||||
|
||||
/**
|
||||
@@ -40,10 +35,6 @@ public class Track {
|
||||
|
||||
private TrackStatistics trackStatistics = new TrackStatistics();
|
||||
|
||||
// Location points (which may not have been loaded)
|
||||
@Deprecated //TODO Is only used by tests
|
||||
private List<TrackPoint> trackPoints = new ArrayList<>();
|
||||
|
||||
public Track() {
|
||||
}
|
||||
|
||||
@@ -94,21 +85,4 @@ public class Track {
|
||||
public void setTrackStatistics(TrackStatistics trackStatistics) {
|
||||
this.trackStatistics = trackStatistics;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@VisibleForTesting
|
||||
public void addTrackPoint(TrackPoint location) {
|
||||
trackPoints.add(location);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@Deprecated //TODO Only used for testing; can be removed?
|
||||
public List<TrackPoint> getTrackPoints() {
|
||||
return trackPoints;
|
||||
}
|
||||
|
||||
@Deprecated //TODO Remove
|
||||
public void setTrackPoints(ArrayList<TrackPoint> trackPoints) {
|
||||
this.trackPoints = trackPoints;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -638,6 +638,7 @@ public class ContentProviderUtils {
|
||||
* @param trackId the trackPoints id
|
||||
* @return the number of trackPoints inserted
|
||||
*/
|
||||
//TODO Only used for testing and file import; might be better to replace it; in any case remove length.
|
||||
public int bulkInsertTrackPoint(TrackPoint[] trackPoints, int length, long trackId) {
|
||||
if (length == -1) {
|
||||
length = trackPoints.length;
|
||||
|
||||
@@ -383,8 +383,8 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
trackStatisticsUpdater = new TrackStatisticsUpdater(track.getTrackStatistics().getStartTime_ms());
|
||||
|
||||
try (TrackPointIterator locationIterator = contentProviderUtils.getTrackPointLocationIterator(track.getId(), -1L, false)) {
|
||||
trackStatisticsUpdater.addTrackPoint(locationIterator, recordingDistanceInterval);
|
||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(track.getId(), -1L, false)) {
|
||||
trackStatisticsUpdater.addTrackPoint(trackPointIterator, recordingDistanceInterval);
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "RuntimeException", e);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
|
||||
/**
|
||||
@@ -90,13 +89,13 @@ public class LocationUtils {
|
||||
*
|
||||
* @param tolerance in meters
|
||||
* @param trackPoints input
|
||||
* @param decimated output
|
||||
*/
|
||||
//TODO What was it used for? Sharing data with other apps?
|
||||
private static void decimate(double tolerance, List<TrackPoint> trackPoints, List<TrackPoint> decimated) {
|
||||
private static List<TrackPoint> decimate(double tolerance, List<TrackPoint> trackPoints) {
|
||||
List<TrackPoint> decimated = new ArrayList<>();
|
||||
final int n = trackPoints.size();
|
||||
if (n < 1) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
int idx;
|
||||
int maxIdx = 0;
|
||||
@@ -142,18 +141,8 @@ public class LocationUtils {
|
||||
idx++;
|
||||
}
|
||||
Log.d(TAG, "Decimating " + n + " points to " + i + " w/ tolerance = " + tolerance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decimates the given track for the given precision.
|
||||
*
|
||||
* @param track a track
|
||||
* @param precision desired precision in meters
|
||||
*/
|
||||
public static void decimate(Track track, double precision) {
|
||||
ArrayList<TrackPoint> decimated = new ArrayList<>();
|
||||
decimate(precision, track.getTrackPoints(), decimated);
|
||||
track.setTrackPoints(decimated);
|
||||
return decimated;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user