Example #1
0
        /// <summary>
        /// 将聚合对象加入到聚合中
        /// </summary>
        /// <param name="ci"></param>
        public void AddGraphics(ClusterItem ci)
        {
            double x = 0, y = 0, sx = ScreenLocation.X * Graphics.Count, sy = ScreenLocation.Y * Graphics.Count;

            foreach (var g in ci.Graphics)
            {
                Graphics.Add(g);
            }
            sx += ci.ScreenLocation.X * ci.Graphics.Count;
            sy += ci.ScreenLocation.Y * ci.Graphics.Count;
            ci.Graphics.Clear();



            foreach (var g in Graphics)
            {
                var point = g.Geometry as MapPoint;
                if (point != null)
                {
                    x += point.X;
                }
                var mapPoint = g.Geometry as MapPoint;
                if (mapPoint != null)
                {
                    y += mapPoint.Y;
                }
            }
            _center        = new MapPoint(x / Graphics.Count, y / Graphics.Count);
            ScreenLocation = new Point(sx / Graphics.Count, sy / Graphics.Count);
            _size          = 25 + Graphics.Count / 20;
        }
Example #2
0
        /// <summary>
        /// 判断两个聚合对象是否需要被聚合
        /// </summary>
        /// <param name="ci"></param>
        /// <param name="buffer">缓冲区</param>
        /// <returns></returns>
        public bool IncludeCluster(ClusterItem ci, double buffer)
        {
            var pt1 = ci.ScreenLocation;

            var pt2 = ScreenLocation;

            var dis = Math.Sqrt(Math.Pow(pt1.X - pt2.X, 2) + Math.Pow(pt1.Y - pt2.Y, 2));

            return(dis <= buffer + 1.0 * (_size + ci._size) / 2);
        }