public void Merge(TrailResultPoint t) { //Merge with later point, some fields kept this.Duration += t.Duration; if (this.LapInfo != null && t.LapInfo != null) { this.LapInfo = new LapInfo(this.LapInfo, t.LapInfo); } else if (t.LapInfo != null) { this.LapInfo = t.LapInfo; } if (this.PoolLengthInfo != null && t.PoolLengthInfo != null) { this.PoolLengthInfo = new PoolLengthInfo(this.PoolLengthInfo, t.PoolLengthInfo); } else if (t.PoolLengthInfo != null) { this.PoolLengthInfo = t.PoolLengthInfo; } foreach (TrailResultPoint t2 in t.SubPoints) { this.SubPoints.Add(t2); } }
public int CompareTo(object obj) { if (obj is TrailResultPoint) { TrailResultPoint t = obj as TrailResultPoint; if (this.DistDiff == t.DistDiff) { return(this.Time < t.Time ? -1 : 1); } return(this.DistDiff < t.DistDiff ? -1 : 1); } return(-1); }
public TrailResultPoint(TrailResultPoint t, TrailGPSLocation loc) : base(loc) { this.m_time = t.Time; //this.m_name = t.Name; this.DistDiff = t.DistDiff; this.Duration = t.Duration; this.LapInfo = t.LapInfo; this.PoolLengthInfo = t.PoolLengthInfo; this.Order = t.Order; foreach (TrailResultPoint t2 in t.SubPoints) { this.SubPoints.Add(t2); } }
public TrailResultInfo CopyFromReference(IActivity activity) { TrailResultInfo result = new TrailResultInfo(activity, this.Reverse); foreach (TrailResultPoint p in Points) { TrailGPSLocation loc; ZoneFiveSoftware.Common.Data.GPS.IGPSPoint t = Utils.TrackUtil.getGpsLoc(activity, p.Time); if (t != null) { loc = new TrailGPSLocation(t, p.Name, p.Required); } else { loc = new TrailGPSLocation(p.Name, p.Required); } TrailResultPoint p2 = new TrailResultPoint(p, loc); p2.LapInfo = null; p2.PoolLengthInfo = null; result.Points.Add(p2); } return(result); }
public static TrailResultInfo TrailResultInfoFromSplits(IActivity activity, bool onlyActiveLaps) { TrailResultInfo results = new TrailResultInfo(activity, false); if (activity == null) { //summary result return(results); } //Get around a problem with only Rest laps if (onlyActiveLaps) { onlyActiveLaps = false; for (int j = 0; j < activity.Laps.Count; j++) { if (!activity.Laps[j].Rest) { onlyActiveLaps = true; break; } } } bool lastIsRestlap = false; if (null == activity.Laps || 0 == activity.Laps.Count) { //Use MovingDistanceMetersTrack rather than ActualDistanceMetersTrack, assume similar activities have similar pauses/slow parts IDistanceDataTrack track = ActivityInfoCache.Instance.GetInfo(activity).MovingDistanceMetersTrack; if (track != null && track.Max > 0) { //Create some kind of points - could be dependent on length const float cDist = 1000; float dist = 0; while (dist < track.Max) { DateTime time = track.GetTimeAtDistanceMeters(dist); IGPSPoint p = Utils.TrackUtil.getGpsLoc(activity, time); if (p != null) { results.Points.Add(new TrailResultPoint(new TrailGPSLocation(p), time)); } else { if (activity.GPSRoute == null || activity.GPSRoute.Count == 0) { results.Points.Add(new TrailResultPoint(new TrailGPSLocation(activity.Name, true), time, track.TotalElapsedSeconds)); } else { System.Diagnostics.Debug.Assert(false, "out of GPS"); if (results.Points.Count > 0) { //end insert break; } } } dist = Math.Min(track.Max, dist + cDist); } } else { DateTime time = ActivityInfoCache.Instance.GetInfo(activity).ActualTrackStart; IGPSPoint p = Utils.TrackUtil.getGpsLoc(activity, time); if (p != null) { results.Points.Add(new TrailResultPoint(new TrailGPSLocation(p), time)); } } } else { int subresultIndex = 1; for (int j = 0; j < activity.Laps.Count; j++) { ILapInfo l = activity.Laps[j]; if (!onlyActiveLaps || !l.Rest || j > 0 && !activity.Laps[j - 1].Rest) { string name = l.Notes; if (string.IsNullOrEmpty(name)) { name = "#" + (results.Points.Count + 1); } DateTime d = l.StartTime; if (activity.GPSRoute == null || activity.GPSRoute.Count == 0) { results.Points.Add(new TrailResultPoint(new TrailGPSLocation(name, !l.Rest), d, l.TotalTime, l)); } else { IGPSPoint t = Utils.TrackUtil.getGpsLoc(activity, d); if (t != null) { results.Points.Add(new TrailResultPoint(new TrailGPSLocation(t, name, !l.Rest), d, l.TotalTime, l)); } } if (//All swim related have at least one PoolLength for each lap l.PoolLengths != null && (l.PoolLengths.Count > 0)) { TrailResultPoint tp = results.Points[results.Points.Count - 1]; foreach (IPoolLengthInfo p in l.PoolLengths) { DateTime d2 = p.StartTime; IPoolLengthInfo p1 = PoolLengthInfo.GetPoolLength(p); tp.SubPoints.Add(new TrailResultPoint(new TrailGPSLocation(null, !l.Rest), d2, p.TotalTime, p1, subresultIndex++)); } //Need (dummy) last point IPoolLengthInfo p2 = tp.SubPoints[tp.SubPoints.Count - 1].PoolLengthInfo; tp.SubPoints.Add(new TrailResultPoint(new TrailGPSLocation(null, !l.Rest), p2.StartTime + p2.TotalTime, TimeSpan.Zero, p2, subresultIndex)); } } } lastIsRestlap = activity.Laps[activity.Laps.Count - 1].Rest; } //Add end point, except if last is a rest lap (where last already is added) if (!onlyActiveLaps || !lastIsRestlap) { DateTime d = ActivityInfoCache.Instance.GetInfo(activity).ActualTrackEnd; if (activity.GPSRoute == null || activity.GPSRoute.Count == 0) { results.Points.Add(new TrailResultPoint(new TrailGPSLocation(activity.Name, !lastIsRestlap), d)); } else { IGPSPoint t = Utils.TrackUtil.getGpsLoc(activity, d); if (t != null) { results.Points.Add(new TrailResultPoint(new TrailGPSLocation(t, activity.Name, !lastIsRestlap), d)); } } } //Special for activities without any GPS info if (results.Count == 0 && activity.HasStartTime) { results.Points.Add(new TrailResultPoint(new TrailGPSLocation(activity.Name, true), activity.StartTime)); results.Points.Add(new TrailResultPoint(new TrailGPSLocation(activity.Name, true), activity.StartTime + activity.TotalTimeEntered)); } //A trail created from splits should not define elevation points foreach (TrailGPSLocation t in results.Points) { t.SetElevation(float.NaN); } return(results); }
public TrailResultPoint(TrailResultPoint t) : this(t, t) { }