public ESRI.ArcGIS.Geodatabase.IFieldEdit2 CreateField(string name, string alias, ESRI.ArcGIS.Geodatabase.esriFieldType fldtype, int length) { ESRI.ArcGIS.Geodatabase.IField field = new ESRI.ArcGIS.Geodatabase.FieldClass(); ESRI.ArcGIS.Geodatabase.IFieldEdit2 fe = (ESRI.ArcGIS.Geodatabase.IFieldEdit2)field; fe.Length_2 = length; fe.Name_2 = name; fe.AliasName_2 = alias; fe.Type_2 = fldtype; return(fe); }
public override ESRI.ArcGIS.Geodatabase.IFields2 CreateFields(ESRI.ArcGIS.Geometry.ISpatialReference spatialReference) { ESRI.ArcGIS.Geodatabase.IFields2 fields = new ESRI.ArcGIS.Geodatabase.FieldsClass(); ESRI.ArcGIS.Geodatabase.IFieldsEdit fieldsEdit = (ESRI.ArcGIS.Geodatabase.IFieldsEdit)fields; ESRI.ArcGIS.Geodatabase.IFieldEdit2 fieldedit = CreateField("ObjectID", "FID", ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeOID, 0); fieldsEdit.AddField(fieldedit); //add id fieldedit = CreateField("LineID", "LineID", ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGUID, 36); fieldedit.DefaultValue_2 = 0; // add default for letter fieldsEdit.AddField(fieldedit); // place holder for letter fieldedit = CreateField("LETTER", "LETTER", ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString, 20); fieldedit.DefaultValue_2 = "X"; // add default for letter fieldsEdit.AddField(fieldedit); // just another field fieldedit = CreateField("NOTES", "NOTES", ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString, 225); fieldsEdit.AddField(fieldedit); // add geomtype ESRI.ArcGIS.Geodatabase.IGeometryDef geometryDef = new ESRI.ArcGIS.Geodatabase.GeometryDefClass(); ESRI.ArcGIS.Geodatabase.IGeometryDefEdit geometryDefEdit = (ESRI.ArcGIS.Geodatabase.IGeometryDefEdit)geometryDef; geometryDefEdit.GeometryType_2 = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline; ESRI.ArcGIS.Geometry.ISpatialReferenceResolution spatialReferenceResolution = (ESRI.ArcGIS.Geometry.ISpatialReferenceResolution)spatialReference; ESRI.ArcGIS.Geometry.ISpatialReferenceTolerance spatialReferenceTolerance = (ESRI.ArcGIS.Geometry.ISpatialReferenceTolerance)spatialReference; spatialReferenceTolerance.SetDefaultXYTolerance(); geometryDefEdit.SpatialReference_2 = spatialReference; ESRI.ArcGIS.Geodatabase.IField geometryField = new ESRI.ArcGIS.Geodatabase.FieldClass(); ESRI.ArcGIS.Geodatabase.IFieldEdit geometryFieldEdit = (ESRI.ArcGIS.Geodatabase.IFieldEdit)geometryField; geometryFieldEdit.Name_2 = "Shape"; geometryFieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry; geometryFieldEdit.GeometryDef_2 = geometryDef; fieldsEdit.AddField(geometryField); return(fields); }