There is way to reduce the BoundingBox?

Topics: Data Access, WinForms Controls
Mar 7, 2009 at 3:05 AM
HI,  i am using the MapImage_MouseClick event to capture the coordinates of a point,, and return  to a datagrid the atribute table of the geometry of shape that  intersect that point. But the BoundingBox of the point doesn't respect the geometry area limit, in most of the times. There is way to reduce the BoundingBox when Execute Intersection Query?

 
here is an example:

private void MainMap_MouseClick(object sender, MouseEventArgs e)
 {

                SharpMap.Geometries.Point p = MainMap.Map.ImageToWorld(e.Location);
                SharpMap.Data.FeatureDataSet cacheTable = new SharpMap.Data.FeatureDataSet();
                SharpMap.Data.FeatureDataTable data = new SharpMap.Data.FeatureDataTable();

                VectorLayer layer = MainMap.Map.Layers[3] as SharpMap.Layers.VectorLayer;
                layer.DataSource.Open();
                layer.DataSource.ExecuteIntersectionQuery(p.GetBoundingBox(), cacheTable);
                layer.DataSource.Close();
                data = cacheTable.Tables[0];
                if (data.Count >= 1)
                {
                    FeaturesDataGridView.DataSource = data;// in the most of the cases it brings more than one cell, even when i query only one geometry
                }
}
Coordinator
Mar 7, 2009 at 9:28 AM
Edited Mar 8, 2009 at 1:03 AM
Hi betoens, the shapefile provider only tests the bounding boxes. You need to use the FilterDelegate property or 'post process' to use NTS to do a true intersection test.There are a few examples on the forum... hth jd

update: I have added some example code to the how to section here

Just to answer the original reduce BoundingBox question : use the BoundingBox.Grow method passing in negative values