private void DrawCircle(ReferenciaGeografica geocerca, Color color)
        {
            var point    = geocerca.Poligono.FirstPoint;
            var poligono = new Point(string.Format("POINT_{0}", geocerca.Id), point.X, point.Y, geocerca.Poligono.Radio, StyleFactory.GetPointFromColor(color));

            Monitor.AddGeometries(Layers.Geocercas, poligono);
        }
Beispiel #2
0
 void Monitor_ContextMenuPostback(object sender, PostbackEventArgs e)
 {
     if (!Directory.Exists(QtreeFullPath))
     {
         return;
     }
     if (e.CommandArguments == "Info" && btInfo.Enabled)
     {
         ChangeState(QtreeEditorState.Info);
         ShowLeafInfo(e.Latitud, e.Longitud);
     }
     else if (e.CommandArguments == "ColorPick" && btPickColor.Enabled)
     {
         SelectColor(e.Latitud, e.Longitud);
     }
     else if (e.CommandArguments == "Lock" && btEdit.Enabled)
     {
         ToggleLock(e.Latitud, e.Longitud);
     }
     else if (e.CommandArguments == "Paint" && btEdit.Enabled)
     {
         using (var qtree = BaseQtree.Open(QtreeFullPath, Format))
         {
             var leaf = qtree.GetQLeaf(e.Latitud, e.Longitud);
             Monitor.AddGeometries(LayerGeocercas, GetPolygon(leaf));
         }
     }
 }
Beispiel #3
0
 private void AddLeaves(IEnumerable <QLeaf> leaves)
 {
     foreach (var leaf in leaves)
     {
         Monitor.AddGeometries(LayerGeocercas, GetPolygon(leaf));
     }
 }
Beispiel #4
0
 void Monitor_DrawSquare(object sender, MonitorDrawSquareEventArgs e)
 {
     if (CurrentState == QtreeEditorState.Edit)
     {
         if (!Directory.Exists(QtreeFullPath))
         {
             return;
         }
         var points = new List <PointF>
         {
             new PointF((float)e.Bounds.Left, (float)e.Bounds.Top),
             new PointF((float)e.Bounds.Right, (float)e.Bounds.Top),
             new PointF((float)e.Bounds.Right, (float)e.Bounds.Bottom),
             new PointF((float)e.Bounds.Left, (float)e.Bounds.Bottom),
             new PointF((float)e.Bounds.Left, (float)e.Bounds.Top)
         };
         DrawPolygon(points);
     }
     else if (CurrentState == QtreeEditorState.CreatingQtree)
     {
         NewQtreeBounds = e.Bounds;
         var pol = new Polygon("square", StyleFactory.GetPolygonFromColor(Color.Red, Color.DarkRed));
         pol.AddPoint(new Point("0", e.Bounds.Left, e.Bounds.Top));
         pol.AddPoint(new Point("1", e.Bounds.Right, e.Bounds.Top));
         pol.AddPoint(new Point("2", e.Bounds.Right, e.Bounds.Bottom));
         pol.AddPoint(new Point("3", e.Bounds.Left, e.Bounds.Bottom));
         pol.AddPoint(new Point("4", e.Bounds.Left, e.Bounds.Top));
         Monitor.AddGeometries(LayerGeocercas, pol);
     }
 }
Beispiel #5
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);
                    }
                }
            }
        }
Beispiel #6
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();
        }
