Problem in getting data from shape file

Topics: Data Access, SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0
Dec 22, 2007 at 10:39 AM
I am New to Sharp map .
I am using ASP.NET with and has changed the shp files to mine data shp file .
The vector layer is made up of multiple polygon which has id attributes to it that r stored in the dbf file.
now when i click on a particular polygon then the attribute id of the dbf file is retunted to me.
All is going on well but in some cases when i click on a polygon Suppose A there r multiple ids that r return to me that of polygons that r next to that polygon A .
the code that is been used to get the id is as follows:

Dim _map As SharpMap.Map = New SharpMap.Map

' create new layer

Dim _layer As New SharpMap.Layers.VectorLayer("My Layer 123")

' set datasource to shape file

layer.DataSource = New SharpMap.Data.Providers.ShapeFile(HttpContext.Current.Server.MapPath("~\Appdata\PlotsHT.shp"), True)

' get position where mouse clicked

Dim clickPoint As SharpMap.Geometries.Point = punto '_map.ImageToWorld(New PointF(punto.X, punto.Y))

' create new dataset

Dim ds As SharpMap.Data.FeatureDataSet = New FeatureDataSet()

' open DataSource

DirectCast(_map.Layers(0), SharpMap.Layers.VectorLayer).DataSource.Open()

' retrieve information from clicked point...this method fill dataset
DirectCast(_map.Layers(0), SharpMap.Layers.VectorLayer).DataSource.ExecuteIntersectionQuery(punto.GetBoundingBox(), ds)

' close datasource

DirectCast(_map.Layers(0), SharpMap.Layers.VectorLayer).DataSource.Close()

If ds.Tables.Count > 0 Then
Dim str As New StringBuilder()
Dim str1 As String
Dim dt As DataTable = ds.Tables(0)
For Each r As DataRow In dt.Rows
str1 = r("objectid")
End If
Dec 22, 2007 at 10:46 PM
Edited Dec 24, 2007 at 9:40 AM
The 0.9 versons of SharpMap return any geometry whose extent contains the query point, instead of checking for a more precise "contains" query. When you get back the list of IDs, you will need to iterate through them and use something like the NTS functions to test for a true contains conditon.
Dec 24, 2007 at 1:27 PM
Thanxs for the reply Magnum
Pls do guide me how can i achive my goal.
If u can post some source code as example that be great
Dec 25, 2007 at 11:54 AM
I'm sorry. I'm not in a position to post any code. We've transitioned to the latest NTS and GeoAPI and away from SharpMap 0.9 If you explore, there should be a method to take a SharpMap geometry object and convert it to an NTS geometry object. Then you can just use the .Contains method, which accepts another geometry object as its parameter. The next major SharpMap build will ust the NTS geometry internally, so this kind of thing won't be an issue.