예제 #1
0
        /// <summary>Combine clustered pins to thin out map
        /// </summary>
        public void CombineClusteredPins(ClusteredPin newPin)
        {
            //This is needed to prevent alert to be considered for clustering
            //if (newPin.AssessmentHeaderData["Sector"].ToLower() == "alert") return;
            ClusterArea.IncludeInBounds(newPin.ClusterArea);

            if ((Count == 0))
            {
                // AssessmentHeaderData = newPin.AssessmentHeaderData;
                pinType = newPin.PinType;
                // themeParameter = newPin.ThemeParameter;
            }
            else
            {
                //AssessmentHeaderData.Clear();
                // AssessmentHeaderData["icontype"] = newPin.AssessmentHeaderData["icontype"];
                pinType = "clusterpoint";
                // themeParameter = newPin.ThemeParameter;
            }

            assessmentids.AddRange(newPin.assessmentids);
            Count = Count + newPin.Count;

            //Merge the two dictionaries into one dictionary
            //Source: http://stackoverflow.com/questions/10559367/combine-multiple-dictionaries-into-a-single-dictionary
            ServiceCodeToTitle = ServiceCodeToTitle.Concat(newPin.ServiceCodeToTitle).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value);
        }
예제 #2
0
        /// <summary>
        /// Adds a pin to the cluster
        /// </summary>
        /// <param name="newPin">the pin to add</param>
        public void AddPin(ClusteredPin newPin)
        {
            //This is needed to prevent alert to be sonsidered for clustering
            //if (newPin.AssessmentHeaderData["Sector"].ToLower() == "alert") return;
            if (Loc == null)
            {
                Loc = newPin.Loc;
            }
            ClusterArea.IncludeInBounds(newPin.ClusterArea);

            if ((Count == 0))
            {
                // AssessmentHeaderData = newPin.AssessmentHeaderData;
                pinType = newPin.PinType;
                //themeParameter = newPin.ThemeParameter;
            }
            else
            {
                //AssessmentHeaderData.Clear();
                // AssessmentHeaderData["icontype"] = newPin.AssessmentHeaderData["icontype"];
                pinType = "clusterpoint";
                //themeParameter = newPin.ThemeParameter;
            }

            assessmentids.Add(newPin.assessmentids[0]);
            Count = Count + 1;

            //Merge the two dictionaries into one dictionary
            //Source: http://stackoverflow.com/questions/10559367/combine-multiple-dictionaries-into-a-single-dictionary
            //ServiceCodeToTitle = ServiceCodeToTitle.Concat(newPin.ServiceCodeToTitle).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value);

            //Update counts dictionary...
            foreach (var key in newPin.ServiceCodeToTitle.Keys)
            {
                servCodeCounts[key] = (servCodeCounts.ContainsKey(key)) ? servCodeCounts[key] + 1 : 1;
            }

            //Update service code dictionary...
            //	Expected format for strings:  <service title> (<service count>)
            foreach (var key in servCodeCounts.Keys)
            {
                string titlePlusCount = ServiceCodeToTitle.ContainsKey(key) ? ServiceCodeToTitle[key] : newPin.ServiceCodeToTitle[key];

                int last = titlePlusCount.LastIndexOf(')');
                if (-1 != last)
                {
                    titlePlusCount = titlePlusCount.Substring(0, last);
                }

                last = titlePlusCount.LastIndexOf(" (");
                if (-1 != last)
                {
                    titlePlusCount = titlePlusCount.Substring(0, last);
                }

                ServiceCodeToTitle[key] = titlePlusCount + " (" + servCodeCounts[key].ToString() + ")";
            }
        }