forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
@@ -16,7 +16,7 @@ limitations under the License.
|
|||||||
-->
|
-->
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:installLocation="auto"
|
android:installLocation="auto"
|
||||||
android:versionCode="68"
|
android:versionCode="69"
|
||||||
android:versionName="2.0.5"
|
android:versionName="2.0.5"
|
||||||
package="com.google.android.maps.mytracks" >
|
package="com.google.android.maps.mytracks" >
|
||||||
<!-- Permission to initialize services -->
|
<!-- Permission to initialize services -->
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,6 @@ import android.util.Log;
|
|||||||
*/
|
*/
|
||||||
public class TripStatisticsUpdater {
|
public class TripStatisticsUpdater {
|
||||||
|
|
||||||
/**
|
|
||||||
* The number of distance readings to smooth to get a stable signal.
|
|
||||||
*/
|
|
||||||
@VisibleForTesting
|
|
||||||
static final int DISTANCE_SMOOTHING_FACTOR = 25;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of elevation readings to smooth to get a somewhat accurate
|
* The number of elevation readings to smooth to get a somewhat accurate
|
||||||
* signal.
|
* signal.
|
||||||
@@ -48,6 +42,18 @@ public class TripStatisticsUpdater {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int ELEVATION_SMOOTHING_FACTOR = 25;
|
static final int ELEVATION_SMOOTHING_FACTOR = 25;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of run readings to smooth for calculating grade.
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
static final int RUN_SMOOTHING_FACTOR = 25;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of rise readings to smooth for calculating grade.
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
static final int RISE_SMOOTHING_FACTOR = 25;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of grade readings to smooth to get a somewhat accurate signal.
|
* The number of grade readings to smooth to get a somewhat accurate signal.
|
||||||
*/
|
*/
|
||||||
@@ -67,7 +73,7 @@ public class TripStatisticsUpdater {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Ignore any acceleration faster than this. Will ignore any speeds that imply
|
* Ignore any acceleration faster than this. Will ignore any speeds that imply
|
||||||
* accelaration greater than 2g's 2g = 19.6 m/s^2 = 0.0002 m/ms^2 = 0.02
|
* acceleration greater than 2g's 2g = 19.6 m/s^2 = 0.0002 m/ms^2 = 0.02
|
||||||
* m/(m*ms)
|
* m/(m*ms)
|
||||||
*/
|
*/
|
||||||
private static final double MAX_ACCELERATION = 0.02;
|
private static final double MAX_ACCELERATION = 0.02;
|
||||||
@@ -84,18 +90,21 @@ public class TripStatisticsUpdater {
|
|||||||
// Current segment's last moving location
|
// Current segment's last moving location
|
||||||
private Location lastMovingLocation;
|
private Location lastMovingLocation;
|
||||||
|
|
||||||
// A buffer of the recent speed readings (m/s) for calculating max speed
|
|
||||||
private final DoubleBuffer speedBuffer = new DoubleBuffer(SPEED_SMOOTHING_FACTOR);
|
|
||||||
|
|
||||||
// A buffer of the recent elevation readings (m)
|
// A buffer of the recent elevation readings (m)
|
||||||
private final DoubleBuffer elevationBuffer = new DoubleBuffer(ELEVATION_SMOOTHING_FACTOR);
|
private final DoubleBuffer elevationBuffer = new DoubleBuffer(ELEVATION_SMOOTHING_FACTOR);
|
||||||
|
|
||||||
// A buffer of the recent distance readings (m) for calculating grade
|
// A buffer of the recent run readings (m) for calculating grade
|
||||||
private final DoubleBuffer distanceBuffer = new DoubleBuffer(DISTANCE_SMOOTHING_FACTOR);
|
private final DoubleBuffer runBuffer = new DoubleBuffer(RUN_SMOOTHING_FACTOR);
|
||||||
|
|
||||||
|
// A buffer of the recent rise readings (m) for calculating grade
|
||||||
|
private final DoubleBuffer riseBuffer = new DoubleBuffer(RISE_SMOOTHING_FACTOR);
|
||||||
|
|
||||||
// A buffer of the recent grade calculations (%)
|
// A buffer of the recent grade calculations (%)
|
||||||
private final DoubleBuffer gradeBuffer = new DoubleBuffer(GRADE_SMOOTHING_FACTOR);
|
private final DoubleBuffer gradeBuffer = new DoubleBuffer(GRADE_SMOOTHING_FACTOR);
|
||||||
|
|
||||||
|
// A buffer of the recent speed readings (m/s) for calculating max speed
|
||||||
|
private final DoubleBuffer speedBuffer = new DoubleBuffer(SPEED_SMOOTHING_FACTOR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new trip statistics updater.
|
* Creates a new trip statistics updater.
|
||||||
*
|
*
|
||||||
@@ -128,8 +137,11 @@ public class TripStatisticsUpdater {
|
|||||||
* @param minRecordingDistance the min recording distance
|
* @param minRecordingDistance the min recording distance
|
||||||
*/
|
*/
|
||||||
public void addLocation(Location location, int minRecordingDistance) {
|
public void addLocation(Location location, int minRecordingDistance) {
|
||||||
|
// Always update time
|
||||||
|
updateTime(location.getTime());
|
||||||
|
|
||||||
if (!LocationUtils.isValidLocation(location)) {
|
if (!LocationUtils.isValidLocation(location)) {
|
||||||
updateTime(location.getTime());
|
// Either pause or resume marker
|
||||||
if (location.getLatitude() == TrackRecordingService.PAUSE_LATITUDE) {
|
if (location.getLatitude() == TrackRecordingService.PAUSE_LATITUDE) {
|
||||||
if (lastLocation != null && lastMovingLocation != null
|
if (lastLocation != null && lastMovingLocation != null
|
||||||
&& lastLocation != lastMovingLocation) {
|
&& lastLocation != lastMovingLocation) {
|
||||||
@@ -140,40 +152,58 @@ public class TripStatisticsUpdater {
|
|||||||
currentSegment = init(location.getTime());
|
currentSegment = init(location.getTime());
|
||||||
lastLocation = null;
|
lastLocation = null;
|
||||||
lastMovingLocation = null;
|
lastMovingLocation = null;
|
||||||
speedBuffer.reset();
|
|
||||||
elevationBuffer.reset();
|
elevationBuffer.reset();
|
||||||
distanceBuffer.reset();
|
runBuffer.reset();
|
||||||
|
riseBuffer.reset();
|
||||||
gradeBuffer.reset();
|
gradeBuffer.reset();
|
||||||
|
speedBuffer.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double elevationDifference = updateElevation(location.getAltitude());
|
|
||||||
currentSegment.updateLatitudeExtremities(location.getLatitude());
|
currentSegment.updateLatitudeExtremities(location.getLatitude());
|
||||||
currentSegment.updateLongitudeExtremities(location.getLongitude());
|
currentSegment.updateLongitudeExtremities(location.getLongitude());
|
||||||
|
|
||||||
|
if (location.hasAltitude()) {
|
||||||
|
updateElevation(location.getAltitude());
|
||||||
|
}
|
||||||
|
|
||||||
if (lastLocation == null || lastMovingLocation == null) {
|
if (lastLocation == null || lastMovingLocation == null) {
|
||||||
updateTime(location.getTime());
|
|
||||||
lastLocation = location;
|
lastLocation = location;
|
||||||
lastMovingLocation = location;
|
lastMovingLocation = location;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double movingDistance = lastMovingLocation.distanceTo(location);
|
double movingDistance = lastMovingLocation.distanceTo(location);
|
||||||
if (movingDistance < minRecordingDistance && location.getSpeed() < MAX_NO_MOVEMENT_SPEED) {
|
if (movingDistance < minRecordingDistance) {
|
||||||
updateTime(location.getTime());
|
if (!location.hasSpeed() || location.getSpeed() < MAX_NO_MOVEMENT_SPEED) {
|
||||||
lastLocation = location;
|
lastLocation = location;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
long movingTime = location.getTime() - lastLocation.getTime();
|
long movingTime = location.getTime() - lastLocation.getTime();
|
||||||
if (movingTime < 0) {
|
if (movingTime < 0) {
|
||||||
updateTime(location.getTime());
|
|
||||||
lastLocation = location;
|
lastLocation = location;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update total distance
|
||||||
currentSegment.addTotalDistance(movingDistance);
|
currentSegment.addTotalDistance(movingDistance);
|
||||||
|
|
||||||
|
// Update moving time
|
||||||
currentSegment.addMovingTime(movingTime);
|
currentSegment.addMovingTime(movingTime);
|
||||||
updateSpeed(
|
|
||||||
location.getTime(), location.getSpeed(), lastLocation.getTime(), lastLocation.getSpeed());
|
// Update grade
|
||||||
updateGrade(lastLocation.distanceTo(location), elevationDifference);
|
if (location.hasAltitude() && lastLocation.hasAltitude()) {
|
||||||
updateTime(location.getTime());
|
float run = lastLocation.distanceTo(location);
|
||||||
|
double rise = location.getAltitude() - lastLocation.getAltitude();
|
||||||
|
updateGrade(run, rise);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update max speed
|
||||||
|
if (location.hasSpeed() && lastLocation.hasSpeed()) {
|
||||||
|
updateSpeed(
|
||||||
|
location.getTime(), location.getSpeed(), lastLocation.getTime(), lastLocation.getSpeed());
|
||||||
|
}
|
||||||
|
|
||||||
lastLocation = location;
|
lastLocation = location;
|
||||||
lastMovingLocation = location;
|
lastMovingLocation = location;
|
||||||
}
|
}
|
||||||
@@ -217,38 +247,46 @@ public class TripStatisticsUpdater {
|
|||||||
* @param elevation the elevation
|
* @param elevation the elevation
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
double updateElevation(double elevation) {
|
void updateElevation(double elevation) {
|
||||||
|
currentSegment.updateElevationExtremities(elevation);
|
||||||
|
|
||||||
|
// update elevation gain
|
||||||
double oldAverage = elevationBuffer.getAverage();
|
double oldAverage = elevationBuffer.getAverage();
|
||||||
elevationBuffer.setNext(elevation);
|
elevationBuffer.setNext(elevation);
|
||||||
double newAverage = elevationBuffer.getAverage();
|
double newAverage = elevationBuffer.getAverage();
|
||||||
currentSegment.updateElevationExtremities(newAverage);
|
if (elevationBuffer.isFull()) {
|
||||||
double elevationDifference = elevationBuffer.isFull() ? newAverage - oldAverage : 0.0;
|
double difference = newAverage - oldAverage;
|
||||||
if (elevationDifference > 0) {
|
if (difference > 0) {
|
||||||
currentSegment.addTotalElevationGain(elevationDifference);
|
currentSegment.addTotalElevationGain(difference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return elevationDifference;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a grade reading.
|
* Updates a grade reading.
|
||||||
*
|
*
|
||||||
* @param distance the distance the user just traveled
|
* @param run the run
|
||||||
* @param elevationDifference the elevation difference between the current
|
* @param rise the rise
|
||||||
* reading and the previous reading
|
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void updateGrade(double distance, double elevationDifference) {
|
void updateGrade(double run, double rise) {
|
||||||
distanceBuffer.setNext(distance);
|
runBuffer.setNext(run);
|
||||||
double smoothedDistance = distanceBuffer.getAverage();
|
riseBuffer.setNext(rise);
|
||||||
|
|
||||||
|
if (!runBuffer.isFull() || !riseBuffer.isFull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double smoothedRun = runBuffer.getAverage();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* With the error in the altitude measurement it is dangerous to divide by
|
* With the error in the altitude measurement it is dangerous to divide by
|
||||||
* anything less than 5.
|
* anything less than 5.
|
||||||
*/
|
*/
|
||||||
if (!elevationBuffer.isFull() || !distanceBuffer.isFull() || smoothedDistance < 5.0) {
|
if (smoothedRun < 5.0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gradeBuffer.setNext(elevationDifference / smoothedDistance);
|
gradeBuffer.setNext(riseBuffer.getAverage() / smoothedRun);
|
||||||
currentSegment.updateGradeExtremities(gradeBuffer.getAverage());
|
currentSegment.updateGradeExtremities(gradeBuffer.getAverage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ public class StatsUtils {
|
|||||||
activity, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
|
activity, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
|
||||||
|
|
||||||
// Set speed/pace
|
// Set speed/pace
|
||||||
double speed = !isRecording || location == null ? Double.NaN : location.getSpeed();
|
double speed = isRecording && location != null && location.hasSpeed() ? location.getSpeed()
|
||||||
|
: Double.NaN;
|
||||||
setSpeed(activity, R.id.stats_speed, R.string.stats_speed, R.string.stats_pace, speed,
|
setSpeed(activity, R.id.stats_speed, R.string.stats_speed, R.string.stats_pace, speed,
|
||||||
metricUnits, reportSpeed);
|
metricUnits, reportSpeed);
|
||||||
|
|
||||||
@@ -65,7 +66,8 @@ public class StatsUtils {
|
|||||||
View elevation = activity.findViewById(R.id.stats_elevation);
|
View elevation = activity.findViewById(R.id.stats_elevation);
|
||||||
|
|
||||||
if (showGradeElevation && isRecording) {
|
if (showGradeElevation && isRecording) {
|
||||||
double altitude = location == null ? Double.NaN : location.getAltitude();
|
double altitude = location != null && location.hasAltitude() ? location.getAltitude()
|
||||||
|
: Double.NaN;
|
||||||
elevation.setVisibility(View.VISIBLE);
|
elevation.setVisibility(View.VISIBLE);
|
||||||
setElevationValue(activity, R.id.stats_elevation, -1, altitude, metricUnits);
|
setElevationValue(activity, R.id.stats_elevation, -1, altitude, metricUnits);
|
||||||
} else {
|
} else {
|
||||||
@@ -79,8 +81,8 @@ public class StatsUtils {
|
|||||||
View coordinateContainer = activity.findViewById(R.id.stats_coordinate_container);
|
View coordinateContainer = activity.findViewById(R.id.stats_coordinate_container);
|
||||||
|
|
||||||
if (showCoordinate && isRecording) {
|
if (showCoordinate && isRecording) {
|
||||||
double latitude = location == null ? Double.NaN : location.getLatitude();
|
double latitude = location != null ? location.getLatitude() : Double.NaN;
|
||||||
double longitude = location == null ? Double.NaN : location.getLongitude();
|
double longitude = location != null ? location.getLongitude() : Double.NaN;
|
||||||
coordinateHorizontalLine.setVisibility(View.VISIBLE);
|
coordinateHorizontalLine.setVisibility(View.VISIBLE);
|
||||||
coordinateContainer.setVisibility(View.VISIBLE);
|
coordinateContainer.setVisibility(View.VISIBLE);
|
||||||
setCoordinateValue(activity, R.id.stats_latitude, R.string.stats_latitude, latitude);
|
setCoordinateValue(activity, R.id.stats_latitude, R.string.stats_latitude, latitude);
|
||||||
|
|||||||
@@ -73,20 +73,19 @@ public class TripStatistics implements Parcelable {
|
|||||||
* @param other another statistics data object to copy from
|
* @param other another statistics data object to copy from
|
||||||
*/
|
*/
|
||||||
public TripStatistics(TripStatistics other) {
|
public TripStatistics(TripStatistics other) {
|
||||||
this.startTime = other.startTime;
|
startTime = other.startTime;
|
||||||
this.stopTime = other.stopTime;
|
stopTime = other.stopTime;
|
||||||
this.totalDistance = other.totalDistance;
|
totalDistance = other.totalDistance;
|
||||||
this.totalTime = other.totalTime;
|
totalTime = other.totalTime;
|
||||||
this.movingTime = other.movingTime;
|
movingTime = other.movingTime;
|
||||||
this.latitudeExtremities.set(
|
latitudeExtremities.set(other.latitudeExtremities.getMin(), other.latitudeExtremities.getMax());
|
||||||
other.latitudeExtremities.getMin(), other.latitudeExtremities.getMax());
|
longitudeExtremities.set(
|
||||||
this.longitudeExtremities.set(
|
|
||||||
other.longitudeExtremities.getMin(), other.longitudeExtremities.getMax());
|
other.longitudeExtremities.getMin(), other.longitudeExtremities.getMax());
|
||||||
this.maxSpeed = other.maxSpeed;
|
maxSpeed = other.maxSpeed;
|
||||||
this.elevationExtremities.set(
|
elevationExtremities.set(
|
||||||
other.elevationExtremities.getMin(), other.elevationExtremities.getMax());
|
other.elevationExtremities.getMin(), other.elevationExtremities.getMax());
|
||||||
this.totalElevationGain = other.totalElevationGain;
|
totalElevationGain = other.totalElevationGain;
|
||||||
this.gradeExtremities.set(other.gradeExtremities.getMin(), other.gradeExtremities.getMax());
|
gradeExtremities.set(other.gradeExtremities.getMin(), other.gradeExtremities.getMax());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,6 +127,15 @@ public class TripStatistics implements Parcelable {
|
|||||||
return startTime;
|
return startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the trip start time.
|
||||||
|
*
|
||||||
|
* @param startTime the trip start time in milliseconds since the epoch
|
||||||
|
*/
|
||||||
|
public void setStartTime(long startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the trip stop time. The number of milliseconds since epoch.
|
* Gets the trip stop time. The number of milliseconds since epoch.
|
||||||
*/
|
*/
|
||||||
@@ -135,6 +143,15 @@ public class TripStatistics implements Parcelable {
|
|||||||
return stopTime;
|
return stopTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the trip stop time.
|
||||||
|
*
|
||||||
|
* @param stopTime the stop time in milliseconds since the epoch
|
||||||
|
*/
|
||||||
|
public void setStopTime(long stopTime) {
|
||||||
|
this.stopTime = stopTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the total distance the user traveled in meters.
|
* Gets the total distance the user traveled in meters.
|
||||||
*/
|
*/
|
||||||
@@ -142,6 +159,24 @@ public class TripStatistics implements Parcelable {
|
|||||||
return totalDistance;
|
return totalDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the total trip distance.
|
||||||
|
*
|
||||||
|
* @param totalDistance the trip distance in meters
|
||||||
|
*/
|
||||||
|
public void setTotalDistance(double totalDistance) {
|
||||||
|
this.totalDistance = totalDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds to the current total distance.
|
||||||
|
*
|
||||||
|
* @param distance the distance to add in meters
|
||||||
|
*/
|
||||||
|
public void addTotalDistance(double distance) {
|
||||||
|
totalDistance += distance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the total time in milliseconds that this track has been active. This
|
* Gets the total time in milliseconds that this track has been active. This
|
||||||
* statistic is only updated when a new point is added to the statistics, so
|
* statistic is only updated when a new point is added to the statistics, so
|
||||||
@@ -152,6 +187,15 @@ public class TripStatistics implements Parcelable {
|
|||||||
return totalTime;
|
return totalTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the trip total time.
|
||||||
|
*
|
||||||
|
* @param totalTime the trip total time in milliseconds
|
||||||
|
*/
|
||||||
|
public void setTotalTime(long totalTime) {
|
||||||
|
this.totalTime = totalTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the moving time in milliseconds.
|
* Gets the moving time in milliseconds.
|
||||||
*/
|
*/
|
||||||
@@ -159,6 +203,24 @@ public class TripStatistics implements Parcelable {
|
|||||||
return movingTime;
|
return movingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the trip total moving time.
|
||||||
|
*
|
||||||
|
* @param movingTime the trip total moving time in milliseconds
|
||||||
|
*/
|
||||||
|
public void setMovingTime(long movingTime) {
|
||||||
|
this.movingTime = movingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds to the trip total moving time.
|
||||||
|
*
|
||||||
|
* @param time the time in milliseconds
|
||||||
|
*/
|
||||||
|
public void addMovingTime(long time) {
|
||||||
|
movingTime += time;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the topmost position (highest latitude) of the track, in signed
|
* Gets the topmost position (highest latitude) of the track, in signed
|
||||||
* degrees.
|
* degrees.
|
||||||
@@ -237,6 +299,38 @@ public class TripStatistics implements Parcelable {
|
|||||||
return (getLeftDegrees() + getRightDegrees()) / 2.0;
|
return (getLeftDegrees() + getRightDegrees()) / 2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bounding box for this trip. The unit for all parameters is signed
|
||||||
|
* millions of degree (degrees * 1E6).
|
||||||
|
*
|
||||||
|
* @param leftE6 the leftmost longitude reached
|
||||||
|
* @param topE6 the topmost latitude reached
|
||||||
|
* @param rightE6 the rightmost longitude reached
|
||||||
|
* @param bottomE6 the bottommost latitude reached
|
||||||
|
*/
|
||||||
|
public void setBounds(int leftE6, int topE6, int rightE6, int bottomE6) {
|
||||||
|
latitudeExtremities.set(bottomE6 / 1E6, topE6 / 1E6);
|
||||||
|
longitudeExtremities.set(leftE6 / 1E6, rightE6 / 1E6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a new latitude value.
|
||||||
|
*
|
||||||
|
* @param latitude the latitude value in signed decimal degrees
|
||||||
|
*/
|
||||||
|
public void updateLatitudeExtremities(double latitude) {
|
||||||
|
latitudeExtremities.update(latitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a new longitude value.
|
||||||
|
*
|
||||||
|
* @param longitude the longitude value in signed decimal degrees
|
||||||
|
*/
|
||||||
|
public void updateLongitudeExtremities(double longitude) {
|
||||||
|
longitudeExtremities.update(longitude);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the average speed in meters/second. This calculation only takes into
|
* Gets the average speed in meters/second. This calculation only takes into
|
||||||
* account the displacement until the last point that was accounted for in
|
* account the displacement until the last point that was accounted for in
|
||||||
@@ -263,140 +357,7 @@ public class TripStatistics implements Parcelable {
|
|||||||
* Gets the maximum speed in meters/second.
|
* Gets the maximum speed in meters/second.
|
||||||
*/
|
*/
|
||||||
public double getMaxSpeed() {
|
public double getMaxSpeed() {
|
||||||
return maxSpeed;
|
return Math.max(maxSpeed, getAverageMovingSpeed());
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the minimum elevation. This is calculated from the smoothed elevation
|
|
||||||
* so this can actually be more than the current elevation.
|
|
||||||
*/
|
|
||||||
public double getMinElevation() {
|
|
||||||
return elevationExtremities.getMin();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the maximum elevation. This is calculated from the smoothed elevation
|
|
||||||
* so this can actually be less than the current elevation.
|
|
||||||
*/
|
|
||||||
public double getMaxElevation() {
|
|
||||||
return elevationExtremities.getMax();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the total elevation gain in meters. This is calculated as the sum of
|
|
||||||
* all positive differences in the smoothed elevation.
|
|
||||||
*/
|
|
||||||
public double getTotalElevationGain() {
|
|
||||||
return totalElevationGain;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the minimum grade for this trip.
|
|
||||||
*/
|
|
||||||
public double getMinGrade() {
|
|
||||||
return gradeExtremities.getMin();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the maximum grade for this trip.
|
|
||||||
*/
|
|
||||||
public double getMaxGrade() {
|
|
||||||
return gradeExtremities.getMax();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the trip start time.
|
|
||||||
*
|
|
||||||
* @param startTime the trip start time in milliseconds since the epoch
|
|
||||||
*/
|
|
||||||
public void setStartTime(long startTime) {
|
|
||||||
this.startTime = startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the trip stop time.
|
|
||||||
*
|
|
||||||
* @param stopTime the stop time in milliseconds since the epoch
|
|
||||||
*/
|
|
||||||
public void setStopTime(long stopTime) {
|
|
||||||
this.stopTime = stopTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the total trip distance.
|
|
||||||
*
|
|
||||||
* @param totalDistance the trip distance in meters
|
|
||||||
*/
|
|
||||||
public void setTotalDistance(double totalDistance) {
|
|
||||||
this.totalDistance = totalDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds to the current total distance.
|
|
||||||
*
|
|
||||||
* @param distance the distance to add in meters
|
|
||||||
*/
|
|
||||||
void addTotalDistance(double distance) {
|
|
||||||
totalDistance += distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the trip total time.
|
|
||||||
*
|
|
||||||
* @param totalTime the trip total time in milliseconds
|
|
||||||
*/
|
|
||||||
public void setTotalTime(long totalTime) {
|
|
||||||
this.totalTime = totalTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the trip total moving time.
|
|
||||||
*
|
|
||||||
* @param movingTime the trip total moving time in milliseconds
|
|
||||||
*/
|
|
||||||
public void setMovingTime(long movingTime) {
|
|
||||||
this.movingTime = movingTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds to the trip total moving time.
|
|
||||||
*
|
|
||||||
* @param time the time in milliseconds
|
|
||||||
*/
|
|
||||||
void addMovingTime(long time) {
|
|
||||||
movingTime += time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the bounding box for this trip. The unit for all parameters is signed
|
|
||||||
* millions of degree (degrees * 1E6).
|
|
||||||
*
|
|
||||||
* @param leftE6 the leftmost longitude reached
|
|
||||||
* @param topE6 the topmost latitude reached
|
|
||||||
* @param rightE6 the rightmost longitude reached
|
|
||||||
* @param bottomE6 the bottommost latitude reached
|
|
||||||
*/
|
|
||||||
public void setBounds(int leftE6, int topE6, int rightE6, int bottomE6) {
|
|
||||||
latitudeExtremities.set(bottomE6 / 1E6, topE6 / 1E6);
|
|
||||||
longitudeExtremities.set(leftE6 / 1E6, rightE6 / 1E6);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates a new latitude value.
|
|
||||||
*
|
|
||||||
* @param latitude the latitude value in signed decimal degrees
|
|
||||||
*/
|
|
||||||
void updateLatitudeExtremities(double latitude) {
|
|
||||||
latitudeExtremities.update(latitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates a new longitude value.
|
|
||||||
*
|
|
||||||
* @param longitude the longitude value in signed decimal degrees
|
|
||||||
*/
|
|
||||||
void updateLongitudeExtremities(double longitude) {
|
|
||||||
longitudeExtremities.update(longitude);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -408,6 +369,14 @@ public class TripStatistics implements Parcelable {
|
|||||||
this.maxSpeed = maxSpeed;
|
this.maxSpeed = maxSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the minimum elevation. This is calculated from the smoothed elevation
|
||||||
|
* so this can actually be more than the current elevation.
|
||||||
|
*/
|
||||||
|
public double getMinElevation() {
|
||||||
|
return elevationExtremities.getMin();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the minimum elevation.
|
* Sets the minimum elevation.
|
||||||
*
|
*
|
||||||
@@ -417,6 +386,14 @@ public class TripStatistics implements Parcelable {
|
|||||||
elevationExtremities.setMin(elevation);
|
elevationExtremities.setMin(elevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum elevation. This is calculated from the smoothed elevation
|
||||||
|
* so this can actually be less than the current elevation.
|
||||||
|
*/
|
||||||
|
public double getMaxElevation() {
|
||||||
|
return elevationExtremities.getMax();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the maximum elevation.
|
* Sets the maximum elevation.
|
||||||
*
|
*
|
||||||
@@ -431,10 +408,18 @@ public class TripStatistics implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @param elevation the elevation value in meters
|
* @param elevation the elevation value in meters
|
||||||
*/
|
*/
|
||||||
void updateElevationExtremities(double elevation) {
|
public void updateElevationExtremities(double elevation) {
|
||||||
elevationExtremities.update(elevation);
|
elevationExtremities.update(elevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the total elevation gain in meters. This is calculated as the sum of
|
||||||
|
* all positive differences in the smoothed elevation.
|
||||||
|
*/
|
||||||
|
public double getTotalElevationGain() {
|
||||||
|
return totalElevationGain;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the total elevation gain.
|
* Sets the total elevation gain.
|
||||||
*
|
*
|
||||||
@@ -449,17 +434,15 @@ public class TripStatistics implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @param gain the elevation gain in meters
|
* @param gain the elevation gain in meters
|
||||||
*/
|
*/
|
||||||
void addTotalElevationGain(double gain) {
|
public void addTotalElevationGain(double gain) {
|
||||||
totalElevationGain += gain;
|
totalElevationGain += gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the minimum grade.
|
* Gets the minimum grade for this trip.
|
||||||
*
|
|
||||||
* @param grade the grade as a fraction (-1.0 would mean vertical downwards)
|
|
||||||
*/
|
*/
|
||||||
public void setMinGrade(double grade) {
|
public double getMinGrade() {
|
||||||
gradeExtremities.setMin(grade);
|
return gradeExtremities.getMin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -471,23 +454,38 @@ public class TripStatistics implements Parcelable {
|
|||||||
gradeExtremities.setMax(grade);
|
gradeExtremities.setMax(grade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum grade for this trip.
|
||||||
|
*/
|
||||||
|
public double getMaxGrade() {
|
||||||
|
return gradeExtremities.getMax();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the minimum grade.
|
||||||
|
*
|
||||||
|
* @param grade the grade as a fraction (-1.0 would mean vertical downwards)
|
||||||
|
*/
|
||||||
|
public void setMinGrade(double grade) {
|
||||||
|
gradeExtremities.setMin(grade);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a new grade value.
|
* Updates a new grade value.
|
||||||
*
|
*
|
||||||
* @param grade the grade value as a fraction
|
* @param grade the grade value as a fraction
|
||||||
*/
|
*/
|
||||||
void updateGradeExtremities(double grade) {
|
public void updateGradeExtremities(double grade) {
|
||||||
gradeExtremities.update(grade);
|
gradeExtremities.update(grade);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "TripStatistics { Start Time: " + getStartTime() + "; Stop Time: " + getStopTime()
|
return "TripStatistics { Start Time: " + getStartTime() + "; Stop Time: " + getStopTime()
|
||||||
+ "; Total Time: " + getTotalTime() + "; Total Distance: " + getTotalDistance()
|
+ "; Total Distance: " + getTotalDistance() + "; Total Time: " + getTotalTime()
|
||||||
+ "; Total Time: " + getTotalTime() + "; Moving Time: " + getMovingTime()
|
+ "; Moving Time: " + getMovingTime() + "; Min Latitude: " + getBottomDegrees()
|
||||||
+ "; Min Latitude: " + getBottomDegrees() + "; Max Latitude: " + getTopDegrees()
|
+ "; Max Latitude: " + getTopDegrees() + "; Min Longitude: " + getLeftDegrees()
|
||||||
+ "; Min Longitude: " + getLeftDegrees() + "; Max Longitude: " + getRightDegrees()
|
+ "; Max Longitude: " + getRightDegrees() + "; Max Speed: " + getMaxSpeed()
|
||||||
+ "; Max Elevation: " + getMaxElevation() + "; Max Speed: " + getMaxSpeed()
|
|
||||||
+ "; Min Elevation: " + getMinElevation() + "; Max Elevation: " + getMaxElevation()
|
+ "; Min Elevation: " + getMinElevation() + "; Max Elevation: " + getMaxElevation()
|
||||||
+ "; Elevation Gain: " + getTotalElevationGain() + "; Min Grade: " + getMinGrade()
|
+ "; Elevation Gain: " + getTotalElevationGain() + "; Min Grade: " + getMinGrade()
|
||||||
+ "; Max Grade: " + getMaxGrade() + "}";
|
+ "; Max Grade: " + getMaxGrade() + "}";
|
||||||
|
|||||||
+9
-24
@@ -84,7 +84,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
|||||||
for (double elevation = 0; elevation < 1000; elevation += 10) {
|
for (double elevation = 0; elevation < 1000; elevation += 10) {
|
||||||
tripStatisticsUpdater = new TripStatisticsUpdater(System.currentTimeMillis());
|
tripStatisticsUpdater = new TripStatisticsUpdater(System.currentTimeMillis());
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
assertEquals(0.0, tripStatisticsUpdater.updateElevation(elevation));
|
tripStatisticsUpdater.updateElevation(elevation);
|
||||||
assertEquals(elevation, tripStatisticsUpdater.getSmoothedElevation());
|
assertEquals(elevation, tripStatisticsUpdater.getSmoothedElevation());
|
||||||
|
|
||||||
TripStatistics tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
TripStatistics tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||||
@@ -101,15 +101,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
|||||||
*/
|
*/
|
||||||
public void testElevationGain() throws Exception {
|
public void testElevationGain() throws Exception {
|
||||||
for (double i = 0; i < 1000; i++) {
|
for (double i = 0; i < 1000; i++) {
|
||||||
double expectedGain;
|
tripStatisticsUpdater.updateElevation(i);
|
||||||
if (i < TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR - 1) {
|
|
||||||
expectedGain = 0;
|
|
||||||
} else if (i < TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) {
|
|
||||||
expectedGain = 0.5;
|
|
||||||
} else {
|
|
||||||
expectedGain = 1.0;
|
|
||||||
}
|
|
||||||
assertEquals(expectedGain, tripStatisticsUpdater.updateElevation(i));
|
|
||||||
assertEquals(i, tripStatisticsUpdater.getSmoothedElevation(),
|
assertEquals(i, tripStatisticsUpdater.getSmoothedElevation(),
|
||||||
TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR / 2);
|
TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR / 2);
|
||||||
|
|
||||||
@@ -127,29 +119,22 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
|||||||
*/
|
*/
|
||||||
public void testGradeSimple() throws Exception {
|
public void testGradeSimple() throws Exception {
|
||||||
for (double i = 0; i < 1000; i++) {
|
for (double i = 0; i < 1000; i++) {
|
||||||
/*
|
|
||||||
* The value of the elevation does not matter. This is just to fill the
|
|
||||||
* elevation buffer.
|
|
||||||
*/
|
|
||||||
tripStatisticsUpdater.updateElevation(i);
|
|
||||||
tripStatisticsUpdater.updateGrade(100, 100);
|
tripStatisticsUpdater.updateGrade(100, 100);
|
||||||
if (i >= TripStatisticsUpdater.GRADE_SMOOTHING_FACTOR
|
if (i >= TripStatisticsUpdater.GRADE_SMOOTHING_FACTOR
|
||||||
&& i >= TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) {
|
&& i >= TripStatisticsUpdater.RISE_SMOOTHING_FACTOR
|
||||||
|
&& i >= TripStatisticsUpdater.RUN_SMOOTHING_FACTOR) {
|
||||||
assertEquals(1.0, tripStatisticsUpdater.getTripStatistics().getMaxGrade());
|
assertEquals(1.0, tripStatisticsUpdater.getTripStatistics().getMaxGrade());
|
||||||
assertEquals(1.0, tripStatisticsUpdater.getTripStatistics().getMinGrade());
|
assertEquals(1.0, tripStatisticsUpdater.getTripStatistics().getMinGrade());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (double i = 0; i < 1000; i++) {
|
for (double i = 0; i < 1000; i++) {
|
||||||
/*
|
|
||||||
* The value of the elevation does not matter. This is just to fill the
|
|
||||||
* elevation buffer.
|
|
||||||
*/
|
|
||||||
tripStatisticsUpdater.updateElevation(i);
|
|
||||||
tripStatisticsUpdater.updateGrade(100, -100);
|
tripStatisticsUpdater.updateGrade(100, -100);
|
||||||
if (i >= TripStatisticsUpdater.GRADE_SMOOTHING_FACTOR
|
if (i >= TripStatisticsUpdater.GRADE_SMOOTHING_FACTOR
|
||||||
&& i >= TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) {
|
&& i >= TripStatisticsUpdater.RISE_SMOOTHING_FACTOR
|
||||||
|
&& i >= TripStatisticsUpdater.RUN_SMOOTHING_FACTOR) {
|
||||||
assertEquals(1.0, tripStatisticsUpdater.getTripStatistics().getMaxGrade());
|
assertEquals(1.0, tripStatisticsUpdater.getTripStatistics().getMaxGrade());
|
||||||
assertEquals(-1.0, tripStatisticsUpdater.getTripStatistics().getMinGrade());
|
// add 0.1 delta since changing min grade from 1 to -1
|
||||||
|
assertEquals(-1.0, tripStatisticsUpdater.getTripStatistics().getMinGrade(), 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,7 +240,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
|||||||
|
|
||||||
// If there are only moving locations in the track.
|
// If there are only moving locations in the track.
|
||||||
if (locationOffset == 0
|
if (locationOffset == 0
|
||||||
&& (i + locationOffset) >= TripStatisticsUpdater.DISTANCE_SMOOTHING_FACTOR
|
&& (i + locationOffset) >= TripStatisticsUpdater.RUN_SMOOTHING_FACTOR
|
||||||
&& (i + locationOffset) >= TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) {
|
&& (i + locationOffset) >= TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) {
|
||||||
// 1 m / 111 m = .009
|
// 1 m / 111 m = .009
|
||||||
assertEquals(0.009, tripStatistics.getMinGrade(), 0.0001);
|
assertEquals(0.009, tripStatistics.getMinGrade(), 0.0001);
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ import junit.framework.Assert;
|
|||||||
* @author Youtao Liu
|
* @author Youtao Liu
|
||||||
*/
|
*/
|
||||||
public class EndToEndTestUtils {
|
public class EndToEndTestUtils {
|
||||||
public static int emulatorPort = 5556;
|
public static int emulatorPort = 5554;
|
||||||
// usually 5554.
|
// usually 5554.
|
||||||
private static final int ORIENTATION_PORTRAIT = 1;
|
private static final int ORIENTATION_PORTRAIT = 1;
|
||||||
private static final int ORIENTATION_LANDSCAPE = 0;
|
private static final int ORIENTATION_LANDSCAPE = 0;
|
||||||
|
|||||||
+2
-2
@@ -43,7 +43,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
|
|||||||
|
|
||||||
private final static String tracksName = "testTrackName1373523959524";
|
private final static String tracksName = "testTrackName1373523959524";
|
||||||
private final static String maxAltitude = "33.3";
|
private final static String maxAltitude = "33.3";
|
||||||
private final static String minAltitude = "33.3";
|
private final static String minAltitude = "22.2";
|
||||||
|
|
||||||
public ExportAllAndImportAllTest() {
|
public ExportAllAndImportAllTest() {
|
||||||
super(TrackListActivity.class);
|
super(TrackListActivity.class);
|
||||||
@@ -54,7 +54,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
|
|||||||
super.setUp();
|
super.setUp();
|
||||||
instrumentation = getInstrumentation();
|
instrumentation = getInstrumentation();
|
||||||
activityMyTracks = getActivity();
|
activityMyTracks = getActivity();
|
||||||
EndToEndTestUtils.setupForDebug(instrumentation, activityMyTracks);
|
EndToEndTestUtils.setupForAllTest(instrumentation, activityMyTracks);
|
||||||
trackNumber = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount();
|
trackNumber = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount();
|
||||||
EndToEndTestUtils.createTrackIfEmpty(1, true);
|
EndToEndTestUtils.createTrackIfEmpty(1, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user