Example #1
0
        private static VectorLayer CrearCapaTemaAdscripcion(IUnidadGeoEstadistica uge)
        {
            if (uge is PlantaEdificio)
            {
                PlantaEdificio pe = (PlantaEdificio)uge;
                //Montar la consulta de los dptos ordenados por superficie
                _dsTemas      = pe.EstadisticaDepartamentosSIGUA();
                _capaTemaAdsc = new SharpMap.Layers.VectorLayer(pe.Codigo);
                SharpMap.Data.Providers.PostGIS proveedorPostgis = new SharpMap.Data.Providers.PostGIS(SIGUANETDesktop.DB.DBUtils.GetPGSQLCnString(), "sig" + pe.Planta.ToString().ToLower(), "gid");
                proveedorPostgis.DefinitionQuery = string.Format("codigo like '{0}%' AND actividad <> 93", pe.Codigo);
                _capaTemaAdsc.DataSource         = proveedorPostgis;
                //Llama a la función delegada para pintar adscripcion
                CustomTheme generadorEstilos = new SharpMap.Rendering.Thematics.CustomTheme(CrearEstiloPorAdscripcion);
                VectorStyle estiloPorDefecto = SIGUANETDesktop.ModeloCartografia.Simbologia.Paleta.obtenerEstiloPorDefecto(_paleta);
                generadorEstilos.DefaultStyle = estiloPorDefecto;

                _capaTemaAdsc.Theme = generadorEstilos;

                NuevaEntradaLeyendaTematica(TipoMapa.TemaAdscripcion, _capaTemaAdsc.LayerName, _capaTemaAdsc, "Temático por Adscripción", EntradaLeyendaTematica.TipoOrdenacion.Descendente);
                return(_capaTemaAdsc);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        public void OnAddRoadsLayer()
        {
            if (_view.GetLayerByName(Constants.roadsLayerName) != null)
            {
                return;
            }

            SharpMap.Data.Providers.PostGIS postGisProv = new
                                                          SharpMap.Data.Providers.PostGIS(Constants.connStr, Constants.roadsTable, Constants.geomName, Constants.idName)
            {
                DefinitionQuery = "fclass = 'primary' or fclass = 'secondary' or fclass = 'motorway_link'"
            };

            VectorLayer roadsLayer = new VectorLayer(Constants.roadsLayerName)
            {
                DataSource = postGisProv
            };

            System.Drawing.Pen primaryRoadPen = new System.Drawing.Pen(new System.Drawing.SolidBrush(System.Drawing.Color.Red))
            {
                Width = 1.5f
            };

            Dictionary <string, IStyle> styles = new Dictionary <string, IStyle>()
            {
                { "primary", new VectorStyle()
                  {
                      Line = primaryRoadPen
                  } },
                { "secondary", new VectorStyle()
                  {
                      Line = System.Drawing.Pens.Orange
                  } },
                { "motorway_link", new VectorStyle()
                  {
                      Line = System.Drawing.Pens.Olive
                  } }
            };

            roadsLayer.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme <string>("fclass",
                                                                                           styles, null);

            LabelLayer roadLabel = new LabelLayer(Constants.roadsLabelName)
            {
                DataSource  = roadsLayer.DataSource,
                Enabled     = true,
                LabelColumn = "name",
                MaxVisible  = 0.3f
            };

            //SetCtAndRct(roadsLayer);
            //SetCtAndRct(roadLabel);

            _view.AddLayer(roadsLayer);
            _view.AddLayer(roadLabel);
        }
Example #3
0
        // NPGSQL EXCEPTION - BAD GEOMETRY FORMATING IN THE RESULTING QUERY && TABLE NAMES MUST BE ALTERED NOT TO CONTAIN ""
        private void GetGeometryIntersections(IGeometry geometry)
        {
            SharpMap.Data.Providers.PostGIS postGisProv = new
                                                          SharpMap.Data.Providers.PostGIS(Constants.connStr, _activeLayer, Constants.geomName, Constants.idName);

            SharpMap.Data.FeatureDataSet fds = new SharpMap.Data.FeatureDataSet();
            postGisProv.Open();
            postGisProv.ExecuteIntersectionQuery(geometry, fds);
            postGisProv.Close();

            //System.Windows.Forms.MessageBox.Show(fds.Tables[0].Rows.Count.ToString());

            _view.DataGridView = fds.Tables[0];
        }
Example #4
0
 private static VectorLayer CrearCapaCentroidesEdificio(IUnidadGeoEstadistica uge)
 {
     if (uge is PlantaEdificio)
     {
         PlantaEdificio pe = (PlantaEdificio)uge;
         VectorLayer    capaCentroidesEdificio            = new SharpMap.Layers.VectorLayer(NOMCAPA_CENTROIDES);
         SharpMap.Data.Providers.PostGIS proveedorPostgis = new SharpMap.Data.Providers.PostGIS(SIGUANETDesktop.DB.DBUtils.GetPGSQLCnString(), "quest_estancias_label", "codigo");
         proveedorPostgis.DefinitionQuery  = string.Format("codigo like '{0}%'", pe.Codigo);
         capaCentroidesEdificio.DataSource = proveedorPostgis;
         return(capaCentroidesEdificio);
     }
     else
     {
         return(null);
     }
 }
Example #5
0
 private static VectorLayer CrearCapaEdificioMuro(IUnidadGeoEstadistica uge)
 {
     if (uge is PlantaEdificio)
     {
         PlantaEdificio pe = (PlantaEdificio)uge;
         VectorLayer    capaEdificioMuro = new SharpMap.Layers.VectorLayer(pe.Codigo + "000");
         SharpMap.Data.Providers.PostGIS proveedorPostgis = new SharpMap.Data.Providers.PostGIS(SIGUANETDesktop.DB.DBUtils.GetPGSQLCnString(), "sig" + pe.Planta.ToString().ToLower(), "gid");
         proveedorPostgis.DefinitionQuery = string.Format("codigo = '{0}000'", pe.Codigo);
         capaEdificioMuro.DataSource      = proveedorPostgis;
         SimbLayEdificioMuro s = new SimbLayEdificioMuro();
         capaEdificioMuro.Enabled = s.visible;
         capaEdificioMuro.Style   = ObtenerEstilo(TipoPaleta.predeterminada, s);
         NuevaEntradaLeyendaBD(capaEdificioMuro.LayerName, capaEdificioMuro, s.titulo);
         return(capaEdificioMuro);
     }
     else
     {
         return(null);
     }
 }
Example #6
0
        private static VectorLayer CrearCapaTemaUsos(IUnidadGeoEstadistica uge)
        {
            if (uge is PlantaEdificio)
            {
                PlantaEdificio pe = (PlantaEdificio)uge;
                _capaTemaUsos = new SharpMap.Layers.VectorLayer(pe.Codigo);
                SharpMap.Data.Providers.PostGIS proveedorPostgis = new SharpMap.Data.Providers.PostGIS(SIGUANETDesktop.DB.DBUtils.GetPGSQLCnString(), "sig" + pe.Planta.ToString().ToLower(), "gid");
                proveedorPostgis.DefinitionQuery = string.Format("codigo like '{0}%' AND actividad <> 93", pe.Codigo);
                _capaTemaUsos.DataSource         = proveedorPostgis;

                CustomTheme generadorEstilos = new SharpMap.Rendering.Thematics.CustomTheme(CrearEstiloPorActividad);
                VectorStyle estiloPorDefecto = SIGUANETDesktop.ModeloCartografia.Simbologia.Paleta.obtenerEstiloPorDefecto(_paleta);
                generadorEstilos.DefaultStyle = estiloPorDefecto;

                _capaTemaUsos.Theme = generadorEstilos;

                NuevaEntradaLeyendaTematica(TipoMapa.TemaUso, _capaTemaUsos.LayerName, _capaTemaUsos, "Temático por Uso", EntradaLeyendaTematica.TipoOrdenacion.Ascendente);
                return(_capaTemaUsos);
            }
            else
            {
                return(null);
            }
        }
Example #7
0
        public void OnQueryLayer(string query, System.Drawing.Color resultColor)
        {
            // Create the postGis provider object, and init it's query property with the passed query
            SharpMap.Data.Providers.PostGIS postGisProv = new
                                                          SharpMap.Data.Providers.PostGIS(Constants.connStr, _activeLayer, Constants.geomName, Constants.idName)
            {
                DefinitionQuery = query
            };

            SharpMap.Rendering.Thematics.ITheme theme = null;
            System.Drawing.Brush queryResultBrush     = new System.Drawing.SolidBrush(resultColor);

            // Create a theme based on the active layer
            if (_activeLayer == Constants.roadsTable)
            {
                System.Drawing.Pen queryResultPen = new System.Drawing.Pen(queryResultBrush);
                theme = new SharpMap.Rendering.Thematics.CustomTheme((SharpMap.Data.FeatureDataRow fdr)
                                                                     => { return(new VectorStyle()
                    {
                        Line = queryResultPen
                    }); });
            }
            else if (_activeLayer == Constants.nrTable)
            {
                theme = new SharpMap.Rendering.Thematics.CustomTheme((SharpMap.Data.FeatureDataRow fdr)
                                                                     => { return(new VectorStyle()
                    {
                        PointColor = queryResultBrush, PointSize = 3f
                    }); });
            }
            else
            {
                theme = new SharpMap.Rendering.Thematics.CustomTheme((SharpMap.Data.FeatureDataRow fdr)
                                                                     => { return(new VectorStyle()
                    {
                        Fill = queryResultBrush
                    }); });
            }

            // Create the resulting vector layer object for query result, and set the created theme
            VectorLayer resultingLayer = new VectorLayer(Constants.queryLayerName)
            {
                DataSource = postGisProv,
                Theme      = theme
            };

            // Create label of the results
            LabelLayer resultingLabel = new LabelLayer(Constants.queryLabelName)
            {
                DataSource  = resultingLayer.DataSource,
                Enabled     = true,
                LabelColumn = "name",
                MaxVisible  = 0.3f
            };

            try
            {
                // NPGSQL exception handle ruins the map by returning an empty layer
                // Getting an envelope when query is invalid triggers an exception
                SharpMap.Data.FeatureDataSet fds = new SharpMap.Data.FeatureDataSet();
                postGisProv.Open();
                Envelope envelope = resultingLayer.Envelope; // <----- Exception
                postGisProv.ExecuteIntersectionQuery(envelope, fds);
                postGisProv.Close();

                // Remove the previous query result if it exists
                OnRemoveLayer(Constants.queryLayerName);
                OnRemoveLayer(Constants.queryLabelName);

                // Add the results to the map
                _view.AddLayer(resultingLayer);
                _view.AddLayer(resultingLabel);
                _view.DataGridView = fds.Tables[0];
            }
            catch (System.Exception e)
            {
                System.Console.Write(e.Message);
                return;
            }
        }
Example #8
0
        public void OnAddWatersLayer()
        {
            if (_view.GetLayerByName(Constants.watersLayerName) != null)
            {
                return;
            }

            SharpMap.Data.Providers.PostGIS postGisProv = new
                                                          SharpMap.Data.Providers.PostGIS(Constants.connStr, Constants.watersTable, Constants.geomName, Constants.idName);

            VectorLayer watersLayer = new VectorLayer(Constants.watersLayerName)
            {
                DataSource = postGisProv
            };

            System.Drawing.Brush riverBrush     = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(59, 179, 208));
            System.Drawing.Brush wetlandBrush   = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(59, 151, 128));
            System.Drawing.Brush dockBrush      = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(164, 164, 132));
            System.Drawing.Brush reservoirBrush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(0, 132, 255));
            System.Drawing.Brush waterBrush     = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(64, 164, 223));

            Dictionary <string, IStyle> styles = new Dictionary <string, IStyle>()
            {
                { "wetland", new VectorStyle()
                  {
                      Fill = wetlandBrush
                  } },
                { "reservoir", new VectorStyle()
                  {
                      Fill = reservoirBrush
                  } },
                { "dock", new VectorStyle()
                  {
                      Fill = dockBrush
                  } },
                { "river", new VectorStyle()
                  {
                      Fill = riverBrush
                  } },
                { "water", new VectorStyle()
                  {
                      Fill = waterBrush
                  } }
            };

            watersLayer.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme <string>("fclass",
                                                                                            styles, null);

            LabelLayer watersLabel = new LabelLayer(Constants.watersLabelName)
            {
                DataSource  = watersLayer.DataSource,
                Enabled     = true,
                LabelColumn = "name",
                MaxVisible  = 0.3f
            };

            //SetCtAndRct(watersLayer);
            //SetCtAndRct(watersLabel);

            _view.AddLayer(watersLayer);
            _view.AddLayer(watersLabel);
        }
