Merge heads

This commit is contained in:
youtaol
2012-08-24 12:42:57 +08:00
parent bc37316fa5
commit 9859e4ff14
14 changed files with 373 additions and 345 deletions
@@ -145,11 +145,14 @@ public class TripStatisticsBuilder {
* is noisy so the smoothed elevation is better than the raw elevation for
* many tasks.
*/
@VisibleForTesting
double getSmoothedElevation() {
public double getSmoothedElevation() {
return elevationBuffer.getAverage();
}
public double getSmoothedSpeed() {
return speedBuffer.getAverage();
}
/**
* Updates a speed reading. Assumes the user is moving.
*
@@ -160,7 +163,7 @@ public class TripStatisticsBuilder {
*/
@VisibleForTesting
void updateSpeed(long time, double speed, long lastLocationTime, double lastLocationSpeed) {
if (!isValidSpeed(time, speed, lastLocationTime, lastLocationSpeed, speedBuffer)) {
if (!isValidSpeed(time, speed, lastLocationTime, lastLocationSpeed)) {
Log.d(TAG, "Invalid speed. speed: " + speed + " lastLocationSpeed: " + lastLocationSpeed);
return;
}
@@ -168,10 +171,6 @@ public class TripStatisticsBuilder {
if (speed > currentSegment.getMaxSpeed()) {
currentSegment.setMaxSpeed(speed);
}
double movingSpeed = currentSegment.getAverageMovingSpeed();
if (speedBuffer.isFull() && movingSpeed > currentSegment.getMaxSpeed()) {
currentSegment.setMaxSpeed(movingSpeed);
}
}
/**
@@ -229,10 +228,9 @@ public class TripStatisticsBuilder {
* @param speed the speed
* @param lastLocationTime the last location time
* @param lastLocationSpeed the last location speed
* @param speedBuffer a buffer of speed readings
*/
public static boolean isValidSpeed(long time, double speed, long lastLocationTime,
double lastLocationSpeed, DoubleBuffer speedBuffer) {
private boolean isValidSpeed(
long time, double speed, long lastLocationTime, double lastLocationSpeed) {
/*
* There are a lot of noisy speed readings. Do the cheapest checks first,