• 在要素数据集中创建要素类


    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", "");
    
    }

  • 相关阅读:
    jzoj 6278. 2019.8.5【NOIP提高组A】跳房子
    2019.08.05【NOIP提高组】模拟 A 组 总结
    HTML笔记
    html中的锚点设置
    前端HTML
    数据库设计(第一范式,第二范式,第三范式)
    MySQL之锁、事务、优化、OLAP、OLTP
    MySQL数据备份与还原(mysqldump)
    MySQl创建用户和授权
    MySQL之索引原理与慢查询优化
  • 原文地址:https://www.cnblogs.com/zuiyirenjian/p/2026209.html
Copyright © 2020-2023  润新知