Ok, here is all my code. Please help me to solve my two problems:
1) It works when I use: xy = “Polygon((-40 0, -40 20, -10 20, -40 0))” but I get the “wellKnownText” error when I use: xy = “Polygon((30.090728 -26.648588, 30.098243 -26.645768, 30.103212 -26.653944, 30.095499 -26.656581))”. Surely a polygon is not always a rectangle.
2) The shp file gets created with one field (ZONE_ID), how do I add more fields: X1, Y1 … up to X4, Y4 ?
'get the data
CL_TCO_ZONESTableAdapter.Fill(DataSet1.CL_TCO_ZONES)
'define the column in the shape file
Dim idColumn As New MapSuite.Core.DbfColumn(“ZONE_ID”, DbfColumnType.String, 8, 0)
'create the shape file
MapSuite.Core.ShapeFileFeatureSource.CreateShapeFile(ShapeFileType.Polygon, _
“c:\abc.shp”, _
New DbfColumn() {idColumn})
'create the index file
MapSuite.Core.ShapeFileFeatureSource.BuildIndexFile(“c:\abc.shp”)
'open the blank shaped file
Dim zoneShapeFile As New MapSuite.Core.ShapeFileFeatureSource(“c:\abc.shp”, ShapeFileReadWriteMode.ReadWrite)
zoneShapeFile.Open()
'begin the transaction
zoneShapeFile.BeginTransaction()
'read the dataset and add the coordinates to the shape file
Dim rowView As System.Data.DataRowView
Dim row As DataSet1.CL_TCO_ZONESRow
CL_TCO_ZONESBindingSource.MoveFirst()
rowView = Me.CL_TCO_ZONESBindingSource.Current
row = rowView.Row
Dim xy As String = “”
'xy = “Polygon((30.090728 -26.648588, 30.098243 -26.645768, 30.103212 -26.653944, 30.095499 -26.656581))”
xy = “Polygon((-40 0, -40 20, -10 20, -40 0))”
Dim polygonShape = New PolygonShape(xy)
Dim zoneColumns As New Dictionary(Of String, String)
zoneColumns.Add(“ZONE_ID”, row.ZONE_ID.ToString)
zoneColumns.Add(“X1”, -40) 'row.X1.ToString)
zoneColumns.Add(“Y1”, 0) 'row.Y1.ToString)
zoneColumns.Add(“X2”, -40) 'row.X2.ToString)
zoneColumns.Add(“Y2”, 20) 'row.Y2.ToString)
zoneColumns.Add(“X3”, -10) 'row.X3.ToString)
zoneColumns.Add(“Y3”, 20) 'row.Y3.ToString)
zoneColumns.Add(“X4”, -40) 'row.X4.ToString)
zoneColumns.Add(“Y4”, 0) 'row.Y4.ToString)
Dim feature As New MapSuite.Core.Feature(polygonShape, zoneColumns)
zoneShapeFile.AddFeature(feature)
'commit the transaction and close the file
Dim results As TransactionResult = zoneShapeFile.CommitTransaction
MessageBox.Show("Features added to zone shapefile result: " & results.TransactionResultStatus.ToString)
zoneShapeFile.Close()