rwelikal

Polygon Split tool using Points and Polylines

Discussion created by rwelikal on Jun 9, 2010
Hi All,
Creating a polygon split tool.  The code below is incomplete but I've hit a snag.  How would I extend the polylines I've created below by a given length?
I want to use these polylines to cut the polygon which I'm defining using the User provided points.

Any help would be appreciated.

Thanks
    Public Sub ClipTool(ByVal p0X As Double, ByVal p0Y As Double, ByVal p1X As Double, _
                        ByVal p1Y As Double, ByVal p2X As Double, ByVal p2Y As Double, _
                        ByVal p3X As Double, ByVal p3Y As Double)

        ' 1.  Create 4 points from teh coordinates input
        Dim pPoint0 As IPoint = New Point
        Dim pPoint1 As IPoint = New Point
        Dim pPoint2 As IPoint = New Point
        Dim pPoint3 As IPoint = New Point

        pPoint0.X = p0X
        pPoint0.Y = p0Y

        pPoint1.X = p1X
        pPoint1.Y = p1Y

        pPoint2.X = p2X
        pPoint2.Y = p2Y

        pPoint3.X = p3X
        pPoint3.Y = p3Y

        Dim pPointCollection As IPointCollection

        pPointCollection.AddPoint(pPoint0)
        pPointCollection.AddPoint(pPoint1)
        pPointCollection.AddPoint(pPoint2)
        pPointCollection.AddPoint(pPoint3)

        ' 2.  Create 4 polylines representing the outline of the lot from the 4 points
        Dim pPLine0 As IPolyline = New Polyline
        Dim pPLine1 As IPolyline = New Polyline
        Dim pPLine2 As IPolyline = New Polyline
        Dim pPLine3 As IPolyline = New Polyline

        pPLine0.FromPoint = pPoint0
        pPLine0.ToPoint = pPoint1

        pPLine1.FromPoint = pPoint1
        pPLine1.ToPoint = pPoint2

        pPLine2.FromPoint = pPoint2
        pPLine2.ToPoint = pPoint3

        pPLine3.FromPoint = pPoint3
        pPLine3.ToPoint = pPLine0

        ' 3.  Locate the point halfway along the top and bottom polylines
        ' This is done using the ratio (in this case. 0.5)
        Dim TopMidPoint As IPoint = New Point
        Dim BotMidPoint As IPoint = New Point

        pPLine0.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, True, TopMidPoint)
        pPLine2.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, True, BotMidPoint)

        ' 4.  Locate the points 1/4, 1/2, and 3/4 along each side polyline.  
        ' This is done using the ratio (in this case 0.25, 0.50, 0.75).
        Dim Right25Point As IPoint = New Point
        Dim Right50Point As IPoint = New Point
        Dim Right75Point As IPoint = New Point

        Dim Left25Point As IPoint = New Point
        Dim Left50Point As IPoint = New Point
        Dim Left75Point As IPoint = New Point

        pPLine1.QueryPoint(esriSegmentExtension.esriNoExtension, 0.25, True, Right25Point)
        pPLine1.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, True, Right50Point)
        pPLine1.QueryPoint(esriSegmentExtension.esriNoExtension, 0.75, True, Right75Point)

        pPLine3.QueryPoint(esriSegmentExtension.esriNoExtension, 0.25, True, Left25Point)
        pPLine3.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, True, Left50Point)
        pPLine3.QueryPoint(esriSegmentExtension.esriNoExtension, 0.75, True, Left75Point)

        ' 5.  Create a polyline from the points in step 3 cutting the geometry in half.
        ' Also create 3 polylines from teh points in 4 for cutting the geometry in quarters.
        Dim pLineCutTopBot As IPolyline = New Polyline
        Dim pLine25Cut As IPolyline = New Polyline
        Dim pLine50Cut As IPolyline = New Polyline
        Dim pLine75Cut As IPolyline = New Polyline

        pLine25Cut.FromPoint = Right25Point
        pLine25Cut.ToPoint = Left25Point

        pLine50Cut.FromPoint = Right50Point
        pLine50Cut.ToPoint = Left50Point

        pLine75Cut.FromPoint = Right75Point
        pLine75Cut.ToPoint = Left75Point

    End Sub

Outcomes