Example #9
0
        public void OnAddNRLayer()
        {
            if (_view.GetLayerByName(Constants.nrLayerName) != null)
            {
                return;
            }

            SharpMap.Data.Providers.PostGIS postGisProv = new
                                                          SharpMap.Data.Providers.PostGIS(Constants.connStr, Constants.nrTable, Constants.geomName, Constants.idName);

            VectorLayer nrLayer = new VectorLayer(Constants.nrLayerName)
            {
                DataSource = postGisProv
            };

            // Define style for each fclass of natural resource
            Dictionary <string, IStyle> styles = new Dictionary <string, IStyle>()
            {
                { "cave_entrance", new VectorStyle()
                  {
                      Symbol = Properties.Resources.cave
                  } },
                { "tree", new VectorStyle()
                  {
                      Symbol = Properties.Resources.tree, SymbolScale = 0.8f
                  } },
                { "peak", new VectorStyle()
                  {
                      Symbol = Properties.Resources.peak, SymbolScale = 0.7f
                  } },
                { "spring", new VectorStyle()
                  {
                      Symbol = Properties.Resources.water
                  } },
                { "beach", new VectorStyle()
                  {
                      Symbol = Properties.Resources.beach
                  } },
                { "cliff", new VectorStyle()
                  {
                      Symbol = Properties.Resources.cliff
                  } }
            };

            nrLayer.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme <string>("fclass",
                                                                                        styles, null);

            LabelLayer nrLabel = new LabelLayer(Constants.nrLabelName)
            {
                DataSource  = nrLayer.DataSource,
                Enabled     = true,
                LabelColumn = "name",
                MaxVisible  = 0.3f
            };

            //SetCtAndRct(nrLayer);
            //SetCtAndRct(nrLabel);

            _view.AddLayer(nrLayer);
            _view.AddLayer(nrLabel);
        }