Example #1
0
        public List <int> sortStands(I2Points g)
        {
            dtoStand   stand;
            List <int> arr = new List <int>
            {
                Capacity = ExtraStand.Count()
            };
            Point midOfG = UtilitiesFunctions.MidPoint(g.P1, g.P2);
            Point closerer;

            if (UtilitiesFunctions.CalculteDist(midOfG, P1) < UtilitiesFunctions.CalculteDist(midOfG, P2))
            {
                closerer = P1;
            }
            else
            {
                closerer = P2;
            }
            for (int i = 0; i < ExtraStand.Count(); i++)
            {
                /* מחשב מרחק לכל סטנד*/
                calculateDistances(closerer);
                ExtraStand.Keys.ToList().Sort();
                stand = Converts.ToDtoStand(ExtraStand.Keys.Where(x => !arr.Contains(x.Code)).First());
                arr.Add(stand.Code);
                closerer = UtilitiesFunctions.MidPoint(stand.P1, stand.P2);
            }
            return(arr);
        }
Example #2
0
        private void calculateDistances(Point closer)
        {
            Point mid;

            foreach (Stand s in ExtraStand.Keys)
            {
                mid = UtilitiesFunctions.MidPoint(new Point()
                {
                    X = Convert.ToInt32(s.X1), Y = Convert.ToInt32(s.Y1.ToString())
                }, new Point {
                    X = Convert.ToInt32(s.X2), Y = Convert.ToInt32(s.Y2)
                });
                s.Distance = UtilitiesFunctions.CalculteDist(mid, closer);
            }
        }