Пример #1
0
 private void CopyMembers(GeoCluster old)
 {
     this._clusterId  = old._clusterId;
     this._center     = old._center;
     this._createdAt  = old._createdAt;
     this._dayTime    = old._dayTime;
     this._dayCount   = old._dayCount;
     this._nightCount = old._nightCount;
     this._clusterId  = old._clusterId;
 }
Пример #2
0
        private void WriteCluster(GeoCluster cluster)
        {
            // [run_id] [smallint] NOT NULL
            BulkWriter.WriteSmallInt(RunId);

            // [user_id] [bigint] NOT NULL
            BulkWriter.WriteBigInt(cluster.UserId);

            // [cluster_id] [tinyint] NOT NULL
            BulkWriter.WriteTinyInt((sbyte)cluster.ClusterId);

            // [location_count] [int] NOT NULL
            BulkWriter.WriteInt(cluster.InitialPointCount);

            // [location_count_trimmed] [int] NOT NULL
            BulkWriter.WriteInt(cluster.FinalPointCount);

            // [sigma] [float] NOT NULL
            BulkWriter.WriteFloat(cluster.Sigma);

            // [lat] [float] NOT NULL
            BulkWriter.WriteFloat(cluster.Center.Lat);

            // [lon] [float] NOT NULL
            BulkWriter.WriteFloat(cluster.Center.Lon);

            // [cx] [float] NOT NULL
            BulkWriter.WriteFloat(cluster.Center.X);

            // [cy] [float] NOT NULL
            BulkWriter.WriteFloat(cluster.Center.Y);

            // [cz] [float] NOT NULL
            BulkWriter.WriteFloat(cluster.Center.Z);

            // [htm_id] [bigint] NOT NULL
            BulkWriter.WriteFloat(0);       // TODO

            // [is_day] [bit] NULL
            BulkWriter.WriteNullableBit(cluster.DayCount > cluster.NightCount);     // TODO: verify

            // [day_count] [int] NOT NULL
            BulkWriter.WriteInt(cluster.DayCount);

            // [night_count] [int] NOT NULL
            BulkWriter.WriteInt(cluster.NightCount);

            // [iterations] [tinyint] NOT NULL
            BulkWriter.WriteTinyInt((sbyte)cluster.TrimmingIter);

            BulkWriter.EndLine();
        }
Пример #3
0
        /// <summary>
        /// Finds FoF clusters in a list of points
        /// </summary>
        /// <param name="points"></param>
        public void FindClusters(IEnumerable <GeoPoint> points)
        {
            // This will hold results
            clusters = new List <GeoCluster>();

            // A hash set will contain all points not in a cluster yet
            var input = new HashSet <GeoPoint>(points);
            var temp  = new HashSet <GeoPoint>();

            int k = 1;

            GeoPoint actual     = new GeoPoint();
            GeoPoint tempActual = new GeoPoint();


            while (input.Count > 0)
            {
                var gclust = new GeoCluster();
                gclust.ClusterId = k;

                actual = input.ElementAt(0);
                input.Remove(actual);

                temp.Add(actual);

                while (temp.Count != 0)
                {
                    tempActual = temp.ElementAt(0);
                    gclust.Points.Add(tempActual);
                    temp.Remove(tempActual);

                    foreach (GeoPoint g in input)
                    {
                        if (IsFriend(g, tempActual))
                        {
                            if (!temp.Contains(g))
                            {
                                temp.Add(g);
                            }
                        }
                    }

                    foreach (GeoPoint g in temp)
                    {
                        input.Remove(g);
                    }
                }

                clusters.Add(gclust);
                k++;
            }
        }
Пример #4
0
 public GeoCluster(GeoCluster old)
 {
     CopyMembers(old);
 }