Confusion with versions. 0.9 and 2.0 create shp file

Topics: SharpMap Project
Aug 4, 2009 at 2:30 PM

Hi guys.. I been workin for a while with sharpmap for a desktop aplication in and ive been capable of doing amazing things like zoom , pan, read shape files, zoombox, etc. Right now im tring to create a new shape file of points.

There is an excellent example for building tables, adding geometry point, and creating layer   : 

Also there is an example for creating a shp file:

I found i need to create the scheme for the table and use ShapeFileProvider.Create to create the shp file... cant recongnize this... So i was wondering if im using an old version of sharpmap. 

Here is the code, hope u can help me!

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim tabla As New SharpMap.Data.FeatureDataTable()
        tabla = createDataTableSource()

        Dim shapeFile As ShapeFileProvider.Create("C:\", "DataSet1", ShapeType.Point, tabla)      **Here is  the problem**

        Dim gfdt As New SharpMap.Data.Providers.GeometryProvider(tabla)
        Dim layerfdt As New SharpMap.Layers.VectorLayer("pepe")                                                            **Here is where i draw the layer and it works perfect**
        layerfdt.DataSource = gfdt
        layerfdt.Style.Fill = New SolidBrush(Color.Red)
        layerfdt.Style.Outline = New Pen(Color.Black)
        layerfdt.Style.EnableOutline = True


    End Sub

    Public Function createDataTableSource() As SharpMap.Data.FeatureDataTable
        Dim tabla = New SharpMap.Data.FeatureDataTable

        tabla.Columns.AddRange(New DataColumn() {New DataColumn("oid"), New DataColumn("name"), New DataColumn("x"), New DataColumn("y")})
        Dim rnd As New Random()
        Dim j As New Integer
        For j = 0 To 10
            Dim x As New Double
            Dim y As New Double
            x = rnd.NextDouble() * 1000
            y = rnd.NextDouble() * 1000
            Dim fila As SharpMap.Data.FeatureDataRow = tabla.NewRow()
            fila("oid") = j
            fila("name") = "Item No " & j
            fila("x") = x
            fila("y") = y
            fila.Geometry = New SharpMap.Geometries.Point(x, y)

        Next j
        Return tabla
    End Function



Mr. Musso

Aug 4, 2009 at 3:55 PM

Hi Mr Musso, all providers are readonly in 0.9 - the writable example is v2 code (v2 is @ hth jd

Aug 4, 2009 at 4:33 PM
Edited Aug 4, 2009 at 4:35 PM

Thx JD!

Ok i already made a checkout of the last revision in the trunk. In your opinion, do u think this is going to affect my current proyect if i use the v2.0 libraries?

Aug 4, 2009 at 4:58 PM

The libraries are quite different, so you will need to make changes to your project jd