示例#1
0
        private int CompareRoutes(TaskItem taskItemClicked, string startAddress, string endAddress, DateTime selectedDate)
        {
            RouteItem AC = RouteCalculator.GetRouteItem((Address)startAddress, taskItemClicked.TaskDescription.Citizen.GetAddress(selectedDate));
            RouteItem CB = RouteCalculator.GetRouteItem(taskItemClicked.TaskDescription.Citizen.GetAddress(selectedDate), (Address)endAddress);

            return(AC.Duration.Seconds + CB.Duration.Seconds);
        }
示例#2
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     DependencyResolver.SetResolver(new NinjectDependencyResolver());
     CleanupRouteCalculations();
     RouteCalculator.StartWorker();
 }
示例#3
0
        static void Main(string[] args)
        {
            connector.ConnectRoutes();
            roadSearch = new RouteCalculator(connector.Nodes);
            Console.WriteLine("Hello and welcome to RoutCity!");
            Console.WriteLine("Here you can find the fastest way too you choosen part of the city.");
            Console.WriteLine("Given the options below make your choise : ");
            Console.WriteLine("Enter 1 : Show all Connections ");
            Console.WriteLine("Enter 2 : Choose your own path ");
            Console.WriteLine("Enter 3 : Exit the program ");

            while (true)
            {
                Console.WriteLine("Make a choise !");
                string userAnswer = Console.ReadLine();
                switch (userAnswer)
                {
                case "1":
                    ShowAllConnections(connector);
                    break;

                case "2":
                    ChoosePath();
                    break;

                case "3":
                    Console.WriteLine("Thanks for visiting and welcome back!");
                    return;

                default:
                    Console.WriteLine("Sorry, you have entered something invalid, try again!");
                    break;
                }
            }
        }
