Buffer Construction Properties - Why it doesn't work?

549
3
09-21-2010 09:38 AM
ChenglinGan
New Contributor
Hi,

All I want to do it create a buffer around a polyline with the buffer created on the right of the polyline. I used BufferConstructor and BufferCOnstructorProperties to do so but I am still getting a full polygon:mad:. Here is the code in VB.NET:

Dim featureClass As IFeatureClass = GetFeatureClassFromShapefileOnDisk("R:\test", "testline")

' GetPolylines takes featureClass and returns IFeatureCursor that points to features in featureClass
Dim FeatureCursor As IFeatureCursor = GetPolylines(featureClass)

Dim feature As IFeature = FeatureCursor.NextFeature()

While Not feature Is Nothing
            Dim featureShape As IGeometry = feature.Shape
            Dim BufferConstructor As IBufferConstruction = New BufferConstructionClass()
            Dim BufferConstructorProp As IBufferConstructionProperties = CType(BufferConstructor, IBufferConstructionProperties)
            BufferConstructorProp.SideOption = esriBufferConstructionSideEnum.esriBufferRight
            Dim featureBuffer As IPolygon = BufferConstructor.Buffer(featureShape, 0.01)
           feature = FeatureCursor.NextFeature()
End While

Any ideas?

Thanks
0 Kudos
3 Replies
NeilClemmons
Regular Contributor III
From the developer help topic for IBufferConstruction.Buffer:

Compatibility method for clients wishing to replace useages of ITopologicalOperator::Buffer. This method does not use the properties exposed in IBufferConstructionProperties.


If you want it to respect the buffer properties you have set, then you'll need to use one of the other methods on the interface.
0 Kudos
ChenglinGan
New Contributor
Thanks Neil! I am using IBufferConstruction.ConstructBuffers now.


From the developer help topic for IBufferConstruction.Buffer:

Compatibility method for clients wishing to replace useages of ITopologicalOperator::Buffer. This method does not use the properties exposed in IBufferConstructionProperties.


If you want it to respect the buffer properties you have set, then you'll need to use one of the other methods on the interface.
0 Kudos
ChrisWheldon
New Contributor
Hi all

I am suffering with the below code to buffer some polylines using IBufferConstruction Is anyone able to help please ? I am trying to get to IBufferConstructionProps but with no buffering yet I'm not going anywhere fast. Thanks for any help - I'm really stumped. I get my new records into the cursor but no features.

Chris

    pEditor.StartOperation
   
    dDist = 3           'InputBox("Buffer offset in meters(m)", "Buffer Offset......")
    l = 1
    Do Until pFeature Is Nothing

        Application.StatusBar.Message(0) = "Buffering " & l & " of " & d
        Set inputPolyline = pFeature.ShapeCopy

        'Set inputPolyline = pFeature.ShapeCopy
        Set pGeomColl = New GeometryBag
        pGeomColl.AddGeometry inputPolyline
       
        Set pEnumGeometry = pGeomColl
        pEnumGeometry.Reset
        'MsgBox "Geometry Count: " & pGeomColl.GeometryCount
        Set pGeo = pEnumGeometry.Next
        i = 1
        While Not pGeo Is Nothing
            'MsgBox "Geometry: " & i & " Geometry type: " & pGeo.GeometryType
           
            Dim pBC As IBufferConstruction
            Set pBC = New BufferConstruction
            Dim pPolygon As IPolygon
            Set pPolygon = pBC.Buffer(pEnumGeometry, dDist)
           
            Set pNewFeature = pInsertFeatureBuffer
            Set pNewFeature.Shape = pPolygon
           
            q = pInsertFeatureCursor.InsertFeature(pInsertFeatureBuffer)  'Insert the feature into the    feature cursor
           
            Set pNewFeature = pEditLayers.CurrentLayer.FeatureClass.CreateFeature
            Set pNewFeature.Shape = pPolygon
            pNewFeature.Store
           
            i = i + 1
            Set pGeo = pEnumGeometry.Next
        Wend
       
        Set pFeature = pFeatureCursor.NextFeature
        l = l + 1
    Loop
0 Kudos