I have turned to SharpMap because I am trying to locate specific shapes in a shapefile using a point. I need to know whether a given point is within a shape.
I started of with SharpMap 0.9 a managed to locate the shapes with the following code:
BoundingBox ext = new SharpMap.Geometries.Point(point.X, point.Y).GetBoundingBox();
FeatureDataSet ds = new FeatureDataSet();
DataTable table = ds.Tables;
foreach (DataRow row in table.Rows)
This is very fast and as far as I can tell also accurate.
My first question is: how can I get the original feature id of the shapes found?
Because I could not find out how to get these, I tried the same with SharpMap 2.0:
IGeometryServices gs = new GeometryServices();
IExtents2D rect = gs.DefaultGeometryFactory.CreateExtents2D(point.X, point.Y, point.X, point.Y);
GeoAPI.Geometries.IPoint ipoint = gs.DefaultGeometryFactory.CreatePoint2D(point.X, point.Y);
FeatureQueryExpression query = FeatureQueryExpression.Intersects(ipoint.Extents);
using (IFeatureDataReader dr = sf.ExecuteFeatureQuery(query))
int fid = dr.GetOid();
This also works, and now I can get the orginal feature id. But... it is many times slower than the SharpMap 0.9 version.
So my second question is: am I missing something, or is the 2.0 version just very slow? (I also saw an other user asking about this in 2008: http://sharpmap.codeplex.com/Thread/View.aspx?ThreadId=31281).
I am specifically interested in using SharpMap 2.0 because later on I also want to write shapefiles.
If you can help me out that would be great.