示例#4
0
        private void CalculateRoute()
        {
            try
            {
                var routeCalculator = new RouteCalculator(
                    CredentialsProvider,
                    To,
                    From,
                    Dispatcher,
                    result =>
                {
                    // Clear the route collection to have only one route at a time.
                    Routes.Clear();

                    // Create a new route based on route calculator result,
                    // and add the new route to the route collection.
                    var routeModel = new RouteModel(result.Result.RoutePath.Points);
                    Routes.Add(routeModel);

                    // Set the map to center on the new route.
                    var viewRect = LocationRect.CreateLocationRect(routeModel.Locations);
                    Map.SetView(viewRect);
                });

                // Display an error message in case of fault.
                routeCalculator.Error += r => MessageBox.Show(r.Reason);

                // Start the route calculation asynchronously.
                routeCalculator.CalculateAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public ActionResult SearchRoute(Shippment model)
        {
            var shippment = new Shippment();
            var Model     = new Shippment();

            var categories = DbHelper.GetAllCategoriesFromDb();

            Model.Categories = GetCategoryListItems(categories);

            var cities = DbHelper.GetAllCities();

            Model.CitiesFrom = GetCityListItems(cities);
            Model.CitiesTo   = GetCityListItems(cities);

            if (ModelState.IsValid)
            {
                shippment.Category = model.Category;
                shippment.Weight   = model.Weight;
                shippment.CityFrom = model.CityFrom;
                shippment.CityTo   = model.CityTo;

                CalculatedRoute calculatedRoute      = null;
                CalculatedRoute calculatedRouteCheap = null;
                try
                {
                    calculatedRoute = RouteCalculator.Calculate(model.Category, model.Weight,
                                                                DbHelper.GetCityByName(model.CityFrom), DbHelper.GetCityByName(model.CityTo), true);

                    calculatedRouteCheap = RouteCalculator.Calculate(model.Category, model.Weight,
                                                                     DbHelper.GetCityByName(model.CityFrom), DbHelper.GetCityByName(model.CityTo), false);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
                shippment.searchedSections      = calculatedRoute;
                shippment.searchedSectionsCheap = calculatedRouteCheap;

                shippment.Categories = GetCategoryListItems(categories);
                shippment.CitiesFrom = GetCityListItems(cities);
                shippment.CitiesTo   = GetCityListItems(cities);
                if (shippment.searchedSections != null && shippment.searchedSections.Route != null)
                {
                    for (int i = 0; i < shippment.searchedSections.Route.Count; i++)
                    {
                        TempData["price" + i]    = shippment.searchedSections.Route[i].Price.ToString();
                        TempData["duration" + i] = shippment.searchedSections.Route[i].Duration.ToString();
                        TempData["from" + i]     = shippment.searchedSections.Route[i].From.Name;
                        TempData["to" + i]       = shippment.searchedSections.Route[i].To.Name;
                    }
                    TempData["price"]    = shippment.searchedSections.Price;
                    TempData["duration"] = shippment.searchedSections.Duration;
                }

                return(View("index", shippment));
            }

            return(View("index", Model));
        }
示例#6
0
        public void TestThatTheParentVertexIsTheExpected()
        {
            mock       = new MockObject();
            calculator = new RouteCalculator(mock.mockObject);
            testVertex = calculator.FindShortestPath(mock.mockObject[0], mock.mockObject[2], 0);

            Assert.IsTrue(testVertex.ParentVertex == "E");
        }
示例#7
0
        public RouteCalculatorTests()
        {
            var distanceCalculatorMock = new Mock <IDistanceCalculator>();

            distanceCalculatorMock.Setup(d => d.CalculateDistance(It.IsAny <string>(), It.IsAny <string>())).Returns(10);
            this.distanceCalculator = distanceCalculatorMock.Object;
            this.routeCalculator    = new RouteCalculator(distanceCalculator);
        }
示例#8
0
        public void TestThatRightNodeGetsReturned()
        {
            mock       = new MockObject();
            calculator = new RouteCalculator(mock.mockObject);
            testVertex = calculator.FindShortestPath(mock.mockObject[0], mock.mockObject[2], 0);

            Assert.IsTrue(testVertex.VertexName == "C");
        }
示例#9
0
        public void TestThatShortestPathIsCalculatedCorrectly()
        {
            mock       = new MockObject();
            calculator = new RouteCalculator(mock.mockObject);
            testVertex = calculator.FindShortestPath(mock.mockObject[0], mock.mockObject[2], 0);

            Assert.IsTrue(testVertex.GoldenNumber == 6);
        }
示例#10
0
        protected override void OnElementChanged(ElementChangedEventArgs <OsmMap> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                // set up the native control
                var mapView = new MKMapView();
                SetNativeControl(mapView);
                Control.ShowsCompass = true;


                var overlay = new MKTileOverlay("http://b.sm.mapstack.stamen.com/(watercolor,streets-and-labels)/{z}/{x}/{y}.png")
                {
                    CanReplaceMapContent = true
                };
                mapView.AddOverlay(overlay, MKOverlayLevel.AboveLabels);

                mapView.OverlayRenderer = OverlayRenderer;
                mapView.RegionChanged  += MapViewOnRegionChanged;
            }

            if (routeCalculator == null)
            {
                routeCalculator = RouteCalculator.Instance;
            }

            if (e.OldElement != null)
            {
                // remove connections to the old instance
                Control.GetViewForAnnotation           = null;
                Control.CalloutAccessoryControlTapped -= OnCalloutAccessoryControlTapped;
                e.OldElement.GpsLocationChanged       -= OnGpsLocationChanged;
                e.OldElement.ExhibitSetChanged        -= OnExhibitSetChanged;
                e.OldElement.DetailsRouteChanged      -= OnDetailsRouteChanged;
                e.OldElement.CenterLocationCalled     -= CenterLocation;
            }

            if (e.NewElement != null)
            {
                // setup connections to the new instance
                osmMap = e.NewElement;
                InitAnnotations(e.NewElement.ExhibitSet, e.NewElement.DetailsRoute);
                Control.GetViewForAnnotation           = GetViewForAnnotation;
                Control.CalloutAccessoryControlTapped += OnCalloutAccessoryControlTapped;
                e.NewElement.GpsLocationChanged       += OnGpsLocationChanged;
                OnGpsLocationChanged(osmMap.GpsLocation);
                e.NewElement.ExhibitSetChanged   += OnExhibitSetChanged;
                e.NewElement.DetailsRouteChanged += OnDetailsRouteChanged;
                OnDetailsRouteChanged(osmMap.DetailsRoute);
                e.NewElement.CenterLocationCalled += CenterLocation;
                InitMapPosition();
                if (e.NewElement.ShowNavigation)
                {
                    UpdateRoute();
                }
            }
        }
示例#11
0
        // GET api/<controller>/5
        public IHttpActionResult Get(string fromName, string toName, string parcelType, int weight, int filter)
        {
            fromName = fromName.ToUpper();
            toName   = toName.ToUpper();
            if (!DbHelper.GetAllCities().Select(x => x.Name).Contains(fromName) ||
                !DbHelper.GetAllCities().Select(x => x.Name).Contains(toName))
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "One of the specified cities was not found"));
            }

            if (!DbHelper.GetAllCategoriesFromDb().Select(x => x.Name).Contains(parcelType))
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "The specified parcel type was not found"));
            }

            if (!(filter == 0 || filter == 1))
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "The specified filter was not found"));
            }

            if (weight > 100)
            {
                return(Json(new {}));
            }
            try
            {
                var result = RouteCalculator.Calculate(
                    DbHelper.GetCategoryByName(parcelType),
                    weight,
                    DbHelper.GetCityByName(fromName),
                    DbHelper.GetCityByName(toName),
                    filter == 1
                    );

                //var result = RouteCalculator.CalculateInternalRoute(
                //    DbHelper.GetCategoryByName(parcelType),
                //    weight,
                //    fromName,
                //    toName,
                //    filter == 1
                //);

                return(Json(new
                {
                    valid = "true",
                    duration = result.Duration.ToString(),
                    price = result.Price.ToString(),
                    fromName = fromName,
                    toName = toName
                }));
            }
            catch (InvalidDataException e)
            {
                Console.Write(e.Message);
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "The route could not be calculated"));
            }
        }
