Error on ESRI samples

Nov 30, 2006 at 4:55 AM
Hi, im using SharpMap for .NET Compact Framework (pocketPC) and probably will merge it with parts of ShapeLib and NTS.

Using several shapefiles provided by ESRI and others, a click on a feature results in it an the surrounding ones also selected. I'm trying to show features attributes on the screen.

//A boundingBox surrounding the clicked point
SharpMap.Geometries.Point p1 = myMap.ImageToWorld(new System.Drawing.Point(e.X, e.Y));
SharpMap.Geometries.Point p2 = myMap.ImageToWorld(new System.Drawing.Point(e.X1, e.Y1));

BoundingBox clickBBox = new BoundingBox(p1, p2);

//Filling the table
FeatureDataSet fds = new FeatureDataSet();
myLayer.DataSource.Open();
myLayer.DataSource.ExecuteIntersectionQuery(clickBBox, fds);
myLayer.DataSource.Close();

//A new layer for viewing the selected feature
VectorLayer newLayer = new VectorLayer("atrib");
newLayer.DataSource = new GeometryProvider(fds.Tables0);

this.myMap.Layers.Add(newLayer);

Goes well, but more than 1 feature is selected, even when im using entrire countries, and clicking not in the borders.




Nov 30, 2006 at 6:26 AM
The Shapefile provider currently only support box/box intersection checking. You can use NTS to filter the remaining extra feaures (see the WIKI and the docs)
Dec 1, 2006 at 11:15 PM
Thanks Odegaard, i think i'll try to fix it myself.