mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
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"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="68"
|
||||
android:versionCode="69"
|
||||
android:versionName="2.0.5"
|
||||
package="com.google.android.maps.mytracks" >
|
||||
<!-- 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) {
|
||||
this.valid = LocationUtils.isValidLocation(location);
|
||||
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;
|
||||
} else {
|
||||
hasFix = !LocationUtils.isLocationOld(currentLocation);
|
||||
hasGoodFix = currentLocation.getAccuracy() <= recordingGpsAccuracy;
|
||||
hasGoodFix = currentLocation.hasAccuracy()
|
||||
&& currentLocation.getAccuracy() < recordingGpsAccuracy;
|
||||
}
|
||||
if (!hasFix) {
|
||||
message = getString(R.string.gps_wait_for_signal);
|
||||
|
||||
@@ -148,7 +148,8 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
||||
|
||||
if (lastLocation != null) {
|
||||
boolean hasFix = !LocationUtils.isLocationOld(lastLocation);
|
||||
boolean hasGoodFix = lastLocation.getAccuracy() <= recordingGpsAccuracy;
|
||||
boolean hasGoodFix = lastLocation.hasAccuracy()
|
||||
&& lastLocation.getAccuracy() < recordingGpsAccuracy;
|
||||
|
||||
if (!hasFix || !hasGoodFix) {
|
||||
lastLocation = null;
|
||||
|
||||
@@ -888,7 +888,7 @@ public class TrackRecordingService extends Service {
|
||||
return;
|
||||
}
|
||||
|
||||
if (location.getAccuracy() > recordingGpsAccuracy) {
|
||||
if (!location.hasAccuracy() || location.getAccuracy() >= recordingGpsAccuracy) {
|
||||
Log.d(TAG, "Ignore onLocationChangedAsync. Poor accuracy.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,12 +35,6 @@ import android.util.Log;
|
||||
*/
|
||||
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
|
||||
* signal.
|
||||
@@ -48,6 +42,18 @@ public class TripStatisticsUpdater {
|
||||
@VisibleForTesting
|
||||
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.
|
||||
*/
|
||||
@@ -67,7 +73,7 @@ public class TripStatisticsUpdater {
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
private static final double MAX_ACCELERATION = 0.02;
|
||||
@@ -84,18 +90,21 @@ public class TripStatisticsUpdater {
|
||||
// Current segment's last moving location
|
||||
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)
|
||||
private final DoubleBuffer elevationBuffer = new DoubleBuffer(ELEVATION_SMOOTHING_FACTOR);
|
||||
|
||||
// A buffer of the recent distance readings (m) for calculating grade
|
||||
private final DoubleBuffer distanceBuffer = new DoubleBuffer(DISTANCE_SMOOTHING_FACTOR);
|
||||
// A buffer of the recent run readings (m) for calculating grade
|
||||
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 (%)
|
||||
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.
|
||||
*
|
||||
@@ -128,8 +137,11 @@ public class TripStatisticsUpdater {
|
||||
* @param minRecordingDistance the min recording distance
|
||||
*/
|
||||
public void addLocation(Location location, int minRecordingDistance) {
|
||||
// Always update time
|
||||
updateTime(location.getTime());
|
||||
|
||||
if (!LocationUtils.isValidLocation(location)) {
|
||||
updateTime(location.getTime());
|
||||
// Either pause or resume marker
|
||||
if (location.getLatitude() == TrackRecordingService.PAUSE_LATITUDE) {
|
||||
if (lastLocation != null && lastMovingLocation != null
|
||||
&& lastLocation != lastMovingLocation) {
|
||||
@@ -140,40 +152,58 @@ public class TripStatisticsUpdater {
|
||||
currentSegment = init(location.getTime());
|
||||
lastLocation = null;
|
||||
lastMovingLocation = null;
|
||||
speedBuffer.reset();
|
||||
elevationBuffer.reset();
|
||||
distanceBuffer.reset();
|
||||
runBuffer.reset();
|
||||
riseBuffer.reset();
|
||||
gradeBuffer.reset();
|
||||
speedBuffer.reset();
|
||||
return;
|
||||
}
|
||||
double elevationDifference = updateElevation(location.getAltitude());
|
||||
currentSegment.updateLatitudeExtremities(location.getLatitude());
|
||||
currentSegment.updateLongitudeExtremities(location.getLongitude());
|
||||
|
||||
if (location.hasAltitude()) {
|
||||
updateElevation(location.getAltitude());
|
||||
}
|
||||
|
||||
if (lastLocation == null || lastMovingLocation == null) {
|
||||
updateTime(location.getTime());
|
||||
lastLocation = location;
|
||||
lastMovingLocation = location;
|
||||
return;
|
||||
}
|
||||
|
||||
double movingDistance = lastMovingLocation.distanceTo(location);
|
||||
if (movingDistance < minRecordingDistance && location.getSpeed() < MAX_NO_MOVEMENT_SPEED) {
|
||||
updateTime(location.getTime());
|
||||
lastLocation = location;
|
||||
return;
|
||||
if (movingDistance < minRecordingDistance) {
|
||||
if (!location.hasSpeed() || location.getSpeed() < MAX_NO_MOVEMENT_SPEED) {
|
||||
lastLocation = location;
|
||||
return;
|
||||
}
|
||||
}
|
||||
long movingTime = location.getTime() - lastLocation.getTime();
|
||||
if (movingTime < 0) {
|
||||
updateTime(location.getTime());
|
||||
lastLocation = location;
|
||||
return;
|
||||
}
|
||||
|
||||
// Update total distance
|
||||
currentSegment.addTotalDistance(movingDistance);
|
||||
|
||||
// Update moving time
|
||||
currentSegment.addMovingTime(movingTime);
|
||||
updateSpeed(
|
||||
location.getTime(), location.getSpeed(), lastLocation.getTime(), lastLocation.getSpeed());
|
||||
updateGrade(lastLocation.distanceTo(location), elevationDifference);
|
||||
updateTime(location.getTime());
|
||||
|
||||
// Update grade
|
||||
if (location.hasAltitude() && lastLocation.hasAltitude()) {
|
||||
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;
|
||||
lastMovingLocation = location;
|
||||
}
|
||||
@@ -217,38 +247,46 @@ public class TripStatisticsUpdater {
|
||||
* @param elevation the elevation
|
||||
*/
|
||||
@VisibleForTesting
|
||||
double updateElevation(double elevation) {
|
||||
void updateElevation(double elevation) {
|
||||
currentSegment.updateElevationExtremities(elevation);
|
||||
|
||||
// update elevation gain
|
||||
double oldAverage = elevationBuffer.getAverage();
|
||||
elevationBuffer.setNext(elevation);
|
||||
double newAverage = elevationBuffer.getAverage();
|
||||
currentSegment.updateElevationExtremities(newAverage);
|
||||
double elevationDifference = elevationBuffer.isFull() ? newAverage - oldAverage : 0.0;
|
||||
if (elevationDifference > 0) {
|
||||
currentSegment.addTotalElevationGain(elevationDifference);
|
||||
if (elevationBuffer.isFull()) {
|
||||
double difference = newAverage - oldAverage;
|
||||
if (difference > 0) {
|
||||
currentSegment.addTotalElevationGain(difference);
|
||||
}
|
||||
}
|
||||
return elevationDifference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a grade reading.
|
||||
*
|
||||
* @param distance the distance the user just traveled
|
||||
* @param elevationDifference the elevation difference between the current
|
||||
* reading and the previous reading
|
||||
* @param run the run
|
||||
* @param rise the rise
|
||||
*/
|
||||
@VisibleForTesting
|
||||
void updateGrade(double distance, double elevationDifference) {
|
||||
distanceBuffer.setNext(distance);
|
||||
double smoothedDistance = distanceBuffer.getAverage();
|
||||
void updateGrade(double run, double rise) {
|
||||
runBuffer.setNext(run);
|
||||
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
|
||||
* anything less than 5.
|
||||
*/
|
||||
if (!elevationBuffer.isFull() || !distanceBuffer.isFull() || smoothedDistance < 5.0) {
|
||||
if (smoothedRun < 5.0) {
|
||||
return;
|
||||
}
|
||||
gradeBuffer.setNext(elevationDifference / smoothedDistance);
|
||||
gradeBuffer.setNext(riseBuffer.getAverage() / smoothedRun);
|
||||
currentSegment.updateGradeExtremities(gradeBuffer.getAverage());
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ public class StatsUtils {
|
||||
activity, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT);
|
||||
|
||||
// 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,
|
||||
metricUnits, reportSpeed);
|
||||
|
||||
@@ -65,7 +66,8 @@ public class StatsUtils {
|
||||
View elevation = activity.findViewById(R.id.stats_elevation);
|
||||
|
||||
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);
|
||||
setElevationValue(activity, R.id.stats_elevation, -1, altitude, metricUnits);
|
||||
} else {
|
||||
@@ -79,8 +81,8 @@ public class StatsUtils {
|
||||
View coordinateContainer = activity.findViewById(R.id.stats_coordinate_container);
|
||||
|
||||
if (showCoordinate && isRecording) {
|
||||
double latitude = location == null ? Double.NaN : location.getLatitude();
|
||||
double longitude = location == null ? Double.NaN : location.getLongitude();
|
||||
double latitude = location != null ? location.getLatitude() : Double.NaN;
|
||||
double longitude = location != null ? location.getLongitude() : Double.NaN;
|
||||
coordinateHorizontalLine.setVisibility(View.VISIBLE);
|
||||
coordinateContainer.setVisibility(View.VISIBLE);
|
||||
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
|
||||
*/
|
||||
public TripStatistics(TripStatistics other) {
|
||||
this.startTime = other.startTime;
|
||||
this.stopTime = other.stopTime;
|
||||
this.totalDistance = other.totalDistance;
|
||||
this.totalTime = other.totalTime;
|
||||
this.movingTime = other.movingTime;
|
||||
this.latitudeExtremities.set(
|
||||
other.latitudeExtremities.getMin(), other.latitudeExtremities.getMax());
|
||||
this.longitudeExtremities.set(
|
||||
startTime = other.startTime;
|
||||
stopTime = other.stopTime;
|
||||
totalDistance = other.totalDistance;
|
||||
totalTime = other.totalTime;
|
||||
movingTime = other.movingTime;
|
||||
latitudeExtremities.set(other.latitudeExtremities.getMin(), other.latitudeExtremities.getMax());
|
||||
longitudeExtremities.set(
|
||||
other.longitudeExtremities.getMin(), other.longitudeExtremities.getMax());
|
||||
this.maxSpeed = other.maxSpeed;
|
||||
this.elevationExtremities.set(
|
||||
maxSpeed = other.maxSpeed;
|
||||
elevationExtremities.set(
|
||||
other.elevationExtremities.getMin(), other.elevationExtremities.getMax());
|
||||
this.totalElevationGain = other.totalElevationGain;
|
||||
this.gradeExtremities.set(other.gradeExtremities.getMin(), other.gradeExtremities.getMax());
|
||||
totalElevationGain = other.totalElevationGain;
|
||||
gradeExtremities.set(other.gradeExtremities.getMin(), other.gradeExtremities.getMax());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,6 +127,15 @@ public class TripStatistics implements Parcelable {
|
||||
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.
|
||||
*/
|
||||
@@ -135,6 +143,15 @@ public class TripStatistics implements Parcelable {
|
||||
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.
|
||||
*/
|
||||
@@ -142,6 +159,24 @@ public class TripStatistics implements Parcelable {
|
||||
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
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -159,6 +203,24 @@ public class TripStatistics implements Parcelable {
|
||||
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
|
||||
* degrees.
|
||||
@@ -237,6 +299,38 @@ public class TripStatistics implements Parcelable {
|
||||
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
|
||||
* 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.
|
||||
*/
|
||||
public double getMaxSpeed() {
|
||||
return 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
return Math.max(maxSpeed, getAverageMovingSpeed());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,6 +369,14 @@ public class TripStatistics implements Parcelable {
|
||||
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.
|
||||
*
|
||||
@@ -417,6 +386,14 @@ public class TripStatistics implements Parcelable {
|
||||
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.
|
||||
*
|
||||
@@ -431,10 +408,18 @@ public class TripStatistics implements Parcelable {
|
||||
*
|
||||
* @param elevation the elevation value in meters
|
||||
*/
|
||||
void updateElevationExtremities(double elevation) {
|
||||
public void updateElevationExtremities(double 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.
|
||||
*
|
||||
@@ -449,17 +434,15 @@ public class TripStatistics implements Parcelable {
|
||||
*
|
||||
* @param gain the elevation gain in meters
|
||||
*/
|
||||
void addTotalElevationGain(double gain) {
|
||||
public void addTotalElevationGain(double gain) {
|
||||
totalElevationGain += gain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum grade.
|
||||
*
|
||||
* @param grade the grade as a fraction (-1.0 would mean vertical downwards)
|
||||
* Gets the minimum grade for this trip.
|
||||
*/
|
||||
public void setMinGrade(double grade) {
|
||||
gradeExtremities.setMin(grade);
|
||||
public double getMinGrade() {
|
||||
return gradeExtremities.getMin();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -471,23 +454,38 @@ public class TripStatistics implements Parcelable {
|
||||
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.
|
||||
*
|
||||
* @param grade the grade value as a fraction
|
||||
*/
|
||||
void updateGradeExtremities(double grade) {
|
||||
public void updateGradeExtremities(double grade) {
|
||||
gradeExtremities.update(grade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TripStatistics { Start Time: " + getStartTime() + "; Stop Time: " + getStopTime()
|
||||
+ "; Total Time: " + getTotalTime() + "; Total Distance: " + getTotalDistance()
|
||||
+ "; Total Time: " + getTotalTime() + "; Moving Time: " + getMovingTime()
|
||||
+ "; Min Latitude: " + getBottomDegrees() + "; Max Latitude: " + getTopDegrees()
|
||||
+ "; Min Longitude: " + getLeftDegrees() + "; Max Longitude: " + getRightDegrees()
|
||||
+ "; Max Elevation: " + getMaxElevation() + "; Max Speed: " + getMaxSpeed()
|
||||
+ "; Total Distance: " + getTotalDistance() + "; Total Time: " + getTotalTime()
|
||||
+ "; Moving Time: " + getMovingTime() + "; Min Latitude: " + getBottomDegrees()
|
||||
+ "; Max Latitude: " + getTopDegrees() + "; Min Longitude: " + getLeftDegrees()
|
||||
+ "; Max Longitude: " + getRightDegrees() + "; Max Speed: " + getMaxSpeed()
|
||||
+ "; Min Elevation: " + getMinElevation() + "; Max Elevation: " + getMaxElevation()
|
||||
+ "; Elevation Gain: " + getTotalElevationGain() + "; Min Grade: " + getMinGrade()
|
||||
+ "; Max Grade: " + getMaxGrade() + "}";
|
||||
|
||||
+9
-24
@@ -84,7 +84,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
||||
for (double elevation = 0; elevation < 1000; elevation += 10) {
|
||||
tripStatisticsUpdater = new TripStatisticsUpdater(System.currentTimeMillis());
|
||||
for (int i = 0; i < 100; i++) {
|
||||
assertEquals(0.0, tripStatisticsUpdater.updateElevation(elevation));
|
||||
tripStatisticsUpdater.updateElevation(elevation);
|
||||
assertEquals(elevation, tripStatisticsUpdater.getSmoothedElevation());
|
||||
|
||||
TripStatistics tripStatistics = tripStatisticsUpdater.getTripStatistics();
|
||||
@@ -101,15 +101,7 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
||||
*/
|
||||
public void testElevationGain() throws Exception {
|
||||
for (double i = 0; i < 1000; i++) {
|
||||
double expectedGain;
|
||||
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));
|
||||
tripStatisticsUpdater.updateElevation(i);
|
||||
assertEquals(i, tripStatisticsUpdater.getSmoothedElevation(),
|
||||
TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR / 2);
|
||||
|
||||
@@ -127,29 +119,22 @@ public class TripStatisticsUpdaterTest extends TestCase {
|
||||
*/
|
||||
public void testGradeSimple() throws Exception {
|
||||
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);
|
||||
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().getMinGrade());
|
||||
}
|
||||
}
|
||||
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);
|
||||
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().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 (locationOffset == 0
|
||||
&& (i + locationOffset) >= TripStatisticsUpdater.DISTANCE_SMOOTHING_FACTOR
|
||||
&& (i + locationOffset) >= TripStatisticsUpdater.RUN_SMOOTHING_FACTOR
|
||||
&& (i + locationOffset) >= TripStatisticsUpdater.ELEVATION_SMOOTHING_FACTOR) {
|
||||
// 1 m / 111 m = .009
|
||||
assertEquals(0.009, tripStatistics.getMinGrade(), 0.0001);
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ import junit.framework.Assert;
|
||||
* @author Youtao Liu
|
||||
*/
|
||||
public class EndToEndTestUtils {
|
||||
public static int emulatorPort = 5556;
|
||||
public static int emulatorPort = 5554;
|
||||
// usually 5554.
|
||||
private static final int ORIENTATION_PORTRAIT = 1;
|
||||
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 maxAltitude = "33.3";
|
||||
private final static String minAltitude = "33.3";
|
||||
private final static String minAltitude = "22.2";
|
||||
|
||||
public ExportAllAndImportAllTest() {
|
||||
super(TrackListActivity.class);
|
||||
@@ -54,7 +54,7 @@ public class ExportAllAndImportAllTest extends ActivityInstrumentationTestCase2<
|
||||
super.setUp();
|
||||
instrumentation = getInstrumentation();
|
||||
activityMyTracks = getActivity();
|
||||
EndToEndTestUtils.setupForDebug(instrumentation, activityMyTracks);
|
||||
EndToEndTestUtils.setupForAllTest(instrumentation, activityMyTracks);
|
||||
trackNumber = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class).get(0).getCount();
|
||||
EndToEndTestUtils.createTrackIfEmpty(1, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user