bac_cc

IBufferConstruction

Discussion created by bac_cc on May 9, 2012
Latest reply on May 11, 2012 by bac_cc
Everything seems to work fine, up until I actually create the buffer, then it doesn't do anything and has 0 shapebuffers. the geometry collection does have 1 object as it enters ConstructBuffers.



IGeometryPtr BufferGeometry(IGeometryPtr inShapePtr, double distance, esriBufferConstructionSideEnum side)
{
long buffCount = -1;

IBufferConstructionPropertiesPtr bufferProp(CLSID_BufferConstruction);
IBufferConstructionPtr bufferPtr = (IBufferConstructionPtr)bufferProp;

bufferProp->put_SideOption(side);
bufferProp->put_EndOption(esriBufferFlat);
bufferProp->put_ExplodeBuffers(VARIANT_FALSE);
bufferProp->put_OutsideOnly(VARIANT_FALSE);
bufferProp->put_GenerateCurves(VARIANT_FALSE);
bufferProp->put_UnionOverlappingBuffers(VARIANT_TRUE);
bufferProp->put_DensifyDeviation(-1);

if(!inShapePtr)
  return NULL;

IGeometryCollectionPtr geometryBag(CLSID_GeometryBag);
IGeometryBagPtr shapesBagPtr = (IGeometryBagPtr)geometryBag;

ISpatialReferencePtr spatialRefPtr;
inShapePtr->get_SpatialReference(&spatialRefPtr);

((IGeometryPtr)shapesBagPtr)->putref_SpatialReference(spatialRefPtr);

((IGeometryCollectionPtr)shapesBagPtr)->AddGeometry(inShapePtr, &vtMissing, &vtMissing);

((IGeometryCollectionPtr)shapesBagPtr)->get_GeometryCount(&buffCount);


IGeometryCollectionPtr shapebuffer(CLSID_GeometryBag);
((IGeometryPtr)shapebuffer)->putref_SpatialReference(spatialRefPtr);

HRESULT hr = bufferPtr->ConstructBuffers((IEnumGeometryPtr)shapesBagPtr, distance, shapebuffer);

if(shapebuffer)
  shapebuffer->get_GeometryCount(&buffCount);

return shapebuffer;
}

Outcomes