find Geometry properties

Topics: SharpMap v0.9 / v1.x
Editor
Jun 18, 2012 at 7:36 AM
Edited Jun 18, 2012 at 7:37 AM

 

Hi All,
i using sharpmap-0.9,
why I can not find  Geometry properties from FeatureDataSet


var DataProvider = new SharpMap.Data.Providers.PostGIS(ConnectionString, "GisData", "geo", "geoid");
            
            SharpMap.Layers.VectorLayer layFind = new SharpMap.Layers.VectorLayer("finds", DataProvider);
            var streetsLayer = layFind ;
            //In your query function
            var bbox = DataProvider.GetExtents();
            DataProvider.DefinitionQuery = string.Format("\"geoid \" like '{0}'", value);
            var ds = new SharpMap.Data.FeatureDataSet();
            DataProvider.ExecuteIntersectionQuery(bbox, ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                var fdr = ds.Tables[0].Rows[0];                
                var bb = fdr.Geometry.GetBoundingBox();
                DisplayMap.Map.ZoomToBox(bbox);

            }
Editor
Jun 18, 2012 at 8:12 AM

I had fixed, here my code:

 

private void ZoomToSelectedFeature(SharpMap.Map _map, object value)
        {
            var DataProvider  = new SharpMap.Data.Providers.PostGIS(ConnectionString, "GisData ", "geo", "geoid");
            SharpMap.Layers.VectorLayer layFind = new SharpMap.Layers.VectorLayer("finds", DataProvider);
            //query function
            var bbox = DataProvider.GetExtents();
            DataProvider.DefinitionQuery = string.Format("\"geoid\" like '{0}'", value);
            var ds = new SharpMap.Data.FeatureDataSet();
            DataProvider.ExecuteIntersectionQuery(bbox, ds);
            if (ds.Tables[0].Rows.Count > 0)
            {                 
                SharpMap.Data.FeatureDataRow selectedFeature = ds.Tables[0].Rows[0] as SharpMap.Data.FeatureDataRow;
                var bb = selectedFeature.Geometry.GetBoundingBox();
                bb = bb.Grow(50, 50);
                _map.ZoomToBox(bb);
            }
}

 

But when I zoom the map display becomes white.And nothing is visible.Is it because of the zoom scale?

 


Editor
Jun 18, 2012 at 10:37 AM

I forgot to refresh the map. Thanks all. :)