示例#1
0
        public void CalculateRoutes_uses_origin_from_previous_event_when_within_3_hours()
        {
            var events = GetEvents();

            var routes = routeCalculator.CalculateRoutes(events, homeAddress);

            // day two
            Assert.AreEqual(homeAddress, routes.ElementAt(2).Origin);
            Assert.AreEqual(events.ElementAt(1).Location, routes.ElementAt(2).Destination);
            Assert.AreEqual(events.ElementAt(1).Location, routes.ElementAt(3).Origin);
            Assert.AreEqual(events.ElementAt(2).Location, routes.ElementAt(3).Destination);
            Assert.AreEqual(events.ElementAt(2).Location, routes.ElementAt(4).Origin);
            Assert.AreEqual(homeAddress, routes.ElementAt(4).Destination);
        }
示例#2
0
        public virtual ActionResult Index(string calendarId, int year, int month)
        {
            try
            {
                var calendarService = this.GetAgendaService();
                var importer        = new AgendaImporter(calendarService);
                var events          = importer.GetEventsModel(calendarId);

                var locationOptimizer = new LocationOptimizer();
                events = locationOptimizer.OptimizeLocations(events);

                var start = new DateTime(year, month, 1);
                var end   = start.AddMonths(1);
                var eventsOfSelectedMonth = events.Where(e => e.Start >= start && e.End <= end);

                var routes = routeCalculator.CalculateRoutes(eventsOfSelectedMonth, "Van koetsveldstraat 39, Utrecht");
                var model  = routeCalculator.CalculateTravelCosts(routes);

                return(View(model));
            }
            catch (NoAuthenticatorException)
            {
                return(RedirectToRoute("GoogleAuthentication", new { callbackurl = Request.Url }));
            }
        }
示例#3
0
        private List <NodeRoute <SkyNetNode> > GetPossibleRoutesForSkynet(Dictionary <int, SkyNetNode> nodes, List <SkyNetNode> allNodes, List <SkyNetNode> exitNodes, int skynetNodePos)
        {
            var skynetNode  = nodes[skynetNodePos];
            var routeHelper = new RouteCalculator <SkyNetNode, SkyNetNode>();
            List <Node <SkyNetNode> >      nodesAsSkyNetNode = allNodes.Select(n => n as Node <SkyNetNode>).ToList();    //generics and casting :(
            List <NodeRoute <SkyNetNode> > availableRoutes   = new List <NodeRoute <SkyNetNode> >();

            //Query the paths to the exit nodes
            exitNodes.ForEach(exitNode => {
                var routes = routeHelper.FilterRoutesOnDestinationReached(routeHelper.CalculateRoutes(nodesAsSkyNetNode, skynetNode, exitNode, 5));
                availableRoutes.AddRange(routes.Select(r => r));
            });

            return(availableRoutes);
        }