Polygon Buffer - How to set  FLAT corner paramater

852
7
01-23-2012 12:06 AM
New Contributor II
How do I modify the code below to get the Buffer polygon with FLAT corners


Sub MyCreatePolygonBuffer()

    Dim pMap As IMap
   Dim pMxDoc As IMxDocument
   Dim pFeatureClass As IFeatureClass
   Dim pFeatureLayer As IFeatureLayer
   Dim pFeatureCursor As IFeatureCursor
   Dim pOutFeatureCursor As IFeatureCursor
   Dim pfeature As IFeature
   
   'Split lines for selected layer
   Set pMxDoc = ThisDocument
   If Not pMxDoc.SelectedLayer Is Nothing Then
     Set pFeatureLayer = pMxDoc.SelectedLayer
   Else
      MsgBox "Please select a polygon layer to buffer"
      Exit Sub
   End If
      
    Dim pLayerInnerPolygon As IFeatureLayer
    Dim pLayerOuterPolygon As IFeatureLayer
    
    Set pMap = pMxDoc.FocusMap
    Set pLayerInnerPolygon = pMap.Layer(0)
    
   Set pFeatureClass = pLayerInnerPolygon.featureClass
   Set pFeatureCursor = pFeatureClass.Update(Nothing, False)
   Set pfeature = pFeatureCursor.NextFeature
    
   Dim pBufferConstruction  As IBufferConstruction
   Set pBufferConstruction = New BufferConstruction
   
   Dim pBufferPolygon As IPolygon
   Set pBufferPolygon = New polygon
   
  'How to make use of this property ?
   'Dim pBufferConstructionProperties As IBufferConstructionProperties
  ' pBufferConstructionProperties.EndOption = esriBufferFlat
   
   Do Until pfeature Is Nothing
            Dim pPolygon As IPolygon
            Set pPolygon = pfeature.Shape
            Set pBufferPolygon = pBufferConstruction.Buffer(pPolygon, 10)
            Set pfeature = pFeatureCursor.NextFeature
  Loop    

 AddPolygonToGraphicsLayer pBufferPolygon

End Sub
Reply
0 Kudos
7 Replies
by
Occasional Contributor III
According to IBufferConstructionProperties documentation, ConstructBuffers and ConstructBuffersByDistances  methods make use of these properties whereas Buffer method does not.
Reply
0 Kudos
New Contributor II
According to IBufferConstructionProperties documentation, ConstructBuffers and ConstructBuffersByDistances  methods make use of these properties whereas Buffer method does not.


Would you share an example to accomplish that.
Reply
0 Kudos
by
Occasional Contributor III
I have never used these properties. But you could try adding input geometry to geometrycollection and use it with constructbuffer method.

IGeometryCollection pInGeomColl = new GeometryBagClass();
                    object Missing = Type.Missing;
                    pInGeomColl.AddGeometry(pfeature.Shape, ref Missing, ref Missing);
IGeometryCollection pOutGeomColl = new GeometryBagClass(); ;
                    IBufferConstruction pBufferConstruction = new BufferConstruction();
                    IBufferConstructionProperties pBufferConstructionProperties =
                        pBufferConstruction as IBufferConstructionProperties;
                    pBufferConstructionProperties.EndOption = esriBufferConstructionEndEnum.esriBufferFlat;
                  
                    pBufferConstruction.ConstructBuffers(pInGeomColl as IEnumGeometry,10,pOutGeomColl);
Reply
0 Kudos
New Contributor II
I have modified my code as below.I still get the rounded corners.:(

Dim pInGeomColl As IGeometryCollection
Set pInGeomColl = New GeometryBag
                   
pInGeomColl.AddGeometry pfeature.Shape   'Adding my polygon to geom collection
Dim pOutGeomColl As IGeometryCollection
Set pOutGeomColl = New GeometryBag
pBufferConstruction.ConstructBuffers pInGeomColl, 40, pOutGeomColl

Set pBufferPolygon = pOutGeomColl.geometry(0)
Reply
0 Kudos
by
Occasional Contributor III
BTW Buffer tool never generates a sharp cornered polygon since the outer polygon is 'd' distance from the vertex of the inner polygon in two different direction. From mathematical perspective it is accurate. If you want sharp corners, You may have to edit the resulting buffered polygon and remove the arc and increase the length of the lines to change it to a sharp cornerred polygon.
Reply
0 Kudos
New Contributor
I have modified my code as below.I still get the rounded corners.:(

Dim pInGeomColl As IGeometryCollection
Set pInGeomColl = New GeometryBag
                   
pInGeomColl.AddGeometry pfeature.Shape   'Adding my polygon to geom collection
Dim pOutGeomColl As IGeometryCollection
Set pOutGeomColl = New GeometryBag
pBufferConstruction.ConstructBuffers pInGeomColl, 40, pOutGeomColl

Set pBufferPolygon = pOutGeomColl.geometry(0)


Hello there,
could you ever solve this problem !? I am confronting the same issue !

Thank you very much,
Nazereh
Reply
0 Kudos
New Contributor
Hi

Try this may work in ARCGIS 10 but its not working in 10.1.I want to know the reason

Do Until pfeature Is Nothing

            'pPolygon = pfeature.Shape
            Dim ptop As ITopologicalOperator
            ptop = pfeature.Shape
            Dim pPl As IPolyline = New Polyline
            pPl = ptop.Boundary

            Dim pConstructCurve As IConstructCurve3
            Dim test As Double
            test = 3.048
            pConstructCurve = New Polyline
            pConstructCurve.ConstructOffset(pPl, -1 * test, esriConstructOffsetEnum.esriConstructOffsetMitered + esriConstructOffsetEnum.esriConstructOffsetSimple)

            ConstructOffset = pConstructCurve
            'pBufferPolygon = ptop.Buffer(-20)
            ' pBufferPolygon = pBufferConstruction.Buffer(pPolygon, 40)
            AddPolygonToGraphicsLayer(ConstructOffset)
            pfeature = pFeatureCursor.NextFeature
        Loop


Govind
Reply
0 Kudos