MapWinGIS:Shape InsertPart
From MapWindow GIS
InsertPart
Inserts a part into the shape. Parts are used to create polygons with holes. Parts with points ordered in a clockwise direction are filled. Parts with points ordered in a counter-clockwise direction are cut out. Only clockwise parts should be used to define the outer-most regions of a shape.
VB.NET Usage
Function InsertPart(PointIndex As Integer, ByRef PartIndex As Integer) As Boolean
Parameters
|
PointIndex | The index of the first point in the part to be inserted. |
| PartIndex | The part index desired. This value may be modified if it is not possible to use the desired part index. |
| ReturnValue | A boolean value representing the success or failure of inserting the part into the shape. |
Sample Code
Private Sub InsertPart()
Dim shape As New MapWinGIS.Shape()
Dim point(5) As MapWinGIS.Point, point2(5) As MapWinGIS.Point
Dim partindex As Integer, pointindex As Integer, i As Integer
Dim success As Boolean
'Create two arrays of point objects
For i = 0 To 4
point(i) = New MapWinGIS.Point()
point2(i) = New MapWinGIS.Point()
Next
'Create a new polygon shape object
success = shape.Create(MapWinGIS.ShpfileType.SHP_POLYGON)
'Set the x and y coordinates for the first part's points
' Note: These points are arranged in a clockwise order.
' As a result, these points specify the part of the shape
' that will be filled.
point(0).x = 100
point(0).y = 100
point(1).x = 100
point(1).y = 200
point(2).x = 200
point(2).y = 200
point(3).x = 200
point(3).y = 100
point(4).x = 100
point(4).y = 100
'Insert the first part into the shape with points starting at point index 0
success = shape.InsertPart(0, partindex)
'Increment the part index
partindex = partindex + 1
'Insert each point in the point array into the shape in the first part
For i = 0 To 4
success = shape.InsertPoint(point(i), pointindex)
'Increment the point index
pointindex = pointindex + 1
Next
'Set the x and y coordinates for the second part's points
' Note: These points are arranged in a counter-clockwise order.
' As a result, these points specify the part to
' be cut out of the shape.
point2(0).x = 120
point2(0).y = 120
point2(1).x = 150
point2(1).y = 120
point2(2).x = 150
point2(2).y = 150
point2(3).x = 120
point2(3).y = 150
point2(4).x = 120
point2(4).y = 120
'Insert the second part using the points from the next point index and on
success = shape.InsertPart(pointindex, partindex)
'Increment the part index
partindex = partindex + 1
'Insert each point in the point2 array into the shape in the second part
For i = 0 To 4
success = shape.InsertPoint(point2(i), pointindex)
'Increment the pointindex
pointindex = pointindex + 1
Next
End Sub
VB 6 Usage
Function InsertPart(PointIndex As Long, ByRef PartIndex As Long) As Boolean
Parameters
|
PointIndex | The index of the first point in the part to be inserted. |
| PartIndex | The part index desired. This value may be modified if it is not possible to use the desired part index. |
| ReturnValue | A boolean value representing the success or failure of inserting the part into the shape. |
Sample Code
Private Sub InsertPart()
Dim shape As New MapWinGIS.shape
Dim point(5) As MapWinGIS.point, point2(5) As MapWinGIS.point
Dim partindex As Long, pointindex As Long, i As Long
Dim success As Boolean
'Create two arrays of point objects
For i = 0 To 4
Set point(i) = New MapWinGIS.point
Set point2(i) = New MapWinGIS.point
Next
'Create a new polygon shape object
success = shape.Create(MapWinGIS.ShpfileType.SHP_POLYGON)
'Set the x and y coordinates for the first part's points
' Note: These points are arranged in a clockwise order.
' As a result, these points specify the part of the shape
' that will be filled.
point(0).x = 100
point(0).y = 100
point(1).x = 100
point(1).y = 200
point(2).x = 200
point(2).y = 200
point(3).x = 200
point(3).y = 100
point(4).x = 100
point(4).y = 100
'Insert the first part into the shape with points starting at point index 0
success = shape.InsertPart(0, partindex)
'Increment the part index
partindex = partindex + 1
'Insert each point in the point array into the shape in the first part
For i = 0 To 4
success = shape.InsertPoint(point(i), pointindex)
'Increment the point index
pointindex = pointindex + 1
Next
'Set the x and y coordinates for the second part's points
' Note: These points are arranged in a counter-clockwise order.
' As a result, these points specify the part to
' be cut out of the shape.
point2(0).x = 120
point2(0).y = 120
point2(1).x = 150
point2(1).y = 120
point2(2).x = 150
point2(2).y = 150
point2(3).x = 120
point2(3).y = 150
point2(4).x = 120
point2(4).y = 120
'Insert the second part using the points from the next point index and on
success = shape.InsertPart(pointindex, partindex)
'Increment the part index
partindex = partindex + 1
'Insert each point in the point2 array into the shape in the second part
For i = 0 To 4
success = shape.InsertPoint(point2(i), pointindex)
'Increment the pointindex
pointindex = pointindex + 1
Next
End Sub
















