Ejemplo n.º 1
0
        /// <summary>
        /// Visual clustering.
        /// </summary>
        /// <param name="pins"></param>
        /// <param name="index"></param>
        /// <param name="direction"></param>
        /// <param name="currentClusterPin"></param>
        /// <param name="zoomLevel"></param>
        /// <param name="minClusterDistance"></param>
        private void addClusteredPinsWithinRange(List <ClusteredPin> pins, int index, int direction, ClusteredPin currentClusterPin, int zoomLevel, int minClusterDistance)
        {
            bool finished = false;
            int  searchindex;

            searchindex = index + direction;
            while (!finished)
            {
                if (searchindex >= pins.Count || searchindex < 0)
                {
                    finished = true;
                }
                else
                {
                    if (!pins[searchindex].IsClustered)
                    {
                        if (Math.Abs(pins[searchindex].GetPixelX(zoomLevel) - pins[index].GetPixelX(zoomLevel)) < minClusterDistance)     //within the same x range
                        {
                            if (Math.Abs(pins[searchindex].GetPixelY(zoomLevel) - pins[index].GetPixelY(zoomLevel)) < minClusterDistance) //within the same y range = cluster needed
                            {
                                //add to cluster
                                currentClusterPin.CombineClusteredPins(pins[searchindex]);

                                //stop any further clustering
                                pins[searchindex].IsClustered = true;
                            }
                        }
                        else
                        {
                            finished = true;
                        }
                    }
                    ;
                    searchindex += direction;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Visual clustering. 
        /// </summary>
        /// <param name="pins"></param>
        /// <param name="index"></param>
        /// <param name="direction"></param>
        /// <param name="currentClusterPin"></param>
        /// <param name="zoomLevel"></param>
        /// <param name="minClusterDistance"></param>
        private void addClusteredPinsWithinRange(List<ClusteredPin> pins, int index, int direction, ClusteredPin currentClusterPin, int zoomLevel, int minClusterDistance)
        {
            bool finished = false;
            int searchindex;
            searchindex = index + direction;
            while (!finished)
            {
                if (searchindex >= pins.Count || searchindex < 0)
                {
                    finished = true;
                }
                else
                {
                    if (!pins[searchindex].IsClustered)
                    {
                        if (Math.Abs(pins[searchindex].GetPixelX(zoomLevel) - pins[index].GetPixelX(zoomLevel)) < minClusterDistance) //within the same x range
                        {
                            if (Math.Abs(pins[searchindex].GetPixelY(zoomLevel) - pins[index].GetPixelY(zoomLevel)) < minClusterDistance) //within the same y range = cluster needed
                            {
                                //add to cluster
                                currentClusterPin.CombineClusteredPins(pins[searchindex]);

                                //stop any further clustering
                                pins[searchindex].IsClustered = true;
                            }
                        }
                        else
                        {
                            finished = true;
                        }
                    };
                    searchindex += direction;
                }
            }
        }