forked from upstream-mirrors/OpenTracks
Check if location speed and accuracy are available.
This commit is contained in:
@@ -107,7 +107,9 @@ public class MapOverlay {
|
|||||||
public CachedLocation(Location location) {
|
public CachedLocation(Location location) {
|
||||||
this.valid = LocationUtils.isValidLocation(location);
|
this.valid = LocationUtils.isValidLocation(location);
|
||||||
this.latLng = valid ? new LatLng(location.getLatitude(), location.getLongitude()) : null;
|
this.latLng = valid ? new LatLng(location.getLatitude(), location.getLongitude()) : null;
|
||||||
this.speed = (int) Math.floor(location.getSpeed() * UnitConversions.MS_TO_KMH);
|
this.speed = location.hasSpeed() ? (int) Math.floor(
|
||||||
|
location.getSpeed() * UnitConversions.MS_TO_KMH)
|
||||||
|
: -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -714,7 +714,8 @@ public class MyTracksMapFragment extends SupportMapFragment implements TrackData
|
|||||||
hasGoodFix = false;
|
hasGoodFix = false;
|
||||||
} else {
|
} else {
|
||||||
hasFix = !LocationUtils.isLocationOld(currentLocation);
|
hasFix = !LocationUtils.isLocationOld(currentLocation);
|
||||||
hasGoodFix = currentLocation.getAccuracy() <= recordingGpsAccuracy;
|
hasGoodFix = currentLocation.hasAccuracy()
|
||||||
|
&& currentLocation.getAccuracy() < recordingGpsAccuracy;
|
||||||
}
|
}
|
||||||
if (!hasFix) {
|
if (!hasFix) {
|
||||||
message = getString(R.string.gps_wait_for_signal);
|
message = getString(R.string.gps_wait_for_signal);
|
||||||
|
|||||||
@@ -148,7 +148,8 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
|
|
||||||
if (lastLocation != null) {
|
if (lastLocation != null) {
|
||||||
boolean hasFix = !LocationUtils.isLocationOld(lastLocation);
|
boolean hasFix = !LocationUtils.isLocationOld(lastLocation);
|
||||||
boolean hasGoodFix = lastLocation.getAccuracy() <= recordingGpsAccuracy;
|
boolean hasGoodFix = lastLocation.hasAccuracy()
|
||||||
|
&& lastLocation.getAccuracy() < recordingGpsAccuracy;
|
||||||
|
|
||||||
if (!hasFix || !hasGoodFix) {
|
if (!hasFix || !hasGoodFix) {
|
||||||
lastLocation = null;
|
lastLocation = null;
|
||||||
|
|||||||
@@ -888,7 +888,7 @@ public class TrackRecordingService extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.getAccuracy() > recordingGpsAccuracy) {
|
if (!location.hasAccuracy() || location.getAccuracy() >= recordingGpsAccuracy) {
|
||||||
Log.d(TAG, "Ignore onLocationChangedAsync. Poor accuracy.");
|
Log.d(TAG, "Ignore onLocationChangedAsync. Poor accuracy.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,16 +192,18 @@ public class TripStatisticsUpdater {
|
|||||||
currentSegment.addMovingTime(movingTime);
|
currentSegment.addMovingTime(movingTime);
|
||||||
|
|
||||||
// Update grade
|
// Update grade
|
||||||
if (lastLocation.hasAltitude() && location.hasAltitude()) {
|
if (location.hasAltitude() && lastLocation.hasAltitude()) {
|
||||||
float run = lastLocation.distanceTo(location);
|
float run = lastLocation.distanceTo(location);
|
||||||
double rise = location.getAltitude() - lastLocation.getAltitude();
|
double rise = location.getAltitude() - lastLocation.getAltitude();
|
||||||
updateGrade(run, rise);
|
updateGrade(run, rise);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update max speed
|
// Update max speed
|
||||||
updateSpeed(
|
if (location.hasSpeed() && lastLocation.hasSpeed()) {
|
||||||
location.getTime(), location.getSpeed(), lastLocation.getTime(), lastLocation.getSpeed());
|
updateSpeed(
|
||||||
|
location.getTime(), location.getSpeed(), lastLocation.getTime(), lastLocation.getSpeed());
|
||||||
|
}
|
||||||
|
|
||||||
lastLocation = location;
|
lastLocation = location;
|
||||||
lastMovingLocation = location;
|
lastMovingLocation = location;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user