Select to view content in your preferred language

Creating Buffer for a Poly-line feature

2225
3
07-21-2010 11:10 PM
BinodKumar
Emerging Contributor
Hi,

I m using ADF in web based application using asp.net/c#.There is requirement to create a buffer around a poly-line feature.
Can anyone suggest a way in which we can accomplish this.

thanks in advance
0 Kudos
3 Replies
spiskulaspiskula
Occasional Contributor
how about using class BufferConstruction and IBufferConstructionProperties ?
0 Kudos
BinodKumar
Emerging Contributor
I found this code from net but i m not getting what exactly i need to do there for the bold line below "spatial reference should be set here "

[C#]//This example demonstrates how to use ITopologicalOperator::Buffer
private void BufferArea()
  {
  IPoint[] points = new IPoint[5];
  //The spatial reference should be set here using IGeometry::SpatialReference (Code skipped here)
  for(int i = 0; i < points.Length; i++)
  {
     points = new PointClass();
  }
  points[0].PutCoords(0, 0);
  points[1].PutCoords(0, 10);
  points[2].PutCoords(10, 10);
  points[3].PutCoords(10, 0);
  points[4].PutCoords(0, 0);
  IPointCollection4 pointCollection = new PolygonClass();
  IGeometryBridge geometryBride = new GeometryEnvironmentClass();
  geometryBride.AddPoints(pointCollection, ref points);
  IArea area = pointCollection as IArea;
  System.Windows.Forms.MessageBox.Show("Area original polygon : " + area.Area);
  ITopologicalOperator topologicalOperator = pointCollection as ITopologicalOperator;
  //Outside buffer
  IPolygon polygon = topologicalOperator.Buffer(1) as IPolygon;
  area = polygon as IArea;
  System.Windows.Forms.MessageBox.Show( "Area polygon positive distance : " + area.Area);
  //Inside buffer
  polygon = topologicalOperator.Buffer(-1) as IPolygon;
  area = polygon as IArea;
  System.Windows.Forms.MessageBox.Show("Area polygon negative distance : " + area.Area);
}
0 Kudos
PhilBlondin
Deactivated User
The below vb function will buffer a polyline.  If your distance units are in a coordinate system which uses meters then you will have to convert the units or project the polyline into footage coordinate system.

pPL.SpatialReference = yoursourcespatialreference
pPL.Project yournewcoordinatesystem

Public Function BufferRoute(pPL As IPolyline, dBuffDistance As Double) As IPolygon
     
    Dim pTopoOp As ITopologicalOperator3
    Dim pPoly As IPolygon
    Set pTopoOp = pPL
    Set pPoly = pTopoOp.Buffer(dBuffDistance)
 
    Set BufferRoute = pPoly

    Set pPL = Nothing
    Set pTopoOp = Nothing
    Set pPoly = Nothing

End Function
0 Kudos