private static CrimeEntryOutput computeCost(CrimeDataEntry crimeEntry, double[] userCoordinates, List <CrimeDataEntry> crimeEntries)
        {
            CrimeEntryOutput crimeOutput = new CrimeEntryOutput();

            crimeOutput.crimeEntry = crimeEntry;
            // Calculation distance between the two points
            double[] pointLoc     = new double[] { crimeEntry.point.longitude, crimeEntry.point.latitude };
            double   locationCost = compute(pointLoc, userCoordinates);

            // Difference of Time
            TimeSpan timeCurrent = DateTime.Now.TimeOfDay;
            TimeSpan timeCrime   = crimeEntry.dateTime.TimeOfDay;
            TimeSpan timeDiff    = timeCurrent - timeCrime;

            // Difference of Date
            DateTime dateCurrent = DateTime.Now.Date;
            DateTime dateCrime   = crimeEntry.dateTime.Date;
            TimeSpan dateDiff    = dateCrime - dateCurrent;

            // Check Frequency
            int frequency = 0;

            foreach (CrimeDataEntry crimeEntryIterator in crimeEntries)
            {
                if (crimeEntry.primaryType == crimeEntryIterator.primaryType)
                {
                    frequency++;
                }
            }

            crimeOutput.dateCost     = dateDiff.Days;
            crimeOutput.timeCost     = timeDiff.Minutes;
            crimeOutput.locationCost = locationCost;
            crimeOutput.frequency    = frequency;
            return(crimeOutput);
        }
 public string getPointData(CrimeDataEntry crimeEntryData)
 {
     return(crimeEntryData.primaryType + " - " + crimeEntryData.description);
 }
        private static string getCrimeDescription(List <CrimeDataEntry> nearCrimeEntries, double[] userCoordinates)
        {
            string htmlDescription = "";

            double         maxCost       = -10000.0f;
            CrimeDataEntry maxCrimeEntry = null;

            listCrimeEntryOutput = new Dictionary <CrimeEntryOutput, double>();
            List <string> crimeTypesAdded = new List <string>();

            foreach (CrimeDataEntry crimeEntry in nearCrimeEntries)
            {
                CrimeEntryOutput crimeEntryOutput = computeCost(crimeEntry, userCoordinates, nearCrimeEntries);
                double           computedCost     = 0.35 * -1000 * crimeEntryOutput.locationCost - 0.15 * Math.Abs(crimeEntryOutput.timeCost) - 0.35 * Math.Abs(crimeEntryOutput.dateCost) * 180 + 0.15 * crimeEntryOutput.frequency * 1000;
                listCrimeEntryOutput.Add(crimeEntryOutput, computedCost);
                //if(computedCost > maxCost)
                //{
                //    maxCost = computedCost;
                //    maxCrimeEntry = crimeEntry;
                //}

                //if (!crimeTypesAdded.Contains(crimeEntry.primaryType))
                //{
                //    listCrimeEntryOutput.Add(crimeEntryOutput, computedCost);
                //    crimeTypesAdded.Add(crimeEntry.primaryType);
                //}
            }

            var sortedDicitonary = from entry in listCrimeEntryOutput orderby entry.Value descending select entry;

            listCrimeEntryOutputAspx = new Dictionary <CrimeEntryOutput, double>();
            string primaryTypeValue = "";

            for (int i = 0; i < sortedDicitonary.Count(); i++)
            {
                maxCrimeEntry = sortedDicitonary.ElementAt(i).Key.crimeEntry;
                double[] pointLoc    = new double[] { maxCrimeEntry.point.longitude, maxCrimeEntry.point.latitude };
                double   distanceFar = compute(userCoordinates, pointLoc);

                if (!crimeTypesAdded.Contains(maxCrimeEntry.primaryType))
                {
                    crimeTypesAdded.Add(maxCrimeEntry.primaryType);
                    if (i == 0)
                    {
                        htmlDescription += "<div class=\"content displayCrime\" >";
                        primaryTypeValue = sortedDicitonary.ElementAt(i).Key.crimeEntry.primaryType;
                    }
                    else
                    {
                        htmlDescription += "<div class=\"content hideCrime\" >";
                    }
                    htmlDescription += "<div id=\"siteNotice\">" +
                                       "</div>" +
                                       "<h1 id=\"firstHeading\" class=\"firstHeading\">" + maxCrimeEntry.primaryType + "</h1>" +
                                       "<div id=\"bodyContent\">" +
                                       "<p>Be aware of <b>" + maxCrimeEntry.primaryType + "</b> <br/>" +
                                       "<p>Specifically for <b>" + maxCrimeEntry.description + "</b> <br/>" +
                                       "which happened <b>" + distanceFar + " kms </b> far <br/>" +
                                       "at <b>" + maxCrimeEntry.block + "</b><br/>" +
                                       "on  <b>" + maxCrimeEntry.dateTime + "</b>.</p> <br/>" +
                                       "The total number of times this crime has happened in the neighbourhood is <b>" + sortedDicitonary.ElementAt(i).Key.frequency + "</b>.</p> <br/>" +
                                       "</div>" +
                                       "</div>";
                }



                if (sortedDicitonary.ElementAt(i).Key.crimeEntry.primaryType == primaryTypeValue)
                {
                    listCrimeEntryOutputAspx.Add(sortedDicitonary.ElementAt(i).Key, sortedDicitonary.ElementAt(i).Value);
                }
            }


            htmlDescription += "<div id=\"nextCrime\"> <a  href=\"#\"><u>Next</u></a></div> ";


            return(htmlDescription);
        }