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


Topics: Algorithms, SharpMap v0.9 / v1.x, WinForms Controls
Mar 12, 2012 at 2:13 PM
Edited Mar 12, 2012 at 2:17 PM

Hi all, I would ask you about this function.

The first overload is GeometryFeatureProvider.ExecuteIntersectionQuery(BoundingBox box, FeatureDataSet ds)

But this function doesn't help me to find on which I clicked in my map, because it returns all the geometries contained in the BoundingBox


The second overload is GeometryFeatureProvider.ExecuteIntersectionQuery(Geometry geom, FeatureDataSet ds)

Seems like the same result: in the code, each geometry is converted into BoundingBox, so I lose the shape of my geometry


So I tried an alternate way:

Geometry.Contains(Geometry geom)

But following the code:

1) Geometry.Contains(Geometry geom)

2) SpatialRelations.Contains(Geometry sourceGeometry, Geometry otherGeometry)

3) Geometry.Within(Geometry geom)

4) SpatialRelations.Within(Geometry g1, Geometry g2)

5) Point.Contains(Geometry geom)

return false;


So the function Point.Contains(Geometry geom) returns false.


How can I know the ID of the geometry clicked on my map (with a GeometryFeatureProvider)?

Mar 12, 2012 at 3:57 PM

SharpMap v0.9 currently only handles SpatialRelation computation on bounding boxes (except for some Point operations).

If you want true intersection testing you need to use NTS. There is a geometry converter in the SharpMap.Extensions project.

You may also want to look at SharpMap.Extension's ShapeFileProviderEx. It uses NTS' PreparedGeometry functionality for the SpatialRelation computation. This should give better performance.

Hth FObermaier

Mar 13, 2012 at 8:31 AM

OK I'll try and I let you know

Thank you

Mar 16, 2012 at 9:03 AM
Edited Mar 16, 2012 at 10:25 AM

Men, you are GREAT!

I simply replaced:

V.ExecuteIntersectionQuery(P1, DS)


NtsProvider P = new NtsProvider(V.DataSource);               

FeatureDataSet DS= new FeatureDataSet();               

P.ExecuteIntersectionQuery(P1, DS);


Until 50.000 geometries I'm getting the same perfomances


Btw, I am interested at ShapeFileProviderEx, but where can I find an example or the entire class?