www.pudn.com > ArcgisMapOperation.rar > UserPerprotyQuery.cs


using System; 
using System.Collections.Generic; 
using System.Text; 
 
using ESRI.ArcGIS.Geodatabase; 
using ESRI.ArcGIS.Carto; 
using ESRI.ArcGIS.Geometry; 
using ArcgisMapOperation.Struct; 
 
namespace ArcgisMapOperation.EsriLib 
{ 
    public class UserPerprotyQuery 
    { 
        ///  
        /// 获取IFeature 
        ///  
        /// 图层 
        /// 查询条件(name ='A') 
        ///  
        public static IFeature GetFeatureByQueryData(IFeatureLayer pFeatureLayer,string strQueryWhere) 
        { 
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; 
 
            //查询获取图例 
            IQueryFilter pQueryFilter = new QueryFilter(); 
            pQueryFilter.WhereClause = strQueryWhere; 
 
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(pQueryFilter, false); 
 
            IFeature pFeature = pFeatureCursor.NextFeature(); 
            while (pFeature == null) 
            { 
                pFeature = pFeatureCursor.NextFeature(); 
            } 
 
            return pFeature; 
        } 
 
        ///  
        /// 获取ISelectionSet  
        ///  
        /// 图层 
        /// 查询条件(name ='A') 
        ///  
        public static ISelectionSet GetFeatureSetByQueryData(IFeatureLayer pFeatureLayer, string strQueryWhere) 
        { 
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; 
 
            //查询获取图例 
            IQueryFilter pQueryFilter = new QueryFilter(); 
            pQueryFilter.WhereClause = strQueryWhere; 
 
            ISelectionSet selectionSet = pFeatureClass.Select(pQueryFilter, esriSelectionType.esriSelectionTypeIDSet, 
                esriSelectionOption.esriSelectionOptionOnlyOne, null); 
 
            return selectionSet; 
        } 
 
    
        ///  
        /// 内存中创建记录IFeature 
        ///  
        ///  
        public static void CreateNewFeature(IFeatureClass featureClass, TableInfo tabInfo) 
        { 
            if (featureClass.ShapeType != tabInfo.ShapeValue.GeometryType)  
            {  
                return; 
            } 
 
            IFeature feature = featureClass.CreateFeature(); 
            feature.Shape = tabInfo.ShapeValue; 
 
            ISubtypes subtypes = (ISubtypes)featureClass; 
            IRowSubtypes rowSubtypes = (IRowSubtypes)feature; 
            if (subtypes.HasSubtype) 
            { 
                rowSubtypes.SubtypeCode = 1; 
            } 
 
            rowSubtypes.InitDefaultValues(); 
 
            int i = 0; 
            foreach (string strField in tabInfo.FieldName) 
            { 
                feature.set_Value(feature.Fields.FindField(strField), tabInfo.FieldValue[i]); 
                i++; 
            } 
 
            feature.Store(); 
        } 
 
    } 
}