Segments: use TrackPoint.type.

So, far specific latitude for segment start/end (i.e., PAUSE/RESUME) was used.
#316.
This commit is contained in:
Dennis Guse
2021-01-15 07:57:05 +01:00
parent 163af2dab2
commit fcc17413e3
25 changed files with 300 additions and 235 deletions
@@ -17,6 +17,8 @@ package de.dennisguse.opentracks.util;
import android.location.Location;
import de.dennisguse.opentracks.content.data.TrackPoint;
/**
* Utility class for decimating tracks at a given level of precision.
*
@@ -34,26 +36,18 @@ public class LocationUtils {
/**
* Checks if a given location is a valid (i.e. physically possible) location on Earth.
* Note: The special separator locations (which have latitude = 100) will not qualify as valid.
* Neither will locations with lat=0 and lng=0 as these are most likely "bad" measurements which often cause trouble.
*
* @param location the location to test
* @return true if the location is a valid location.
*/
//TODO Move to TrackPoint
@Deprecated //See #316
public static boolean isValidLocation(Location location) {
return location != null
&& Math.abs(location.getLatitude()) <= 90
&& Math.abs(location.getLongitude()) <= 180;
}
/**
* Returns true if a location is old.
*
* @param location the location
*/
public static boolean isLocationOld(Location location) {
return !LocationUtils.isValidLocation(location) || (System.currentTimeMillis() - location.getTime() > MAX_LOCATION_AGE_MS);
public static boolean isTrackPointOld(TrackPoint trackPoint) {
return System.currentTimeMillis() - trackPoint.getTime() > MAX_LOCATION_AGE_MS;
}
}