create a simple rectangle polygon shapefile

Oct 20, 2012 at 9:29 PM

Seems to be a very task, but I stuck somewhere...Just points were created....

Whats wrong?

Dim shapefile As New MapWinGIS.Shapefile
Dim newField = New MapWinGIS.Field
newField.Name = "ID"
newField.Type = MapWinGIS.FieldType.INTEGER_FIELD
newField.Width = 10newField.Precision = 0

shapefile.CreateNew("dummy.shp",MapWinGIS.ShpfileType.SHP_POLYGON)
shapefile.EditInsertField(newField, 0)

Dim shape = New MapWinGIS.Shapeshape.Create(MapWinGIS.ShpfileType.SHP_POLYGON)
shape.InsertPart(0, 0)
Dim pt = New MapWinGIS.Point
pt.x = ext.xMin
pt.y = ext.yMin
shape.InsertPoint(pt, 0)

pt.x = ext.xMin
pt.y = ext.yMax
shape.InsertPoint(pt, 1)


pt.x = ext.xMax
pt.y = ext.yMax
shape.InsertPoint(pt, 2)

pt.x = ext.xMax
pt.y = ext.yMin
shape.InsertPoint(pt, 3)


pt.x = ext.xMin
pt.y = ext.yMin
shape.InsertPoint(pt, 4)

shapefile.EditInsertShape(shape, 0)
shapefile.EditCellValue(0, 0, 0)
shapefile.StopEditingTable(True,Nothing)
shapefile.StopEditingShapes()
shapefile.Save()
shapefile.Close()

Any hint appreciated. ;-) Thank you....

Oct 21, 2012 at 9:22 AM

ok, solved by myself..Its soo easy ;-))

The secret was to create a new point instance before inserting it to the shape...

 

....

Dim pt = New MapWinGIS.Point
pt.x = ext.xMin
pt.y = ext.yMin
shape.InsertPoint(pt, 0)

pt = New MapWinGIS.Point  ' not really obvious for me, but necessary
pt.x = ext.xMin
pt.y = ext.yMax
shape.InsertPoint(pt, 1)

....

Thanks anyway.

Coordinator
Oct 22, 2012 at 10:43 AM

Thanks for letting us know.

 

--
Paul