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

PLEASE help me! ExecuteIntersectionQuery in VB gets NULLREF exc.

Topics: General Topics
Nov 23, 2006 at 11:02 AM
Please someone help me using ExecuteIntersectionQuery method to do identify operations in VB.NET.
Here the code:

' ========== identify ====================
Dim l1 As SharpMap.Layers.VectorLayer = map.Layers(1)
Dim pt1 As SharpMap.Geometries.Point = New SharpMap.Geometries.Point(lon, lat)
Dim dts As New SharpMap.Data.FeatureDataSet
l1.DataSource.ExecuteIntersectionQuery(pt1, dts)
' ========================================

I get NullReferenceException while executing last code row where l1,pt1,dts are all successfully defined.
Anybody can help me to find what's wrong? (sorry for my english I'm italian).


Nov 30, 2006 at 8:03 AM
I was having this same problem, so I searched in the help documentation for "ExecuteIntersectionQuery" and noticed this:

Returns the data associated with all the geometries that are intersected by 'geom'. Please note that the ShapeFile provider currently doesn't fully support geometryintersection and thus only BoundingBox/BoundingBox querying are performed. The results are NOT guaranteed to lie withing 'geom'.

Basically, for shapefiles, searching by point is not supported yet. So all I did was created a BoundingBox using the x/y coordinates (c#, not vb - sorry)

//create the bounding box where user clicked
SharpMap.Geometries.BoundingBox bb = new SharpMap.Geometries.BoundingBox(x, y, x, y);

This worked for me. Hope it helps you as well.
Dec 1, 2006 at 3:56 PM
Thank you very much. So there's no way to retrieve data attributes of the shapefile 'cause BBox returns only geometries. Have you solved this problem too?