Exemplo n.º 1
0
 public void ValidateGroupLocationUniqness()
 {
     if (GroupsList != null && GroupsList.Count > 0)
     {
         List <GroupRecord> localGroupRecords = GroupsList.Distinct(new GroupLocationComparator()).ToList();
         FailedRecords.AddRange(GroupsList.Except(localGroupRecords).ToList());
         GroupsList = localGroupRecords;
     }
 }
Exemplo n.º 2
0
        public void RemoveGroupsIntersections()
        {
            if (GroupsList != null && GroupsList.Count > 0)
            {
                List <IRecord> intersectingFailedRecords = new List <IRecord>();

                for (int i = 0; i < GroupsList.Count - 1; i++)
                {
                    GroupRecord group1 = GroupsList[i];
                    for (int j = i + 1; j < GroupsList.Count; j++)
                    {
                        GroupRecord group2 = GroupsList[j];
                        if (intersectingFailedRecords.Count == 0 || !intersectingFailedRecords.Contains(group2))
                        {
                            double distance = CalculateDistance(group1.LocationX, group1.LocationY, group2.LocationX,
                                                                group2.LocationY);

                            if (distance > group1.Radius + group2.Radius)
                            {
                                //not intersecting, leave group
                            }
                            else if ((distance <= group1.Radius + group2.Radius) || distance <
                                     Math.Abs(group1.Radius - group2.Radius) ||
                                     (distance == 0 &&
                                      group1.Radius == group2.Radius))
                            {
                                intersectingFailedRecords.Add(group2);
                            }
                            else
                            {
                                intersectingFailedRecords.Add(group2);
                            }
                        }
                    }
                }

                FailedRecords.AddRange(intersectingFailedRecords);
                List <GroupRecord> groups = intersectingFailedRecords.Cast <GroupRecord>().ToList();
                GroupsList = GroupsList.Except(groups).ToList();
            }
        }