/// <summary> /// 合并要素图形范围 /// </summary> /// <param name="pFeatureclass">要合并的要素类</param> /// <param name="filter">过滤条件</param> /// <returns></returns> public static IGeometry UnionFeature(ESRI.ArcGIS.Geodatabase.IFeatureClass pFeatureclass, string filter) { IGeometry geo = null; using (ComReleaser comReleaser = new ComReleaser()) { List <IGeometry> geoLst = new List <IGeometry>(); ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset = pFeatureclass as ESRI.ArcGIS.Geodatabase.IGeoDataset; ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = pFeatureclass.Search(new ESRI.ArcGIS.Geodatabase.QueryFilter { WhereClause = filter }, false); ESRI.ArcGIS.Geodatabase.IFeature pFeature = featureCursor.NextFeature(); while (pFeature != null) { geoLst.Add(pFeature.ShapeCopy); if (geoLst.Count == 50) { geo = UnionGeometry(geoLst, geoDataset.SpatialReference); geoLst.Clear(); geoLst.Add(geo); } comReleaser.ManageLifetime(pFeature); pFeature = featureCursor.NextFeature(); } if (geoLst.Count == 1) { geo = geoLst[0]; } if (geoLst.Count > 1) { geo = UnionGeometry(geoLst, geoDataset.SpatialReference); } IZAware ipZAware = geo as IZAware; if (ipZAware.ZAware == true) { ipZAware.ZAware = false; } comReleaser.ManageLifetime(featureCursor); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor); } return(geo); }
public static Boolean?isFeetFromFc(ESRI.ArcGIS.Geodatabase.IFeatureClass pFeatureClass) { ESRI.ArcGIS.Geodatabase.IGeoDataset geo = (ESRI.ArcGIS.Geodatabase.IGeoDataset)pFeatureClass; if (geo.SpatialReference is ESRI.ArcGIS.Geometry.IProjectedCoordinateSystem) { ESRI.ArcGIS.Geometry.IProjectedCoordinateSystem proj = (ESRI.ArcGIS.Geometry.IProjectedCoordinateSystem)geo.SpatialReference; if (proj.CoordinateUnit.Name.StartsWith("Meter")) { return(false); } else if (proj.CoordinateUnit.Name.StartsWith("Foot")) { return(true); } else { return(null); } } else { return(null); } }