示例#12
0
        public void TestMethod2()
        {
            RouteCalculator calculator = new RouteCalculator();

            using (var textStream = CreateResource())
            {
                Assert.AreEqual(2631, calculator.GetNumberOfHousesWithGiftsUsingRobo(InputReader.ReadResource(textStream)));
            }
        }
示例#13
0
        public void TestThatItTakeTheExpectedWay()
        {
            mock       = new MockObject();
            calculator = new RouteCalculator(mock.mockObject);
            testVertex = calculator.FindShortestPath(mock.mockObject[0], mock.mockObject[4], 0);

            Assert.IsTrue(testVertex.ParentVertex == "B");
            Assert.IsTrue(testVertex.VertexName == "E");
            Assert.AreEqual(testVertex.GoldenNumber, 5);
        }
示例#14
0
        public MainWindowViewModel()
        {
            var data     = new MetroLayout();
            var stations = data.GetStations();
            var routes   = data.GetRoutes();

            StationList = stations;
            RouteList   = routes
                          .Distinct(directionlessRouteComparer)
                          .Select(route => new RouteViewModel(route)).ToArray();
            calculator = new RouteCalculator(stations, routes);
        }
示例#15
0
        public void TestRouteConnectorAnNodeConnectionsWithCalculateRoute()
        {
            testConnector = new RouteConnector();
            testConnector.ConnectRoutes();
            calculator = new RouteCalculator(testConnector.Nodes);
            testVertex = calculator.FindShortestPath(testConnector.Nodes[0], testConnector.Nodes[1], 0);

            Assert.AreEqual(testVertex.VertexName, testConnector.Nodes[1].Name);
            Assert.IsTrue(testVertex.Distance < 10);
            Assert.IsTrue(testVertex.Distance > 0);
            Assert.IsTrue(testConnector.Nodes.Count == 10);
        }
 public IHttpActionResult RetrievePlaceData([FromBody] ClientRouteCalculatorRequest rcr)
 {
     try
     {
         List <Route> resultList = RouteCalculator.Calculate(rcr);
         return(Ok(resultList));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
         //return BadRequest(ex.Message);
     }
 }
