forked from upstream-mirrors/OpenTracks
Code cleanup: reorg methods in TripStatistics
This commit is contained in:
@@ -73,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;
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -266,139 +360,6 @@ public class TripStatistics implements Parcelable {
|
|||||||
return maxSpeed;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the maximum speed.
|
* Sets the maximum speed.
|
||||||
*
|
*
|
||||||
@@ -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() + "}";
|
||||||
|
|||||||
Reference in New Issue
Block a user