码迷,mamicode.com
首页 > 其他好文 > 详细

ArcEngine创建要素类01

时间:2016-06-12 18:21:14      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

单独生成要素类:

        public IFeatureClass CreateStandaloneFeatureClass(IWorkspace workspace, String
    featureClassName, IFields fieldsCollection, String shapeFieldName)
        {
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
            IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
            IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;
            // Use IFieldChecker to create a validated fields collection.
            IFieldChecker fieldChecker = new FieldCheckerClass();
            IEnumFieldError enumFieldError = null; IFields validatedFields = null;
            fieldChecker.ValidateWorkspace = workspace;
            fieldChecker.Validate(fieldsCollection, out enumFieldError, out validatedFields);
            // The enumFieldError enumerator can be inspected at this point to determine 
            // which fields were modified during validation.
            IFeatureClass featureClass = featureWorkspace.CreateFeatureClass
                (featureClassName, validatedFields, ocDesc.InstanceCLSID,
                ocDesc.ClassExtensionCLSID, esriFeatureType.esriFTSimple, shapeFieldName, ""); 
            return featureClass;
        }

在要素集中添加要素类:

        public IFeatureClass CreateFeatureDatasetFeatureClass(IFeatureDataset featureDataset,
            String featureClassName, IFields fieldsCollection, String shapeFieldName)
        {
            IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
            IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;

            // Use IFieldChecker to create a validated fields collection.
            IFieldChecker fieldChecker = new FieldCheckerClass();
            IEnumFieldError enumFieldError = null;
            IFields validatedFields = null;
            fieldChecker.ValidateWorkspace = featureDataset.Workspace;
            fieldChecker.Validate(fieldsCollection, out enumFieldError, out validatedFields);

            // The enumFieldError enumerator can be inspected at this point to determine 
            // which fields were modified during validation.
            IFeatureClass featureClass = featureDataset.CreateFeatureClass(featureClassName,
                validatedFields, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID,
                esriFeatureType.esriFTSimple, fcDesc.ShapeFieldName, "");
            return featureClass;
        }

 

ArcEngine创建要素类01

标签:

原文地址:http://www.cnblogs.com/lee24789229/p/5578320.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!