This project has moved and is read-only. For the latest updates, please go here.

Possible bug in MapQueried event

Topics: SharpMap Project, WinForms Controls
Aug 29, 2009 at 1:16 PM
Edited Aug 29, 2009 at 1:30 PM

I was expecting the MapQueried event to be fired when the user clicks inside the ExteriorRing of the polygon. However this does not seem to be the case. The event is fired if the user clicks anywhere inside the BoundingBox of the polygon, even if the point clicked is outside the polygon's exterior!

I am not sure if there is any specific reason for this to be implemented the way it is. But for now I think it is a bug.

Anyway, I tried adding some custom code in the MapQueried event where the points are added to a GraphicsPath class and a check is done using the GraphicsPath.IsVisible method. But this does not seem to be working as well.

Aug 29, 2009 at 4:55 PM

Anyway, I got it right using the PolygonF class provided here:

But, still I think this should have been the default behaviour.

Aug 29, 2009 at 6:01 PM

Hi kraghavk, the implementation is specific to the daaprovider - I am assuming you are using the shapefile provider which only tests bonding boxes by default, however this behaviour can be changed see hth jd

Aug 30, 2009 at 7:24 AM
Edited Aug 30, 2009 at 7:24 AM

I am not using the ShapeFile provider as my data is in a database. So, I am using GeometryFeatureProvider and constructing the layers I want on the fly. As I've already said in my previous reply, I have got it working by performing this check in the MapQueried event and it is working perfectly fine.

I would like to know if using the NTS way of checking for true intersection performs better than the way I have implemented it.

Sep 1, 2009 at 10:46 AM
Edited Sep 1, 2009 at 10:47 AM

I don't have any performance metrics, however using NTS is a very common as it offers many useful spatial operations and tests. It is also valid for polygons containing holes which I am not sure the code you found is. Personally I might change the functionality of MapQueried to raise an event containing the real world point and then layer and the query the datasource manually. hth jd