Need a better way to handle feature selection.

Topics: Algorithms, Data Access, General Topics, SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0
Jun 12, 2008 at 12:39 AM
Edited Jun 12, 2008 at 12:45 AM
Hi, I'm developing and application using SharpMap 0.9. I've currently got a nice little demo up which includes some good features like panning, zooming and selecting. My problem is the the selecting. I've implemented it in the way posted in the HOWTO. But when selecting adjacent diagonal objects, this method is not satisfactory. Seeing as the ExecuteIntersectionQuery takes the envelope (axis-aligned bounding box) of the features, if two features have diagonals and are close to each other, they'll overlap when they shouldn't (I hope you know what I mean.) So is there a better way to do this? Maybe this works better in 2.0?

Perhaps someone knows the library better than I do. I'm not to sure about how some of the classes work. i could do a simple "Does this point lie inside this polygon" test if I could get a list of lines and vertices of each geometric object.

Thanks in advance for your help.
Jun 12, 2008 at 1:43 AM
@aarnold -

This is because of the spatial operations in v0.9 being based on bounding boxes (or extents) instead of the actual geometry. You might be able to use the NTS provider in v0.9 to get true geometry predicates.

In v2.0, the selection model is different, and is based on an expression and a resulting view: same layer, new expression to define the selection. Since v2.0 uses NTS as the geometry model of choice, true predicates are also available without the use of another provider. Sorry to say, however, that v2.0 needs some work on your end to get to a demoable stage, since we don't have much out of the box. Current source does build and render maps on the desktop, however, so if you are a brave soul, have a look.
Jun 12, 2008 at 1:51 AM
Thanks. So I might have to just sit tight or risk brain overload with v2. Do you know of a workaround to at least simulate the effect I want until I can fix it up?
Jun 12, 2008 at 5:37 AM
You can try looking at the NTS provider, which has a write up here: NetTopologySuite Data Provider.