This project has moved and is read-only. For the latest updates, please go here.

Creating Feature Data silent error?

Topics: Data Access, SharpMap Project, SharpMap v0.9 / v1.x
May 3, 2010 at 9:03 AM

I am trying to create a vector layer with points on it that I can click on and return some feature data.


I got this code from elsewhere in the forums and it works with my shapefile

Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
        Dim ClickPnt As SharpMap.Geometries.Point = MainMap.ImageToWorld(New System.Drawing.Point(e.X, e.Y))
        Dim ds As SharpMap.Data.FeatureDataSet = New SharpMap.Data.FeatureDataSet()

        ' I like to create a local, since it is easier to read and makes the generated IL more efficient
        Dim layer As SharpMap.Layers.VectorLayer = MainMap.Layers("aLayer")

        'You have to open the layer first...

        'Perform the query which fills up the data set.
        layer.DataSource.ExecuteIntersectionQuery(ClickPnt.GetBoundingBox(), ds)

        'Now that you have the data, you can close the data source.
        For Each row As SharpMap.Data.FeatureDataRow In ds.Tables(0)
            Dim check As String = row.Item(0)
    End Sub


But when I try to create a layer like this:


 Dim fdt As SharpMap.Data.FeatureDataTable = New SharpMap.Data.FeatureDataTable()
        fdt.Columns.Add("ID", GetType(String))

        Dim fdr As SharpMap.Data.FeatureDataRow

        For i As Integer = 0 To 10
            fdr = fdt.NewRow
            fdr.Geometry = New SharpMap.Geometries.Point(i, i)
            fdr("ID") = i.ToString


        Dim newlayer As New SharpMap.Layers.VectorLayer("Pipe")
        newlayer.DataSource = New SharpMap.Data.Providers.GeometryProvider(fdt)
            MainMap.Layers("Pipe") = newlayer

        PictureBox1.Image = MainMap.GetMap


The following Renders fine but when you try to query it it fails with System.NotSupportedException on the line 'layer.DataSource.ExecuteIntersectionQuery(ClickPnt.GetBoundingBox(), ds)'

I also can not use the Datasource from my code created layer for labels either so I'm assuming there is something wrong with how I'm creating the FeatureDataTable.