zoukankan      html  css  js  c++  java
  • 在要素数据集中创建要素类

    public IFeatureClass IFeatureDataset__CreateFeatureClass(IFeatureDataset featureDataset, String nameOfFeatureClass)
    {
    
    // This function creates a new feature class in a supplied feature dataset by building all of the
    // fields from scratch. IFeatureClassDescription (or IObjectClassDescription if the table is 
      // created at the workspace level) can be used to get the required fields and are used to 
      // get the InstanceClassID and ExtensionClassID.
    // Create new fields collection with the number of fields you plan to add. Must add at least two fields
    // for a feature class: Object ID and Shape field.
    IFields fields = new FieldsClass();
    IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
    fieldsEdit.FieldCount_2 = 3;
    
    // Create Object ID field.
    IField fieldUserDefined = new Field();
    
    IFieldEdit fieldEdit = (IFieldEdit)fieldUserDefined;
    fieldEdit.Name_2 = "OBJECTID";
    fieldEdit.AliasName_2 = "OBJECT ID";
    fieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
    fieldsEdit.set_Field(0, fieldUserDefined);
    
    // Create Shape field.
    fieldUserDefined = new Field();
    fieldEdit = (IFieldEdit)fieldUserDefined;
    
    // Set up geometry definition for the Shape field.
    // You do not have to set the spatial reference, as it is inherited from the feature dataset.
    IGeometryDef geometryDef = new GeometryDefClass();
    IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
    geometryDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline;
    
    // By setting the grid size to 0, you are allowing ArcGIS to determine the appropriate grid sizes for the feature class. 
    // If in a personal geodatabase, the grid size is 1,000. If in a file or ArcSDE geodatabase, the grid size
    // is based on the initial loading or inserting of features.
    geometryDefEdit.GridCount_2 = 1;
    geometryDefEdit.set_GridSize(0, 0);
    geometryDefEdit.HasM_2 = false;
    geometryDefEdit.HasZ_2 = false;
    
    // Set standard field properties.
    fieldEdit.Name_2 = "SHAPE";
    fieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
    fieldEdit.GeometryDef_2 = geometryDef;
    fieldEdit.IsNullable_2 = true;
    fieldEdit.Required_2 = true;
    fieldsEdit.set_Field(1, fieldUserDefined);
    
    // Create a field of type double to hold some information for the features.
    fieldUserDefined = new Field();
    
     fieldEdit = (IFieldEdit)fieldUserDefined;
    fieldEdit.Name_2 = "Avg_income";
    fieldEdit.AliasName_2 = "Average income for 1999-2000";
    fieldEdit.Editable_2 = true;
    fieldEdit.IsNullable_2 = false;
    fieldEdit.Precision_2 = 2;
    fieldEdit.Scale_2 = 5;
    fieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
    fieldsEdit.set_Field(2, fieldUserDefined);
    
    // Create a feature class description object to use for specifying the CLSID and EXTCLSID.
    IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
    IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;
    
    return featureDataset.CreateFeatureClass(nameOfFeatureClass, fields, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID, esriFeatureType.esriFTSimple, "SHAPE", "");
    
    }

  • 相关阅读:
    很久没有写代码日记了。
    Bundle数据类型
    8-18 缓存垃圾清理
    关于 printf
    强制类型转换/隐式类型转换
    JAVA文件扫描(递归)
    字符串
    8-17 安卓内存清理
    【11-29】excel reader
    orale 乱码
  • 原文地址:https://www.cnblogs.com/zuiyirenjian/p/2026209.html
Copyright © 2011-2022 走看看