Exemplo n.º 1
0
        private void ComputeStatistics()
        {
            TrackStatistics trackStatistics = new TrackStatistics();

            for (int i = 0; i < Waypoints.Count - 1; i++)
            {
                Waypoint w1       = Waypoints[i];
                Waypoint w2       = Waypoints[i + 1];
                double   distance = Waypoint.ComputeDistance(w1, w2, out double elevationChange);
                if (elevationChange < 0)
                {
                    trackStatistics.AbsoluteDescent -= elevationChange;
                }
                else
                {
                    trackStatistics.AbsoluteClimb += elevationChange;
                }
                TimeSpan timeBetween = w2.Time - w1.Time;
                w1.Speed = distance / (1000.0 * timeBetween.TotalHours);
                if (w1.Speed > motionSpeedThreshold)
                {
                    trackStatistics.TimeInMotion += timeBetween;
                }
                trackStatistics.Length += distance;
            }
            trackStatistics.Length /= 1000; // convert to km
            TimeSpan duration = Waypoints[Waypoints.Count - 1].Time - Waypoints[0].Time;

            trackStatistics.AverageSpeed         = trackStatistics.Length / duration.TotalHours;
            trackStatistics.AverageSpeedInMotion = trackStatistics.Length / trackStatistics.TimeInMotion.TotalHours;
            statisics = trackStatistics;
        }
Exemplo n.º 2
0
 /// <summary>
 /// If waypoints are altered manually, previously computed track statistics might become invalid and you need to call this method.
 /// </summary>
 public void ResetStatistics()
 {
     this.statisics = null;
 }