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

Intersection Query Accuracy Help Needed!!!!

Topics: Algorithms, Data Access, General Topics
Dec 8, 2008 at 2:41 PM
I have a lat/lon point passed into a shapefile for an intersection query. Even though the point is in the middle of a returned shape I get 2, 3 sometimes 5 rows returned. Is there anything that I can do to make this return 1 row? And it has to be the correct row.
Dec 8, 2008 at 2:45 PM
The shapefile provider for 0.9 only does a point in bounding box check - you will need to use NTS to do a true spatial intersects hth jd
Dec 8, 2008 at 2:53 PM
Do you have an example, I am kinda crunched for time?
Dec 8, 2008 at 3:20 PM
Edited Dec 8, 2008 at 10:22 PM
I dont have a complete example but you would use the GeometryConverter (in the extensions project) class to convert all Geometries that passed the shapefile bounding box test (lets call them results1) into NTS Geometries (call them results2), then also convert the click point into NTS fromat (call it target1) and do

for each  IGeometry possibleGeom in results2
     if possibleGeom.Intersects(targetGeom)
          convert possibleGeom back to SharpMap format // using GeometryConverter
                do something with it..

You could also do something similar within the shapefile.FilterDelelgate an optional post bounding box filter
Dec 10, 2008 at 2:50 AM
GisSharpBlog.NetTopologySuite.Geometries.Geometry ntsPoint =
                        new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory());

foreach your result set
convert each row's geometry to NTS geometry (targetGeom).
after that operation only one record will remained.