Union of buffer polygons - ConstructUnion

485
0
11-29-2012 05:06 AM
JulianaCastillo
New Contributor
Hi all,

I'm having issues when trying to combine multiple buffer polygon geometries into one while using the ConstructUnion method from the ITopologicalOperator2 class.
It does not give me an error, but the polygon I get, is not exactly the union of all other polygons.
I've attached an image of the polygon result geometry.

[ATTACH=CONFIG]19602[/ATTACH]

Here is the code I'm using.

for (int geomIdx = 0; geomIdx < bufferGeometryCollection.GeometryCount; geomIdx++)
                {

                    IGeometry currentGeom = bufferGeometryCollection.Geometry[geomIdx];
                    ISpatialReference geomSR = currentGeom.SpatialReference;

                    //if geometry is a point, convert to polygon
                    if (currentGeom.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        IEnvelope pEnv = currentGeom.Envelope;
                        pEnv.Expand(0.0001, 0.0001, false);
                        IPolygon pPoly = new PolygonClass();
                        ISegmentCollection pSegCol = (ISegmentCollection)pPoly;
                        pSegCol.SetRectangle(pEnv);
                        currentGeom = (IGeometry)pSegCol;
                    }


                    //Create an ITopologicalOperator object based upon a geometry
                    ITopologicalOperator topoOp = (ITopologicalOperator)currentGeom;
                    //'Generate the buffer
                    IPolygon bufferPolygon = (IPolygon)topoOp.Buffer(bufferDistance);

                    topoOp2 = (ITopologicalOperator2)bufferPolygon;
                    topoOp2.IsKnownSimple_2 = false;
                    topoOp2.Simplify();

                    geometryCollection.AddGeometry(topoOp2 as IGeometry, ref missing, ref missing);

                }

                IPolygon poly = new PolygonClass();
                poly.SpatialReference = _outputSpatialReference;

                ITopologicalOperator2 topologicalOperator;
                topologicalOperator = poly as ITopologicalOperator2;

                topologicalOperator.ConstructUnion(geometryCollection as IEnumGeometry);

                return topologicalOperator as IPolygon;


I'm following ESRI samples, and this is the result, which does not work.
I've tried without the simplify and it gives me the same result.
I've also tried to create the polygon by adding the rings separately with the same result.

What am I missing?

Thanks!

Juliana
Tags (2)
0 Kudos
0 Replies