Add pause_duration to statistics.

This commit is contained in:
voussoir 2023-03-26 19:31:30 -07:00
parent f7101ff83a
commit f62cebdfaf
2 changed files with 9 additions and 0 deletions

View file

@ -135,6 +135,7 @@ data class TrackStatistics(
val trkpts: ArrayList<Trkpt>, val trkpts: ArrayList<Trkpt>,
var distance: Double = 0.0, var distance: Double = 0.0,
var duration: Long = 0, var duration: Long = 0,
var pause_duration: Long = 0,
var velocity: Double = 0.0, var velocity: Double = 0.0,
var total_ascent: Double = 0.0, var total_ascent: Double = 0.0,
var total_descent: Double = 0.0, var total_descent: Double = 0.0,
@ -158,6 +159,13 @@ data class TrackStatistics(
min_altitude = trkpt.altitude min_altitude = trkpt.altitude
continue continue
} }
if (trkpt.time - previous.time > Keys.STOP_OVER_THRESHOLD)
{
pause_duration += (trkpt.time - previous.time)
previous = trkpt
last = trkpt
continue
}
distance += previous.toLocation().distanceTo(trkpt.toLocation()) distance += previous.toLocation().distanceTo(trkpt.toLocation())
val ascentdiff = trkpt.altitude - previous.altitude val ascentdiff = trkpt.altitude - previous.altitude
if (ascentdiff > 0) if (ascentdiff > 0)

View file

@ -504,6 +504,7 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
distanceView.text = LengthUnitHelper.convertDistanceToString(stats.distance, useImperialUnits) distanceView.text = LengthUnitHelper.convertDistanceToString(stats.distance, useImperialUnits)
waypointsView.text = track.trkpts.size.toString() waypointsView.text = track.trkpts.size.toString()
durationView.text = DateTimeHelper.convertToReadableTime(requireContext(), stats.duration) durationView.text = DateTimeHelper.convertToReadableTime(requireContext(), stats.duration)
recordingPausedView.text = DateTimeHelper.convertToReadableTime(requireContext(), stats.pause_duration)
velocityView.text = LengthUnitHelper.convertToVelocityString(stats.velocity, useImperialUnits) velocityView.text = LengthUnitHelper.convertToVelocityString(stats.velocity, useImperialUnits)
if (track.trkpts.isNotEmpty()) if (track.trkpts.isNotEmpty())
{ {