Пример #1
0
        public String CreateConvexHauls(List <Point> points)
        {
            List <List <Point> > finalResultList = new List <List <Point> >();

            foreach (List <Point> list in ConvexHaul.CalculateHull(points, AreaAroundYuu))
            {
                finalResultList.Add(list);
            }
            foreach (List <Point> list in ConvexHaul.CalculateHull(points, NeighourHood))
            {
                finalResultList.Add(list);
            }
            foreach (List <Point> list in ConvexHaul.CalculateHull(points, Town))
            {
                finalResultList.Add(list);
            }
            foreach (List <Point> list in ConvexHaul.CalculateHull(points, Country))
            {
                finalResultList.Add(list);
            }

            String JSON = "{result : [";

            foreach (var list in finalResultList)
            {
                JSON = JSON + "[";
                foreach (var point in list)
                {
                    JSON = JSON + "{" + point.x + ", " + point.y + "},";
                }
                JSON = JSON.TrimEnd(',');
                JSON = JSON + "],";
            }

            JSON = JSON.TrimEnd(',');
            JSON = JSON + "]}";

            Console.WriteLine(JSON);

            return(JSON);
        }
Пример #2
0
        public String CheckIfPointsCauseAlert(List <Point> points, Point user)
        {
            String JSON = "{areas : [";

            int counterForAreaAroundYuu = 0;
            int counterForNeighourHood  = 0;
            int counterForTown          = 0;
            int counterForCountry       = 0;

            foreach (Point point in points)
            {
                if (ConvexHaul.Distance(point, user) < AreaAroundYuu)
                {
                    counterForAreaAroundYuu++;
                }
                if (ConvexHaul.Distance(point, user) < NeighourHood)
                {
                    counterForNeighourHood++;
                }
                if (ConvexHaul.Distance(point, user) < Town)
                {
                    counterForTown++;
                }
                if (ConvexHaul.Distance(point, user) < Country)
                {
                    counterForCountry++;
                }
            }

            if (counterForAreaAroundYuu >= AreaAroundYuuCases)
            {
                JSON = JSON + "{\"AreaAroundYou\" : 1},";
            }
            else
            {
                JSON = JSON + "{\"AreaAroundYou\" : 0},";
            }

            if (counterForNeighourHood >= NeighourHoodCases)
            {
                JSON = JSON + "{\"NeighourHood\" : 1},";
            }
            else
            {
                JSON = JSON + "{\"NeighourHood\" : 0},";
            }

            if (counterForTown >= TownCases)
            {
                JSON = JSON + "{\"Town\" : 1},";
            }
            else
            {
                JSON = JSON + "{\"Town\" : 0},";
            }

            if (counterForCountry >= CountryCases)
            {
                JSON = JSON + "{\"Country\" : 1}]}";
            }
            else
            {
                JSON = JSON + "{\"Country\" : 0}]}";
            }

            return(JSON);
        }