This project has moved. For the latest updates, please go here.

Select a feature

Topics: Algorithms, CompactFramework, Data Access, General Topics, SharpMap Project, SharpMap v2.0, WinForms Controls
May 12, 2010 at 12:35 AM

Hi All, Im trying to select a feature based on a unique id of its dbf, I was trying reading the layer.datasource Im having some errors reading the rows... any idea?

May 12, 2010 at 3:53 AM

This is the code I currently have, with this code I read the code I need to search, but the select and zoom to feature it oesnt working yet... any idea? thanks guys...


            string value = "";
            if (Tmp.InputBox("Client Search", "Code :", ref value) == DialogResult.OK)
                this.Name = value;

            int idSel = Convert.ToInt32(this.Name);

            ShapeFile sf = new ShapeFile("C:\\Christian\\shapes\\melvin.shp");

            sf.FilterDelegate = delegate(FeatureDataRow row)
                return Convert.ToInt32(row["Id"]) == idSel;

            SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet();

            SharpMap.Geometries.BoundingBox bbox = sf.GetExtents();
            sf.ExecuteIntersectionQuery(bbox, ds);


            SharpMap.Data.FeatureDataTable tbl = ds.Tables[0] as SharpMap.Data.FeatureDataTable;
            SharpMap.Layers.VectorLayer testLayer = new SharpMap.Layers.VectorLayer("Results");
            testLayer.DataSource = new SharpMap.Data.Providers.GeometryFeatureProvider(tbl);

            testLayer.Style.Fill = new SolidBrush(Color.White);