Exemple #1
0
        public void CalculateBounds()
        {
            _boundsField = new BoundsEx();
            WayPoint wpt = trkptField[0];
            _boundsField.ElevationMaximum = _boundsField.ElevationMinimum = wpt.Elevation;
            _boundsField.EndTime = _boundsField.StartTime = wpt.Time;
            _boundsField.SetLatitudeMaximum(wpt.Latitude);
            _boundsField.SetLatitudeMinimum(wpt.Latitude);
            _boundsField.SetLongitudeMaximum(wpt.Longitude);
            _boundsField.SetLongitudeMinimum(wpt.Longitude);

            for (int i = 1; i < trkptField.Count; i++)
            {
                wpt = trkptField[i];
                if (_boundsField.ElevationMaximum < wpt.Elevation)
                    _boundsField.ElevationMaximum = wpt.Elevation;
                if (_boundsField.ElevationMinimum > wpt.Elevation)
                    _boundsField.ElevationMinimum = wpt.Elevation;
                if (_boundsField.EndTime < wpt.Time)
                    _boundsField.EndTime = wpt.Time;
                if (_boundsField.LatitudeMaximum < wpt.Latitude)
                    _boundsField.SetLatitudeMaximum(wpt.Latitude);
                if (_boundsField.LatitudeMinimum > wpt.Latitude)
                    _boundsField.SetLatitudeMinimum(wpt.Latitude);
                if (_boundsField.LongitudeMaximum < wpt.Longitude)
                    _boundsField.SetLongitudeMaximum(wpt.Longitude);
                if (_boundsField.LongitudeMinimum > wpt.Longitude)
                    _boundsField.SetLongitudeMinimum(wpt.Longitude);
                if (_boundsField.StartTime > wpt.Time)
                    _boundsField.StartTime = wpt.Time;
            }
        }
Exemple #2
0
        public void Recalculate()
        {
            _TrackLength = 0;
            _MaximumSpeed = 0;
            _Duration = new TimeSpan(0);
            _boundsField = null;

            foreach (TrackSegment seg in trksegField)
            {
                seg.Recalculate();
                _TrackLength += seg.GetSegmentLength();
                _Duration += seg.GetDuration();
                if (_MaximumSpeed < seg.GetMaximumSpeed())
                    _MaximumSpeed = seg.GetMaximumSpeed();

            }
        }
Exemple #3
0
 public void CalculateBounds()
 {
     _boundsField = trksegField[0].TrackBounds;
     for (int i = 1; i < trksegField.Count; i++)
     {
         BoundsEx bounds = trksegField[i].TrackBounds;
         if (_boundsField.ElevationMaximum < bounds.ElevationMaximum)
             _boundsField.ElevationMaximum = bounds.ElevationMaximum;
         if (_boundsField.ElevationMinimum > bounds.ElevationMinimum)
             _boundsField.ElevationMinimum = bounds.ElevationMinimum;
         if (_boundsField.EndTime < bounds.EndTime)
             _boundsField.EndTime = bounds.EndTime;
         if (_boundsField.LatitudeMaximum < bounds.LatitudeMaximum)
             _boundsField.LatitudeMaximum = bounds.LatitudeMaximum;
         if (_boundsField.LatitudeMinimum > bounds.LatitudeMinimum)
             _boundsField.LatitudeMinimum = bounds.LatitudeMinimum;
         if (_boundsField.LongitudeMaximum < bounds.LongitudeMaximum)
             _boundsField.LongitudeMaximum = bounds.LongitudeMaximum;
         if (_boundsField.LongitudeMinimum > bounds.LongitudeMinimum)
             _boundsField.LongitudeMinimum = bounds.LongitudeMinimum;
         if (_boundsField.StartTime > bounds.StartTime)
             _boundsField.StartTime = bounds.StartTime;
     }
 }
Exemple #4
0
        ///// <summary>
        ///// Returns the duration of the segment in seconds.
        ///// </summary>
        //public int GetDurationSeconds()
        //{
        //    if ((_LastWayPoint != null) /*&& (_LastWayPoint.timeSpecified)*/
        //        && (_FirstWayPoint != null) /*&& (_FirstWayPoint.timeSpecified)*/)
        //    {
        //        TimeSpan ts =_LastWayPoint.Time.Subtract(_FirstWayPoint.Time);
        //        return Convert.ToInt32(ts.Ticks / Utils.TicksPerSecond);
        //    }
        //    else
        //        return 0;
        //}

        public void Recalculate()
        {
            bool throwTimeTravelException = false;
            string setting = System.Configuration.ConfigurationManager.AppSettings["ThrowTimeTravelException"];
            bool.TryParse(setting, out throwTimeTravelException);

            _boundsField = null;
            ConnectWayPoints();

            _SegmentLength = 0;
            _MaximumSpeed = 0;
            _TotalAscent = 0;
            _TotalDescent = 0;
            //helper for ascent and descent
            decimal eMax = _FirstWayPoint.Elevation;
            decimal eMin = _FirstWayPoint.Elevation;
            decimal eLast = _FirstWayPoint.Elevation;
            decimal threashold = 2.5M;
            DateTime lastDateTime = _FirstWayPoint.Time;

            foreach (WayPoint wp in trkptField)
            {
                wp.Recalculate();
                wp.RelateToStartPoint(ref _FirstWayPoint);
                _SegmentLength += wp.GetDistance();
                if (_MaximumSpeed < wp.GetSpeed())
                    _MaximumSpeed = wp.GetSpeed();

                if (eLast > wp.Elevation + threashold)
                {
                    _TotalDescent = _TotalDescent + Convert.ToDouble(eLast - wp.Elevation);
                    eLast = wp.Elevation;
                }
                else if (eLast < wp.Elevation - threashold)
                {
                    _TotalAscent = _TotalAscent + Convert.ToDouble(wp.Elevation - eLast);
                    eLast = wp.Elevation;
                }

                if (throwTimeTravelException && (wp.Time < lastDateTime))
                {
                    throw new ApplicationException(string.Format("You are a time traveller, aren't you?\r\n{0}>{1}", lastDateTime, wp.Time));
                }
                lastDateTime = wp.Time;
            }
        }