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

SharpMap.Demo.Wms GetFeatureInfo results: Too many features returned

Topics: SharpMap Project, SharpMap v0.9 / v1.x
Oct 2, 2013 at 10:23 PM
Edited Oct 2, 2013 at 10:29 PM
I made a WMS using SharpMap, but noticed that the GetFeatureInfo call resulted in multiple records from the same layer. Upon debugging the code, I noticed that it was because of the "pixelSensitivity" parameter in the WmsServer.ParseQueryString call. So I gave it a value of 1 and it still yielded similar results. My data are shapefiles in Geographic NAD 83 and I'm using OpenLayers.

So I decided to look at the OpenLayers example (SharpMap.Demo.Wms) in the SharpMap code that I downloaded and saw similar results there as well (I did try reducing the pixel sensitivity). I chose the area by the 4 hospitals by East River and if I clicked on any of them it gave me 5 results (4 hospitals, plus the east river polygon).

I even edited the SharpMap code (method:CreateFeatureInfoGeoJSON, class: SharpMap.Web.Wms.WmsServer) where it makes the queryBox to look like this:
                        //var queryBoxMinX = x - (_pixelSensitivity);
                        //var queryBoxMinY = y - (_pixelSensitivity);
                        //var queryBoxMaxX = x + (_pixelSensitivity);
                        //var queryBoxMaxY = y + (_pixelSensitivity);
                        var queryBoxMinX = x - 0.0001f;
                        var queryBoxMinY = y - 0.0001f;
                        var queryBoxMaxX = x;
                        var queryBoxMaxY = y;
                        var minXY = map.ImageToWorld(new PointF(queryBoxMinX, queryBoxMinY));
                        var maxXY = map.ImageToWorld(new PointF(queryBoxMaxX, queryBoxMaxY));
I did that to reduce the queryBox as small as (0.0001f x 0.0001f) so as to reduce the intersection area. But still no luck.

I'm out of options/ideas at this point. Does any one have any ideas on how I can get the CreateFeatureInfoGeoJSON to return the right results?

Oct 2, 2013 at 11:20 PM
For backwards compatiblitly the shapefile provider only performs intersection tests on the bounding boxes.
If you do want true intersection testing, you need to set
var sfProvider = new ShapeFile(...);
sfProvider.DoTrueIntersectionQuery = true;
Hth FObermaier
Oct 3, 2013 at 4:02 AM
Thanks! That was it. I am so glad the library can do a point in polygon search.