예제 #1
0
        protected void ShowViaje(Intercalado viaje, int selectedId)
        {
            var color  = GetColor(viaje.Id);
            var line   = new Line("v" + viaje.Id, StyleFactory.GetLineFromColor(color, 4, 0.5));
            var distri = DAOFactory.ViajeDistribucionDAO.FindById(viaje.Id);

            // Agrego los markers de las entregas
            var ordenEntrega = 1;

            foreach (var entrega in distri.Detalles)
            {
                var imageUrl = GetImageUrl(color, ordenEntrega++);
                AddMarker(entrega, imageUrl);
            }

            // Agrego las lineas de recorrido
            var recorrido = viaje.Id == selectedId ? viaje.ViajeIntercalado : viaje.ViajeAnterior;

            if (recorrido != null)
            {
                var stepCount = 0;
                var steps     = recorrido.Legs.SelectMany(l => l.Steps);
                var puntos    = steps.SelectMany(s => s.Points)
                                .Select(p => new Point((stepCount++).ToString("0"), p.Longitud, p.Latitud));
                line.AddPoints(puntos);
                Monitor1.AddGeometries(LayerRecorrido, line);
            }
        }
예제 #2
0
        public void DrawViajeProgramado(int idViajeProgramado)
        {
            Monitor.ClearLayer(LayerViajeProgramado);
            if (idViajeProgramado > 0)
            {
                var viaje = DAOFactory.ViajeProgramadoDAO.FindById(idViajeProgramado);
                if (viaje != null)
                {
                    var count = viaje.Detalles.Count;
                    if (count > 1)
                    {
                        var primero   = viaje.Detalles[0].PuntoEntrega;
                        var ultimo    = viaje.Detalles[count - 1].PuntoEntrega;
                        var origen    = new LatLon(primero.ReferenciaGeografica.Latitude, primero.ReferenciaGeografica.Longitude);
                        var destino   = new LatLon(ultimo.ReferenciaGeografica.Latitude, ultimo.ReferenciaGeografica.Longitude);
                        var waypoints = new List <LatLon>();
                        for (int i = 1; i < count - 1; i++)
                        {
                            var punto    = viaje.Detalles[i].PuntoEntrega;
                            var waypoint = new LatLon(punto.ReferenciaGeografica.Latitude, punto.ReferenciaGeografica.Longitude);
                            waypoints.Add(waypoint);
                        }

                        var directions = GoogleDirections.GetDirections(origen, destino, GoogleDirections.Modes.Driving, string.Empty, waypoints.ToArray());
                        var posiciones = directions.Legs.SelectMany(l => l.Steps.SelectMany(s => s.Points));
                        var line       = new Line("D:" + Color.Red.ToArgb(), StyleFactory.GetLineFromColor(Color.Red, 4, 0.5));
                        line.AddPoints(posiciones.Select(p => new Point("", p.Longitud, p.Latitud)));
                        Monitor.AddGeometries(LayerViajeProgramado, line);
                        Monitor.SetCenter(destino.Latitud, destino.Longitud);
                    }
                }
            }
        }
예제 #3
0
        public void SetLine(List <PointF> points)
        {
            var line = new Line("Recorrido", StyleFactory.GetLineFromColor(Color.Blue, 7, 0.7));

            foreach (var p in points)
            {
                line.AddPoint(new Point("", p.X, p.Y));
            }
            Monitor.AddGeometries(LayerRecorrido, line);
            Points.Set(points);
            AddMarkers();
        }
예제 #4
0
        private void ShowRecorrido(bool recalcularValores)
        {
            monitor.ClearLayer(LayerRecorrido);
            var count = lstAsignadas.Items.Count;

            if (count > 1)
            {
                var primero   = DAOFactory.PuntoEntregaDAO.FindById(Convert.ToInt32(lstAsignadas.Items[0].Value));
                var ultimo    = DAOFactory.PuntoEntregaDAO.FindById(Convert.ToInt32(lstAsignadas.Items[count - 1].Value));
                var origen    = new LatLon(primero.ReferenciaGeografica.Latitude, primero.ReferenciaGeografica.Longitude);
                var destino   = new LatLon(ultimo.ReferenciaGeografica.Latitude, ultimo.ReferenciaGeografica.Longitude);
                var waypoints = new List <LatLon>();
                for (int i = 1; i < count - 1; i++)
                {
                    var punto    = DAOFactory.PuntoEntregaDAO.FindById(Convert.ToInt32(lstAsignadas.Items[i].Value));
                    var waypoint = new LatLon(punto.ReferenciaGeografica.Latitude, punto.ReferenciaGeografica.Longitude);
                    waypoints.Add(waypoint);
                }

                var directions = GoogleDirections.GetDirections(origen, destino, GoogleDirections.Modes.Driving, string.Empty, waypoints.ToArray());
                var posiciones = directions.Legs.SelectMany(l => l.Steps.SelectMany(s => s.Points));
                var line       = new Line("D:" + Color.Red.ToArgb(), StyleFactory.GetLineFromColor(Color.Red, 4, 0.5));
                line.AddPoints(posiciones.Select(p => new Point("", p.Longitud, p.Latitud)));

                Points.Set(posiciones.Select(p => new PointF((float)p.Longitud, (float)p.Latitud)).ToList());

                monitor.AddGeometries(LayerRecorrido, line);

                if (recalcularValores)
                {
                    var ts = directions.Duration;
                    txtHoras.Text = ((int)Math.Truncate(ts.TotalHours)).ToString("00") + ":" + ((int)(ts.Minutes)).ToString("00") + ":" + ((int)(ts.Seconds)).ToString("00");
                    txtKm.Text    = (directions.Distance / 1000.00).ToString("#0.00");
                }
            }
            else
            {
                if (recalcularValores)
                {
                    txtHoras.Text = "00:00:00";
                    txtKm.Text    = "0.00";
                }
            }
        }