Beispiel #7
0
        protected void AddCircle(int id, PointF point, int radio, string layer, Color color)
        {
            if (radio <= 0)
            {
                return;
            }

            var poly = new Point(id.ToString("#0"), point.X, point.Y, radio, StyleFactory.GetPointFromColor(color));

            Monitor.AddGeometries(layer, poly);
            Monitor.SetCenter(point.Y, point.X);
        }
        private void DrawPolygon(ReferenciaGeografica geocerca, Color color)
        {
            var poligono = new Polygon(string.Format("POLYGON_{0}", geocerca.Id), StyleFactory.GetPointFromColor(color));

            var points = geocerca.Poligono.ToPointFList();

            for (var i = 0; i < points.Count; i++)
            {
                poligono.AddPoint(new Point(string.Format("{0}_{1}", geocerca.Id, i), points[i].X, points[i].Y));
            }

            Monitor.AddGeometries(Layers.Geocercas, poligono);
        }
        private void AddMessageWithElapsedTime(Infraccion mobileEvent, IEnumerable <List <RoutePosition> > routes)
        {
            var positions = GetMessagePositions(mobileEvent, routes);

            var line = new Line(mobileEvent.Fecha.ToString(), StyleFactory.GetRedLine());

            line.AddPoint(new Point(mobileEvent.Fecha.ToString(), mobileEvent.Longitud, mobileEvent.Latitud));

            for (var i = 0; i < positions.Count; i++)
            {
                line.AddPoint(new Point(i.ToString("#0"), positions[i].Longitude, positions[i].Latitude));
            }

            line.AddPoint(new Point(mobileEvent.FechaFin.Value.ToString(), mobileEvent.LongitudFin, mobileEvent.LatitudFin));

            Monitor.AddGeometries(Layers.MensajesDuracion, line);
        }
Beispiel #10
0
        protected void AddPolygon(int id, List <PointF> points, string layer, Color color)
        {
            if (points == null || points.Count == 0)
            {
                return;
            }

            var poly = new Polygon(id.ToString("#0"), StyleFactory.GetPointFromColor(color));

            for (var i = 0; i < points.Count; i++)
            {
                poly.AddPoint(new Point(i.ToString("#0"), points[i].X, points[i].Y));
            }

            Monitor.AddGeometries(layer, poly);
            Monitor.SetCenter(points.Last().Y, points.Last().X);
        }
Beispiel #11
0
 protected void ShowQTree(Box box)
 {
     using (var qtree = BaseQtree.Open(QtreeFullPath, Format))
     {
         for (var i = box.Bottom; i < box.Top; i++)
         {
             for (var j = box.Left; j < box.Right; j++)
             {
                 var latlon = qtree.GetCenterLatLon(new QIndex {
                     Y = i, X = j
                 });
                 var leaf = qtree.GetQLeaf(latlon.Latitud, latlon.Longitud);
                 if (leaf == null)
                 {
                     continue;
                 }
                 Monitor.AddGeometries(LayerGeocercas, GetPolygon(leaf));
             }
         }
     }
 }
Beispiel #12
0
        private void AddReferenciaGeografica(string layerPoi, string layerArea, ReferenciaGeografica dom, string popupContent)
        {
            if (dom.Poligono != null)
            {
                var center = dom.Poligono.FirstPoint;
                var col    = StyleFactory.GetPointFromColor(dom.Color.Color);
                var id     = dom.Id + "_GEO";

                if (dom.Poligono.Radio > 0)
                {
                    Monitor.AddGeometries(layerArea, new Point(id, center.X, center.Y, dom.Poligono.Radio, col));
                }
                else
                {
                    var points = dom.Poligono.ToPointFList();
                    var poly   = new Polygon(id, col);
                    for (var i = 0; i < points.Count; i++)
                    {
                        poly.AddPoint(new Point(id + "_" + i, points[i].X, points[i].Y));
                    }

                    Monitor.AddGeometries(layerArea, poly);
                }
            }

            if (dom.Direccion == null)
            {
                return;
            }

            var icono  = dom.Icono != null ? IconDir + dom.Icono.PathIcono : string.Empty;
            var marker = new Marker(dom.Id.ToString("#0"),
                                    icono,
                                    dom.Direccion.Latitud,
                                    dom.Direccion.Longitud,
                                    popupContent,
                                    DrawingFactory.GetSize(dom.Icono != null ? dom.Icono.Width : 0, dom.Icono != null ? dom.Icono.Height : 0), DrawingFactory.GetOffset(dom.Icono != null ? dom.Icono.OffsetX : 0, dom.Icono != null ? dom.Icono.OffsetY : 0));

            Monitor.AddMarkers(layerPoi, marker);
        }
Beispiel #13
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);
        }
Beispiel #14
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);
        }