コード例 #1
0
        public static float FindDistanceRank(List <CheckIn> checkInInfo, string placeId, DateTime t1, DateTime t2)
        {
            var checkIn       = checkInInfo.First(c => c.PlaceId.Equals(placeId));
            var latitude      = checkIn.Latitude;
            var longitude     = checkIn.Longitude;
            var locationsDist = checkInInfo.Where(c => GeoCodeCalc.CalcDistance(latitude, longitude,
                                                                                c.Latitude, c.Longitude, GeoCodeCalcMeasurement.Kilometers) < thrDist &&
                                                  c.DateTime.Hour >= t1.Hour &&
                                                  c.DateTime.Hour <= t2.Hour).ToList();

            List <CheckIn> distinctLocs = locationsDist.GroupBy(c => c.PlaceId).Select(c => c.First()).ToList();

            float[] thetas   = new float[distinctLocs.Count];
            int     position = 0;

            for (int i = 0; i < distinctLocs.Count; i++)
            {
                thetas[i] = DistanceSensitiveFactor(checkInInfo, distinctLocs[i].PlaceId, t1, t2);
                if (distinctLocs[i].PlaceId.Equals(placeId))
                {
                    position = i;
                }
            }

            return(GetDistanceRanks(distinctLocs, thetas)[position, 1]);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: mitkosl/MapsRepository
        //Get the sum of the number of visits by the current user in the dataset to the locations within the threshold distance and within the time interval(t1, t2)
        public static int VisitsByUserAndDistance(List <CheckIn> checkInInfo, string placeId, string userId, DateTime t1, DateTime t2)
        {
            var checkIn   = checkInInfo.First(c => c.PlaceId.Equals(placeId));
            var latitude  = checkIn.Latitude;
            var longitude = checkIn.Longitude;
            var sum       = checkInInfo.Count(c => c.UserId.Equals(userId) &&
                                              GeoCodeCalc.CalcDistance(latitude, longitude,
                                                                       c.Latitude, c.Longitude, GeoCodeCalcMeasurement.Kilometers) < thrDist &&
                                              c.DateTime.Hour >= t1.Hour &&
                                              c.DateTime.Hour <= t2.Hour);

            return(sum);
        }
コード例 #3
0
        public static float CalculatePsiD(List <CheckIn> checkInInfo, string userId, string placeId)
        {
            var   checkIn   = checkInInfo.First(c => c.PlaceId.Equals(placeId));
            var   latitude  = checkIn.Latitude;
            var   longitude = checkIn.Longitude;
            float nD        = checkInInfo.Count(c => c.UserId.Equals(userId) &&
                                                GeoCodeCalc.CalcDistance(latitude, longitude,
                                                                         c.Latitude, c.Longitude, GeoCodeCalcMeasurement.Kilometers) < thrDist);
            var n = checkInInfo.Count(c => c.UserId.Equals(userId));
            var N = checkInInfo.Select(c => c.PlaceId).Distinct().Count();

            var            locsByUser   = checkInInfo.Where(c => c.UserId.Equals(userId));
            List <CheckIn> distinctLocs = locsByUser.GroupBy(c => c.PlaceId).Select(c => c.First()).ToList();

            var Nd = distinctLocs.Count(c => GeoCodeCalc.CalcDistance(latitude, longitude,
                                                                      c.Latitude, c.Longitude, GeoCodeCalcMeasurement.Kilometers) < thrDist);

            if (Nd == 0)
            {
                Nd = 1;
            }

            return((nD / n) * (float)(Math.Log(1 + N / Nd)));
        }