示例#17
0
        protected override void OnElementChanged(ElementChangedEventArgs <OsmMap> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                // set up the native control
                var mapView = new MKMapView();
                SetNativeControl(mapView);
                Control.ShowsCompass = true;

                mapView.OverlayRenderer = OverlayRenderer;
                mapView.RegionChanged  += MapViewOnRegionChanged;
            }

            if (routeCalculator == null)
            {
                routeCalculator = RouteCalculator.Instance;
            }

            if (e.OldElement != null)
            {
                // remove connections to the old instance
                Control.GetViewForAnnotation           = null;
                Control.CalloutAccessoryControlTapped -= OnCalloutAccessoryControlTapped;
                e.OldElement.GpsLocationChanged       -= OnGpsLocationChanged;
                e.OldElement.ExhibitSetChanged        -= OnExhibitSetChanged;
                e.OldElement.DetailsRouteChanged      -= OnDetailsRouteChanged;
                e.OldElement.CenterLocationCalled     -= CenterLocation;
            }

            if (e.NewElement != null)
            {
                // setup connections to the new instance
                osmMap = e.NewElement;
                InitAnnotations(e.NewElement.ExhibitSet, e.NewElement.DetailsRoute);
                Control.GetViewForAnnotation           = GetViewForAnnotation;
                Control.CalloutAccessoryControlTapped += OnCalloutAccessoryControlTapped;
                e.NewElement.GpsLocationChanged       += OnGpsLocationChanged;
                OnGpsLocationChanged(osmMap.GpsLocation);
                e.NewElement.ExhibitSetChanged   += OnExhibitSetChanged;
                e.NewElement.DetailsRouteChanged += OnDetailsRouteChanged;
                OnDetailsRouteChanged(osmMap.DetailsRoute);
                e.NewElement.CenterLocationCalled += CenterLocation;
                InitMapPosition();
                if (e.NewElement.ShowNavigation)
                {
                    UpdateRoute();
                }
            }
        }
示例#18
0
        protected override void OnElementChanged(ElementChangedEventArgs <OsmMap> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                mapView         = new MapView(Forms.Context, 11);
                activity        = Context as Activity;
                routeCalculator = RouteCalculator.Instance;
                SetNativeControl(mapView);

                //Watercolorstyle map with labels layer
                mapView.SetTileSource(new XYTileSource("OSM", null, 0, 18, 256, ".png",
                                                       new[] { "http://c.tile.stamen.com/watercolor/" }));
                MapTileProviderBasic tileProvider = new MapTileProviderBasic(activity);
                ITileSource          tileSource   = new XYTileSource("MyCustomTiles", null, 1, 16, 256, ".png",
                                                                     new[] { "http://b.sm.mapstack.stamen.com/(watercolor,streets-and-labels)/" });
                tileProvider.TileSource = (tileSource);
                TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, activity.BaseContext);
                tilesOverlay.LoadingBackgroundColor = Color.Transparent;
                mapView.OverlayManager.Add(tilesOverlay);
                mapView.SetMultiTouchControls(true);
                mapView.TilesScaledToDpi = true;

                mapController = (MapController)mapView.Controller;
                mapController.SetCenter(new GeoPoint(AppSharedData.PaderbornCenter.Latitude, AppSharedData.PaderbornCenter.Longitude));
                mapController.SetZoom(AppSharedData.MapZoomLevel);
                mapView.SetMapListener(this);
            }

            if (e.OldElement != null)
            {
                // Unsubscribe
                e.OldElement.ExhibitSetChanged   -= NewElementOnExhibitSetChanged;
                e.OldElement.GpsLocationChanged  -= NewElementOnGpsLocationChanged;
                e.OldElement.DetailsRouteChanged -= NewElementOnDetailsRouteChanged;
            }
            if (e.NewElement != null)
            {
                // Subscribe
                osmMap = e.NewElement;
                osmMap.GpsLocationChanged += NewElementOnGpsLocationChanged;
                NewElementOnGpsLocationChanged(e.NewElement.GpsLocation);
                osmMap.ExhibitSetChanged += NewElementOnExhibitSetChanged;
                NewElementOnExhibitSetChanged(e.NewElement.ExhibitSet);
                osmMap.DetailsRouteChanged += NewElementOnDetailsRouteChanged;
                NewElementOnDetailsRouteChanged(osmMap.DetailsRoute);

                e.NewElement.CenterLocationCalled += CenterMap;
            }
        }
