zoukankan      html  css  js  c++  java
  • 创建要素集

    创建要素集

        创建要素集可以通过IFeatureWorkspace接口的CreateFeatureclass方法实现。具体方法如下:
    //建立SDE连接
    IPropertySet propertySet = new PropertySetClass();            
    propertySet.SetProperty("SERVER", server);            
    propertySet.SetProperty("INSTANCE", instance);            
    propertySet.SetProperty("DATABASE", database);            
    propertySet.SetProperty("USER", user);            
    propertySet.SetProperty("PASSWORD", password);            
    propertySet.SetProperty("VERSION", version);                        
    IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)new

    SdeWorkspaceFactoryClass();            
    IWorkspace pWorkspace = workspaceFactory.Open(propertySet, 0);
    //接口查询,通过IFeatureWorkspace接口创建要素集/图层
    IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspace;

    //设置字段
    IFields pFields = new FieldsClass();
    IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;

    IField pField = new FieldClass();
    IFieldEdit pFieldEdit = (IFieldEdit)pField;
    //几何图形定义
    IGeometryDef pGeomDef = new GeometryDefClass();
    IGeometryDefEdit pGeomDefEdit = (IGeometryDefEdit)pGeomDef;
    pGeomDefEdit.GeometryType = esriGeometryType.esriGeometryPolygon;
    pgeomDefEdit.SpatialReference = new UnknownCoordinateSystem;//可从其它要素集获取,这里设为坐标系统未知。
    //添加SHAPE字段
    pFieldEdit.Name_2 = "SHAPE";
    pFieldEdit.Type_2 = esriFieldType.esriFieldGeometry;
    pFieldEdit.GeomtryDef_2 = pGeomDef;
    pFieldsEdit.AddField(pField);
    //添加一般字段
    pField = new FieldClass();
    pFieldEdit = (IFieldEdit)pField;
    pFieldEdit.Length = 30;
    pFieldEdit.Name_2 = "text";
    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
    pFieldsEdit.AddField(pField);
    //创建要素集/图层
    IFeatureClass pFeatureClass;
    pFeatureClass = pFeatureWorkspace.CreateFeatureClass

    (strName,pFields,null,null,esriFeatureType.esriFTsimple,"SHAPE","");
    //strName-图层名称;"SHAPE"-图形字段名称

  • 相关阅读:
    Xcode及模拟器SDK下载
    修改Navigation Bar上的返回按钮文本颜色,箭头颜色以及导航栏按钮的颜色
    NJKWebViewProgress ——webview进度条
    _tmain 和 main
    XSS原理
    逆向工程
    guide
    网络数据包
    Linux 文件系统 和文件属性
    Linux 文件系统
  • 原文地址:https://www.cnblogs.com/lauer0246/p/1127187.html
Copyright © 2011-2022 走看看