博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ArcEngine创建要素类01
阅读量:6302 次
发布时间:2019-06-22

本文共 3307 字,大约阅读时间需要 11 分钟。

单独生成要素类:

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;        }

 创建不同类型的要素类:

可以修改,主要是修改validatedFields,IFields字段有一个是关于要素类几何类型的,比如:IGeometryDef pGeoDef = new GeometryDefClass();            IGeometryDefEdit pGeoDefEdit = pGeoDef as IGeometryDefEdit;            pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;  //指定创建的要素类的要素类型            pGeoDefEdit.SpatialReference_2 = spatialReference;  //设置要素类的空间参考           // pSpatialReference.SetDomain(0, 99999999, 0, 9999999);            //定义一个字段集合对象            IFields pFields = new FieldsClass();            IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;            //定义单个的字段            IField pField = new FieldClass();            IFieldEdit pFieldEdit = (IFieldEdit)pField;            pFieldEdit.Name_2 = "SHAPE";            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;                      pFieldEdit.GeometryDef_2 = pGeoDef;  pFieldsEdit.AddField(pField);

 

转载于:https://www.cnblogs.com/leebokeyuan/p/5578320.html

你可能感兴趣的文章
你的可用性达标了吗?云端业务性能高可用的深度实践
查看>>
linux yum清缓存脚本
查看>>
基于epoll封装的事件回调miniserver
查看>>
天猫高管全面解读大快消2018新零售打法
查看>>
idea springboot热部署无效问题
查看>>
第八章 进程间通信
查看>>
HttpSession接口中的方法(Jsp中的session类的用法)
查看>>
「镁客早报」AI可预测心脏病人死亡时间;机器人开始在美国送外卖
查看>>
MoQ(基于.net3.5,c#3.0的mock框架)简单介绍
查看>>
物联网全面升级,十年内推动工业进入智能化新阶段
查看>>
spring-通过ListFactory注入List
查看>>
一种基于SDR实现的被动GSM嗅探
查看>>
阿里云ECS每天一件事D1:配置SSH
查看>>
SQL Server 性能调优(性能基线)
查看>>
uva 10801 - Lift Hopping(最短路Dijkstra)
查看>>
[Java Web]servlet/filter/listener/interceptor区别与联系
查看>>
POJ 2312Battle City(BFS-priority_queue 或者是建图spfa)
查看>>
从零开始学MVC3——创建项目
查看>>
CentOS 7 巨大变动之 firewalld 取代 iptables
查看>>
延时任务和定时任务
查看>>