Ejemplo n.º 1
0
        public List <int> GetRouteSafety()
        {
            RouteInformation         mapdata = JsonConvert.DeserializeObject <RouteInformation>(json);
            RoutePickingIntelligence safeNav = new RoutePickingIntelligence();

            return(safeNav.ParseStreetSafety(mapdata));

            //gets a list accidents in that route,
            //return the route with the least accident count
        }
Ejemplo n.º 2
0
 public List <StreetDetails> ParseStreetInfo(RouteInformation mapdata)
 {
     try
     {
         HashSet <StreetDetails> streets = new HashSet <StreetDetails>();
         foreach (var route in mapdata.routes)
         {
             foreach (var leg in route.legs)
             {
                 foreach (var step in leg.steps)
                 {
                     streets.UnionWith(Utilities.GetStreets(step));
                 }
             }
         }
         return(streets.ToList());
     }
     catch (Exception)
     {
         //TODO : write exception
         return(null);
     }
 }
        public List <int> ParseStreetSafety(RouteInformation mapdata)
        {
            HashSet <StreetDetails> streets = new HashSet <StreetDetails>();
            int        i       = 0;
            List <int> counter = new List <int>();

            foreach (var route in mapdata.routes)
            {
                counter.Add(0);
                foreach (var leg in route.legs)
                {
                    foreach (var step in leg.steps)
                    {
                        List <StreetDetails> stNames = Utilities.GetStreets(step);
                        foreach (var item in stNames)
                        {
                            counter[i] += Queries.GetAccidentCount(item.stName);
                        }
                    }
                }
                i++;
            }
            return(counter);
        }
Ejemplo n.º 4
0
        public List <StreetDetails> GetStreetInfo()
        {
            RouteInformation mapdata = JsonConvert.DeserializeObject <RouteInformation>(json);

            return(ParseStreetInfo(mapdata));
        }