//private long AddGeneratedActivity(EventCluster ec, int eventCount, DataTable photos) private long AddGeneratedActivity(EventCluster ec, int eventCount, string genedName) { Activity act = new Activity(); //DataRow p1 = photos.Rows[ec.ecIndex1]; //string[] parts1 = p1["dateTaken"].ToString().Split('^'); //DataRow p2 = photos.Rows[ec.ecIndex2]; //string[] parts2 = p2["dateTaken"].ToString().Split('^'); act.ActivityKind = "Generated"; //act.EndDate = (DateTime)p2["dateTaken"]; act.EndDate = ec.endTime; act.Source = "LinearClusterIndexer"; act.SourceId = genedName + eventCount.ToString(); act.ActivityName = genedName + eventCount.ToString(); act.Latitude = 0; act.Longitude = 0; TimePeriod tpStart = new TimePeriod(); tpStart.Year = (short)act.StartDate.Year; tpStart.Month = (short)act.StartDate.Month; tpStart.Hour = (short)act.StartDate.Hour; tpStart.Day = act.StartDate.DayOfWeek.ToString(); tpStart.DayNumber = (short)act.StartDate.Day; //tpStart.AltKey = Convert.ToDateTime(parts1[0]); tpStart.AltKey = ec.startTime; act.StartDate = tpStart.AltKey; TimePeriod tpEnd = new TimePeriod(); tpEnd.Year = (short)act.EndDate.Year; tpEnd.Month = (short)act.EndDate.Month; tpEnd.Hour = (short)act.EndDate.Hour; tpEnd.Day = act.EndDate.DayOfWeek.ToString(); tpEnd.DayNumber = (short)act.EndDate.Day; //tpEnd.AltKey = Convert.ToDateTime(parts1[0]); tpEnd.AltKey = ec.endTime; //act.StartDate = tpEnd.AltKey; Address loc = new Address(); //return _store.AddActivity(_userId, act, tpStart, tpEnd, loc); return _store.AddActivity(_userId, act, tpStart, tpEnd, loc); }
private List<EventCluster> BuildEventClusterListFromPhotos(DataTable photos, double[] diffs, int windowSize, double K) { double localGapMean = 0; int lastClusterIndex = 0; List<EventCluster> gapList = new List<EventCluster>(); int rowCount = photos.Rows.Count; // ignore the first _diff value as it will always be zero for (int i = 1; i < rowCount; i++) { localGapMean = CalculateLocalGapMean(i, diffs, windowSize, rowCount); if (Math.Log(diffs[i]) >= K + localGapMean) { EventCluster ec = new EventCluster(); ec.diffIndex = i; ec.ecIndex1 = lastClusterIndex; ec.ecIndex2 = i - 1; DataRow dr = photos.Rows[ec.ecIndex1]; ec.startTime = (DateTime)dr["datetaken"]; dr = photos.Rows[ec.ecIndex2]; ec.endTime = (DateTime)dr["datetaken"]; lastClusterIndex = i; gapList.Add(ec); } } return gapList; }
private List<EventCluster> BuildEventClusterListFromEventClusters(List<EventCluster> ecList, double[] diffs, int windowSize, double K) { double localGapMean = 0; int lastClusterIndex = 0; List<EventCluster> gapList = new List<EventCluster>(); int eventCount = ecList.Count; // ignore the first _diff value as it will always be zero for (int i = 1; i < eventCount; i++) { localGapMean = CalculateLocalGapMean(i, diffs, windowSize, eventCount); if (Math.Log(diffs[i]) >= K + localGapMean) { EventCluster ec = new EventCluster(); ec.diffIndex = i; ec.ecIndex1 = lastClusterIndex; ec.ecIndex2 = i - 1; EventCluster first = ecList[ec.ecIndex1]; ec.startTime = first.startTime; EventCluster second = ecList[ec.ecIndex2]; ec.endTime = second.endTime; lastClusterIndex = i; gapList.Add(ec); } } return gapList; }