Merge heads

This commit is contained in:
youtaol
2012-08-27 10:31:25 +08:00
parent 3ef2a9c901
commit 9565e81dab
23 changed files with 1376 additions and 1638 deletions
@@ -27,14 +27,14 @@ import android.location.Location;
import android.util.Log;
/**
* Builder for {@link TripStatistics}. For keeping track statistics as new
* Updater for {@link TripStatistics}. For updating track trip statistics as new
* locations are added. Note that some of the locations represent pause/resume
* separator.
*
* @author Sandor Dornbush
* @author Rodrigo Damazio
*/
public class TripStatisticsBuilder {
public class TripStatisticsUpdater {
// The track's trip statistics
private final TripStatistics tripStatistics;
@@ -62,11 +62,11 @@ public class TripStatisticsBuilder {
private final DoubleBuffer gradeBuffer = new DoubleBuffer(Constants.GRADE_SMOOTHING_FACTOR);
/**
* Creates a new trip statistics builder.
* Creates a new trip statistics updater.
*
* @param startTime the start time
*/
public TripStatisticsBuilder(long startTime) {
public TripStatisticsUpdater(long startTime) {
tripStatistics = init(startTime);
currentSegment = init(startTime);
}
@@ -96,6 +96,10 @@ public class TripStatisticsBuilder {
if (!LocationUtils.isValidLocation(location)) {
updateTime(location.getTime());
if (location.getLatitude() == TrackRecordingService.PAUSE_LATITUDE) {
if (lastLocation != null && lastMovingLocation != null
&& lastLocation != lastMovingLocation) {
currentSegment.addTotalDistance(lastMovingLocation.distanceTo(lastLocation));
}
tripStatistics.merge(currentSegment);
}
currentSegment = init(location.getTime());