本文整理汇总了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;
}