当前位置: 首页>>代码示例>>C#>>正文


C# ESRI.CreateFeatureClass方法代码示例

本文整理汇总了C#中ESRI.CreateFeatureClass方法的典型用法代码示例。如果您正苦于以下问题:C# ESRI.CreateFeatureClass方法的具体用法?C# ESRI.CreateFeatureClass怎么用?C# ESRI.CreateFeatureClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ESRI的用法示例。


在下文中一共展示了ESRI.CreateFeatureClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePolygonFeatureClass


//.........这里部分代码省略.........
                    osmSupportingElementField.Length_2 = 5;
                    osmSupportingElementField.DefaultValue_2 = "no";
                    osmSupportingElementField.Required_2 = true;
                    fieldsEdit.AddField((IField)osmSupportingElementField);

                    IFieldEdit osmMembersField = new FieldClass() as IFieldEdit;
                    osmMembersField.Name_2 = "osmMembers";
                    //if (((IWorkspace)workspace).Type == esriWorkspaceType.esriLocalDatabaseWorkspace)
                    //{
                    osmMembersField.Type_2 = esriFieldType.esriFieldTypeBlob;
                    osmMembersField.Required_2 = true;
                    //}
                    //else
                    //{
                    //    osmMembersField.Type_2 = esriFieldType.esriFieldTypeXML;
                    //}
                    fieldsEdit.AddField((IField)osmMembersField);

                    //IFieldEdit osmTrackChangesField = new FieldClass() as IFieldEdit;
                    //osmTrackChangesField.Name_2 = "osmTrackChanges";
                    //osmTrackChangesField.Required_2 = true;
                    //osmTrackChangesField.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
                    //osmTrackChangesField.DefaultValue_2 = 0;
                    //fieldsEdit.AddField((IField)osmTrackChangesField);

                    fields = (ESRI.ArcGIS.Geodatabase.IFields)fieldsEdit; // Explicit Cast
                }

                System.String strShapeField = "";

                // locate the shape field
                for (int j = 0; j < fields.FieldCount; j++)
                {
                    if (fields.get_Field(j).Type == ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry)
                    {
                        strShapeField = fields.get_Field(j).Name;

                        // redefine geometry type

                        IFieldEdit shapeField = fields.get_Field(j) as IFieldEdit;
                        IGeometryDefEdit geometryDef = new GeometryDefClass() as IGeometryDefEdit;
                        geometryDef.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
                        geometryDef.HasZ_2 = false;
                        geometryDef.HasM_2 = false;
                        geometryDef.GridCount_2 = 1;
                        geometryDef.set_GridSize(0, 0);

                        geometryDef.SpatialReference_2 = ((IGeoDataset)featureDataset).SpatialReference;

                        shapeField.GeometryDef_2 = (IGeometryDef)geometryDef;

                        break;
                    }
                }

                // Use IFieldChecker to create a validated fields collection.
                ESRI.ArcGIS.Geodatabase.IFieldChecker fieldChecker = new ESRI.ArcGIS.Geodatabase.FieldCheckerClass();
                ESRI.ArcGIS.Geodatabase.IEnumFieldError enumFieldError = null;
                ESRI.ArcGIS.Geodatabase.IFields validatedFields = null;
                fieldChecker.ValidateWorkspace = (ESRI.ArcGIS.Geodatabase.IWorkspace)workspace;
                fieldChecker.Validate(fields, out enumFieldError, out validatedFields);

                // The enumFieldError enumerator can be inspected at this point to determine
                // which fields were modified during validation.

                // finally create and return the feature class
                if (featureDataset == null)// if no feature dataset passed in, create at the workspace level
                {
                    featureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, CLSID, CLSEXT, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword);
                    IPropertySet extensionPropertySet = new PropertySetClass();
                    extensionPropertySet.SetProperty("VERSION", OSMClassExtensionManager.Version);
                    ((IClassSchemaEdit2)featureClass).AlterClassExtensionProperties(extensionPropertySet);

                }
                else
                {
                    featureClass = featureDataset.CreateFeatureClass(featureClassName, validatedFields, CLSID, CLSEXT, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword);
                    IPropertySet extensionPropertySet = new PropertySetClass();
                    extensionPropertySet.SetProperty("VERSION", OSMClassExtensionManager.Version);
                    ((IClassSchemaEdit2)featureClass).AlterClassExtensionProperties(extensionPropertySet);
                }

                // create the openstreetmap spcific metadata
                _osmUtility.CreateOSMMetadata((IDataset)featureClass, metadataAbstract, metadataPurpose);

                // the change at release 2.1 requires a new model name
                IModelInfo fcModelInfo = featureClass as IModelInfo;
                if (fcModelInfo != null)
                {
                    fcModelInfo.ModelName = OSMClassExtensionManager.OSMModelName;
                }

            }
            catch
            {
                throw;
            }

            return featureClass;
        }
开发者ID:hallahan,项目名称:arcgis-osm-editor,代码行数:101,代码来源:OSMToolHelper.cs


注:本文中的ESRI.CreateFeatureClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。