/// <summary> /// Used to generate the record properties of the supplied activity /// </summary> /// <param name="activity">The full activity for the record</param> /// <param name="category">The Record Category for this record</param> /// <param name="gpsTrack">The GPS route of the actual record</param> /// <param name="hrTrack">The HR track of the actual record</param> /// <param name="pwrTrack">The power track of the actual record</param> /// <param name="cadTrack">The cadence track of the actual record</param> public Record(IActivity activity, RecordCategory category, IGPSRoute gpsTrack, INumericTimeDataSeries hrTrack, INumericTimeDataSeries pwrTrack, INumericTimeDataSeries cadTrack, IDistanceDataTrack distTrack, INumericTimeDataSeries elevTrack, DateTime activityStartTime) { // Create new activity from template IActivity recActivity = (IActivity)Activator.CreateInstance(activity.GetType()); // HACK: Manually Clone 'activity' until a better way is found recActivity.Category = activity.Category; recActivity.DistanceMetersTrack = distTrack; recActivity.ElevationMetersTrack = elevTrack; recActivity.GPSRoute = gpsTrack; recActivity.HasStartTime = activity.HasStartTime; recActivity.HeartRatePerMinuteTrack = hrTrack; recActivity.Intensity = activity.Intensity; recActivity.Location = activity.Location; recActivity.Name = activity.Name; recActivity.PowerWattsTrack = pwrTrack; recActivity.CadencePerMinuteTrack = cadTrack; recActivity.Weather.Conditions = activity.Weather.Conditions; recActivity.Weather.CurentDirectionDegrees = activity.Weather.CurentDirectionDegrees; recActivity.Weather.CurentSpeedKilometersPerHour = activity.Weather.CurentSpeedKilometersPerHour; recActivity.Weather.HumidityPercent = activity.Weather.HumidityPercent; recActivity.Weather.TemperatureCelsius = activity.Weather.TemperatureCelsius; recActivity.Weather.WindDirectionDegrees = activity.Weather.WindDirectionDegrees; recActivity.Weather.WindSpeedKilometersPerHour = activity.Weather.WindSpeedKilometersPerHour; // Set the start time for the record activity recActivity.StartTime = activityStartTime; // Set up the activity info for pulling summary data ActivityInfo info = ActivityInfoCache.Instance.GetInfo(recActivity); // Set the record category this.category = category; // Max and Min elevation seen over the route float maxE = float.NegativeInfinity; float minE = float.PositiveInfinity; if (activity.GPSRoute != null && activity.GPSRoute.Count > 0) { GPSRoute startRoute = new GPSRoute(); for (int i = 0; i < activity.GPSRoute.Count; i++) { GPSPoint p = (GPSPoint)activity.GPSRoute[i].Value; if (p.ElevationMeters > maxE) { maxE = p.ElevationMeters; } if (p.ElevationMeters < minE) { minE = p.ElevationMeters; } if (gpsTrack.Count == 0) { break; } if (p.Equals((GPSPoint)gpsTrack[0].Value)) { break; } else { startRoute.Add(activity.GPSRoute.EntryDateTime(activity.GPSRoute[i]), p); } } startDistance = startRoute.TotalDistanceMeters; } else if (activity.ElevationMetersTrack != null) { for (int i = 0; i < activity.ElevationMetersTrack.Count; i++) { if (activity.ElevationMetersTrack[i].Value > maxE) { maxE = activity.ElevationMetersTrack[i].Value; } if (activity.ElevationMetersTrack[i].Value < maxE) { minE = activity.ElevationMetersTrack[i].Value; } } startDistance = 0; } this.maxElevation = maxE; this.minElevation = minE; this.trueStartDate = activity.StartTime; this.activity = recActivity; }