一:图形融合(待补充)
//对于面要素,如果满足条件,返回融合后对象
IGeometryPtr GetUnionGeometryByFilter(IFeatureClassPtr spFeaClass,LPCTSTR lpstrWhere)
{
if( spFeaClass==NULL )
return NULL;
esriGeometryType gType;
spFeaClass->get_ShapeType(&gType);
//if( gType!=esriGeometryPolygon )
// return GetGeometryByFilter(spFeaClass,lpstrWhere);
//循环获得所有对象
IQueryFilterPtr spFilter(__uuidof(QueryFilter));
spFilter->SubFields = spFeaClass->ShapeFieldName;
spFilter->WhereClause = lpstrWhere;
try
{
IFeatureCursorPtr spCursor = spFeaClass->Search(spFilter,VARIANT_FALSE);
IFeaturePtr spFeature = spCursor->NextFeature();
if(spFeature == NULL) return NULL;
IGeometryPtr spFirstGeo = spFeature->Shape;
spFeature = spCursor->NextFeature();
if(spFeature == NULL)
{// 表示当前仅一个对象
return spFirstGeo;
}
//开始循环
IGeometryCollectionPtr spCol;
spCol.CreateInstance(__uuidof(GeometryBag));
spCol->AddGeometry(spFirstGeo);
while( spFeature != NULL)
{
spCol->AddGeometry(spFeature->Shape);
spCursor->raw_NextFeature(&spFeature);
}
//开始融合
ITopologicalOperatorPtr spPolyTop;
spPolyTop.CreateInstance(__uuidof(polygon));
spPolyTop->ConstructUnion( ( IEnumGeometryPtr )spCol);
return spPolyTop;
}
catch (...)
{
}
return NULL;
}