示例#19
0
        /// <summary>
        /// Plans a task. Sets task status = planned, and adjusts rest of the tasks in the employee schedule
        /// </summary>
        /// <param name="targetGroup"></param>
        /// <param name="targetEmployeeSchedule"></param>
        /// <param name="taskToPlan"></param>
        /// <param name="index"></param>
        public void PlanTask(Group targetGroup, EmployeeSchedule targetEmployeeSchedule, TaskItem taskToPlan, int index) // locked? ret så der bruges GetAddress(date) når address er impl. Add methods.
        {
            if (taskToPlan.Locked)
            {
                taskToPlan.State = TaskItem.Status.Unplanned;
                return(false);
            }

            if (index == 0) //first
            {
                targetEmployeeSchedule.TaskItems.Insert(index, taskToPlan);
                taskToPlan.Route = RouteCalculator.GetRouteItem(new Address("Kærvej 2, 7752 Snedsted"), taskToPlan.TaskDescription.Citizen.GetAddress(DateTime.Today));
                taskToPlan.TimePeriod.StartTime = targetEmployeeSchedule.TimePeriod.StartTime;

                for (int i = index + 1; i < targetEmployeeSchedule.TaskItems.Count; i++)
                {
                    AdjustTravelTime(targetEmployeeSchedule.TaskItems[i - 1], targetEmployeeSchedule.TaskItems[i]);
                    if (targetEmployeeSchedule.TaskItems[i].Locked)//ERRORS messes the list up (indexes and placement). TODO
                    {
                        break;
                    }
                    AdjustStartTime(targetEmployeeSchedule.TaskItems[i - 1], targetEmployeeSchedule.TaskItems[i]);
                }
            }
            else if (index == targetEmployeeSchedule.TaskItems.Count)  //last
            {
                targetEmployeeSchedule.TaskItems.Add(taskToPlan);
                AdjustTravelTime(targetEmployeeSchedule.TaskItems[index - 1], taskToPlan);
                AdjustStartTime(targetEmployeeSchedule.TaskItems[index - 1], taskToPlan);
            }

            else
            {
                targetEmployeeSchedule.TaskItems.Insert(index, taskToPlan);

                for (int i = index; i < targetEmployeeSchedule.TaskItems.Count; i++)
                {
                    AdjustTravelTime(targetEmployeeSchedule.TaskItems[i], targetEmployeeSchedule.TaskItems[i + 1]);
                    if (targetEmployeeSchedule.TaskItems[i].Locked)//ERRORS messes the list up (indexes and placement). TODO
                    {
                        break;
                    }
                    AdjustStartTime(targetEmployeeSchedule.TaskItems[i - 1], targetEmployeeSchedule.TaskItems[i]);
                }
            }
            taskToPlan.State = TaskItem.Status.Planned;
            targetEmployeeSchedule.TimePeriod.EndTime = targetEmployeeSchedule.TaskItems.Last <TaskItem>().TimePeriod.EndTime;
            return(true);
        }
示例#20
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);
        }
示例#21
0
        public long StartRouteCalculation([FromBody] AlgorithmStarter algorithmStarter)
        {
            var routeCalculations = RouteCalculationFactory.CreateRouteCalculation(algorithmStarter);

            using (var dbSession = SessionFactory.Instance.OpenSession())
            {
                foreach (var routeCalculation in routeCalculations)
                {
                    var savedRouteCalculation = dbSession.Merge(routeCalculation);
                    routeCalculation.Id = savedRouteCalculation.Id;
                    RouteCalculator.EnqueueRouteCalculation(routeCalculation.Id);
                }
            }

            return(routeCalculations[0].Id);
        }
示例#22
0
        public void B()
        {
            Random one = new Random();
            Random two = new Random();

            for (int i = 0; i < 10000000; i++)
            {
                RouteConnector a = new RouteConnector();
                a.ConnectRoutes();
                RouteCalculator b = new RouteCalculator(a.Nodes);
                int             s = one.Next(0, a.Nodes.Count);
                int             u = two.Next(0, a.Nodes.Count);
                if (s != u)
                {
                    b.FindShortestPath(a.Nodes[s], a.Nodes[u], 0);
                }
            }
            Assert.Pass();
        }