예제 #5
0
        private void AddPositions(IList <List <RoutePosition> > routes, Color color, string layerName)
        {
            RoutePosition lastPosition = null;

            for (var i = 0; i < routes.Count; i++)
            {
                if (routes[i].Count > 0)
                {
                    _fechasRecorridos.Add(routes[i][routes[i].Count - 1].Date);
                }

                var lineId    = i.ToString(CultureInfo.InvariantCulture);
                var routeLine = new Line(lineId, StyleFactory.GetLineFromColor(color));

                for (var j = 0; j < routes[i].Count; j++)
                {
                    var currentPosition = routes[i][j];
                    if (lastPosition != null)
                    {
                        if (currentPosition.EqualsPosition(lastPosition))
                        {
                            lastPosition = currentPosition;
                            continue;
                        }
                    }

                    routeLine.AddPoint(new Point(j.ToString(CultureInfo.InvariantCulture), currentPosition.Longitude, currentPosition.Latitude));
                    lastPosition = currentPosition;
                }

                Monitor.AddGeometries(layerName, routeLine);
            }

            _x = routes[0][0].Latitude;
            _y = routes[0][0].Longitude;

            Monitor.SetDefaultCenter(_x, _y);
        }
예제 #6
0
        private void AddPositions(IList <List <RoutePosition> > routes)
        {
            //var maxTimeBetweenPositions = TimeSpan.FromMinutes(15);
            //var maxDistanceBetweenPositions = 500;


            var colorGenerator = new ColorGenerator(new List <Color> {
                Color.Yellow, Color.Orange
            });
            //var subid = 1;
            RoutePosition lastPosition = null;

            for (var i = 0; i < routes.Count; i++)
            {
                if (routes[i].Count > 0)
                {
                    _fechasRecorridos.Add(routes[i][routes[i].Count - 1].Date);
                }

                var color     = colorGenerator.GetNextColor();
                var lineId    = i.ToString(CultureInfo.InvariantCulture);
                var routeLine = new Line(lineId, StyleFactory.GetLineFromColor(color));


                for (var j = 0; j < routes[i].Count; j++)
                {
                    var currentPosition = routes[i][j];
                    if (lastPosition != null)
                    {
                        if (currentPosition.EqualsPosition(lastPosition))
                        {
                            lastPosition = currentPosition;
                            continue;
                        }
                        //var tiempo = currentPosition.Date.Subtract(lastPosition.Date);
                        //if (tiempo > maxTimeBetweenPositions ||
                        //    Distancias.Loxodromica(lastPosition.Latitude, lastPosition.Longitude,
                        //    currentPosition.Latitude, currentPosition.Longitude) > maxDistanceBetweenPositions)
                        //{
                        //    Monitor.AddGeometries(_recorrido, routeLine);

                        //    routeLine = new Line(string.Format("{0}_{1}",lineId, (subid++)), StyleFactory.GetDottedLineFromColor(color));
                        //    routeLine.AddPoint(new Point(string.Format("{0}_{1}", lineId, (subid++)), lastPosition.Longitude, lastPosition.Latitude));
                        //    routeLine.AddPoint(new Point(string.Format("{0}_{1}", lineId, (subid++)), currentPosition.Longitude, currentPosition.Latitude));
                        //    Monitor.AddGeometries(_recorrido, routeLine);

                        //    routeLine = new Line(string.Format("{0}_{1}", lineId, (subid++)), StyleFactory.GetLineFromColor(color));
                        //}
                    }

                    routeLine.AddPoint(new Point(j.ToString(CultureInfo.InvariantCulture), currentPosition.Longitude, currentPosition.Latitude));
                    lastPosition = currentPosition;
                }

                Monitor.AddGeometries(Layers.Recorrido, routeLine);
            }

            _x = routes[0][0].Latitude;
            _y = routes[0][0].Longitude;

            Monitor.SetDefaultCenter(_x, _y);
        }