public void RandomDrawing()
        {
            int[]       groupsCapacity = Utils.GetClustersCapacity(_round.clubs.Count, _round.groupsCount);
            List <Club> clubs          = new List <Club>(_round.clubs);

            if (_round.groupsLocalisation.Count > 0)
            {
                for (int i = 0; i < _round.groupsCount; i++)
                {
                    GeographicPosition position = _round.groupsLocalisation[i];
                    clubs.Sort(new ClubLocalisationComparator(position));
                    for (int j = 0; j < groupsCapacity[i]; j++)
                    {
                        _round.groups[i].Add(clubs[0]);
                        clubs.RemoveAt(0);
                    }
                }
            }
            else
            {
                List <Club>[] splitClubs = Utils.CreateGeographicClusters(clubs, _round.groupsCount);
                for (int i = 0; i < _round.groupsCount; i++)
                {
                    _round.groups[i].AddRange(splitClubs[i]);
                }
            }
        }
Example #2
0
        public static float Distance(GeographicPosition a, GeographicPosition b)
        {
            float lat1 = a.Latitude;
            float lon1 = a.Longitude;
            float lat2 = b.Latitude;
            float lon2 = b.Longitude;

            int    R    = 6371;
            double dLat = Deg2Rad(lat2 - lat1);
            double dLon = Deg2Rad(lon2 - lon1);
            double va   = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Cos(Deg2Rad(lat1)) * Math.Cos(Deg2Rad(lat2)) * Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
            double c    = 2 * Math.Atan2(Math.Sqrt(va), Math.Sqrt(1 - va));
            double d    = R * c;

            return((float)d);
        }
Example #3
0
 public City(string name, int population, float latitude, float longitude)
 {
     Name       = name;
     Population = population;
     Position   = new GeographicPosition(latitude, longitude);
 }