示例#23
0
        protected override void OnElementChanged(ElementChangedEventArgs <OsmMap> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                mapView         = new MapView(Context, 11);
                activity        = Context as Activity;
                routeCalculator = RouteCalculator.Instance;
                SetNativeControl(mapView);

                mapView.SetMultiTouchControls(true);
                mapView.TilesScaledToDpi = true;

                mapController = (MapController)mapView.Controller;
                mapController.SetCenter(new GeoPoint(AppSharedData.PaderbornCenter.Latitude, AppSharedData.PaderbornCenter.Longitude));
                mapController.SetZoom(AppSharedData.MapZoomLevel);
                mapView.SetMapListener(this);
            }

            if (e.OldElement != null)
            {
                // Un-subscribe
                e.OldElement.ExhibitSetChanged   -= NewElementOnExhibitSetChanged;
                e.OldElement.GpsLocationChanged  -= NewElementOnGpsLocationChanged;
                e.OldElement.DetailsRouteChanged -= NewElementOnDetailsRouteChanged;
            }
            if (e.NewElement != null)
            {
                // Subscribe
                osmMap = e.NewElement;
                osmMap.GpsLocationChanged += NewElementOnGpsLocationChanged;
                NewElementOnGpsLocationChanged(e.NewElement.GpsLocation);
                osmMap.ExhibitSetChanged += NewElementOnExhibitSetChanged;
                NewElementOnExhibitSetChanged(e.NewElement.ExhibitSet);
                osmMap.DetailsRouteChanged += NewElementOnDetailsRouteChanged;
                NewElementOnDetailsRouteChanged(osmMap.DetailsRoute);

                e.NewElement.CenterLocationCalled += CenterMap;
            }
        }
示例#24
0
文件: Visitator.cs 项目: danielbj/P3
        /// <summary>
        /// Validates the address through Bing map REST services.
        /// </summary>
        /// <param name="address">Address that as to be validated</param>
        /// <returns></returns>
        private bool ValidateAddress(string address)
        {
            RouteCalculator routeCalc = new RouteCalculator(); //TODO lav det statisk!! det her er noget rod...

            return(routeCalc.ValidateLocation(address));
        }
        /// <summary>
        /// Realiza cálculo das rotas
        /// </summary>
        public bool CalcularRotas()
        {
            //Abrindo tela de configuração da rota na viewer
            DadosCalculoRotaTO dadosCalculoRota =  _View.ShowConfiguracaoRota();

            //Se for nulo indica que houve um cancelamento na tela de configurações da rota
            if (dadosCalculoRota == null)
                return false;

            //Crinado objeto de cálculo de rotas da biblioteca MapLinkLib
            RouteCalculator roteCalculator = new RouteCalculator()
            {
                Pedagio = (CategoriaPedagio)dadosCalculoRota.CategoriaPedagio,

                TipoDeRota = dadosCalculoRota.IsRotaEvitaTransito ?
                    TipoRota.EvitandoTransito : TipoRota.PadraoMaisRapida
            };

            roteCalculator.Veiculo.CapacidadeTanqueComb = dadosCalculoRota.CapacidadeTanqueComb;
            roteCalculator.Veiculo.ConsumoMedio = dadosCalculoRota.ConsumoMedio;
            roteCalculator.Veiculo.PrecoCombustivel = dadosCalculoRota.PrecoCombustivel;
            roteCalculator.Veiculo.VelocidadeMedia = dadosCalculoRota.VelocidadeMedia;

            this.RotasCalculadas.Clear();

            _View.ModoProcessando = true;
            try
            {
                //Calculando Rotas
                roteCalculator.Consultar(_lstEnderecos).ForEach(rota =>
                {
                    //Atualizando lista de resultados
                    this.RotasCalculadas.Add(new RotasTO()
                    {
                        CustoCombustivel = rota.CustoCombustivel,
                        CustoTotal = rota.CustoTotal,
                        DistanciaTotal = rota.DistanciaTotal,
                        EnderecoDestino = rota.EnderecoDestino.ObterStringEndereco(),
                        EnderecoOrigem = rota.EnderecoOrigem.ObterStringEndereco(),
                        TempoTotal = rota.TempoTotal
                    });
                });
            }
            finally
            {
                _View.ModoProcessando = false;
            }

            return true;
        }
示例#26
0
 public TravelController(IDistanceCalculator distanceCalculator)
 {
     this.distanceCalculator = distanceCalculator;
     this.routeCalculator    = new RouteCalculator(distanceCalculator);
 }
示例#27
0
 /// <summary>
 /// Updates travelTime in a task, according to previous task.
 /// </summary>
 /// <param name="previousTask"></param>
 /// <param name="task"></param>
 private void AdjustTravelTime(TaskItem previousTask, TaskItem task)
 {
     task.Route = RouteCalculator.GetRouteItem(previousTask.TaskDescription.Citizen.GetAddress(DateTime.Today), task.TaskDescription.Citizen.GetAddress(DateTime.Today)); // todo date på addresse
 }