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"-图形字段名称

  • 相关阅读:
    SCRIPT TO GENERATE SQL*LOADER CONTROL FILE
    Setting an Oracle event:The structure of the trace syntax
    Script to Collect RAC Diagnostic Information (racdiag.sql)
    Data Block Cache Header Format Changes (Oracle8 Physical layout)
    Function Based Indexes and Global Temporary Tables
    EVENT: 10231 "skip corrupted blocks on _table_scans_"
    Materialized Views and Dimensions
    Script: Computing Table Size
    DBMS_REPAIR example
    Sql2005+:ssms 的【临时】服务器连接配置文件:
  • 原文地址:https://www.cnblogs.com/lauer0246/p/1127187.html
Copyright © 2011-2022 走看看