I am New to Sharp map .
I am using ASP.NET with VB.net 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
' retrieve information from clicked point...this method fill dataset
DirectCast(_map.Layers(0), SharpMap.Layers.VectorLayer).DataSource.ExecuteIntersectionQuery(punto.GetBoundingBox(), ds)
' close datasource
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")
Dec 22, 2007 at 11:46 PM
Edited Dec 24, 2007 at 10: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.
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
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.