///
///获取单个要素的外包矩形///
///
///
publicIEnvelope GetEnvelope(IFeature pFeature)
{
IEnvelope pEnvelope=pFeature.Extent;returnpEnvelope;
}///
///通过ITopologicalOperator接口,获得包含几个或多个要素的外包矩形///
///
///
publicIEnvelope GetEnvelope(IGeometryCollection pGeometryCollection)
{
IPolygon pPolygon= newPolygonClass();
ITopologicalOperator pTopo;
pTopo= pPolygon asITopologicalOperator;
pTopo.ConstructUnion(pGeometryCollectionasIEnumGeometry);
IEnvelope pEnvelope=pPolygon.Envelope;returnpEnvelope;
}///
///通过ITopologicalOperator接口,获得包含几个或多个要素的外包矩形///
///
///
public IEnvelope GetEnvelope(IFeatureClass featureClass, string whereCaluse = "1=1")
{if (featureClass == null)
{return null; }
IGeoDataset geoDataset= featureClass asIGeoDataset;
IGeometry geometryBag= newGeometryBagClass();
ISpatialFilter queryFilter= newSpatialFilterClass();
queryFilter.WhereClause=whereCaluse;
geometryBag.SpatialReference=geoDataset.SpatialReference;
IFeatureCursor featureCursor= featureClass.Search(queryFilter, false);
IGeometryCollection geometryCollection= geometryBag asIGeometryCollection;
IFeature currentFeature=featureCursor.NextFeature();object missing =Type.Missing;int j = 0;while (currentFeature != null)
{
j++;
geometryCollection.AddGeometry(currentFeature.Shape,ref missing, refmissing);
currentFeature=featureCursor.NextFeature();
}if (featureCursor != null)
ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(featureCursor);
ITopologicalOperator unionedPolygon= newPolygonClass();
unionedPolygon.ConstructUnion(geometryBagasIEnumGeometry);return (unionedPolygon asIPolygon).Envelope;
}///
///通过IGeoDataset接口,获得一个要素图层的外包矩形///
///
///
publicIEnvelope GetEnvelope(IFeatureClass pFeatureClass)
{
IGeoDataset pGeoDataset;
pGeoDataset= pFeatureClass asIGeoDataset;
IEnvelope pEnvelope=pGeoDataset.Extent;returnpEnvelope;
}