public static void AddDefaultField(IFieldsEdit ifieldsEdit_0, esriGeometryType esriGeometryType_0, ISpatialReference ispatialReference_0, bool bool_0, bool bool_1, int int_0) { IFieldEdit fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "OBJECTID"; fieldClass.AliasName_2 = "OBJECTID"; fieldClass.IsNullable_2 = false; fieldClass.Type_2 = esriFieldType.esriFieldTypeOID; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "SHAPE"; fieldClass.AliasName_2 = "SHAPE"; fieldClass.IsNullable_2 = true; fieldClass.Type_2 = esriFieldType.esriFieldTypeGeometry; IGeometryDefEdit geometryDefClass = new GeometryDef() as IGeometryDefEdit; geometryDefClass.SpatialReference_2 = ispatialReference_0; geometryDefClass.GridCount_2 = 1; geometryDefClass.GridSize_2[0] = (double)int_0; geometryDefClass.GeometryType_2 = esriGeometryType_0; geometryDefClass.HasZ_2 = bool_1; geometryDefClass.HasM_2 = bool_0; fieldClass.GeometryDef_2 = geometryDefClass; ifieldsEdit_0.AddField(fieldClass); }
private static IFieldEdit CreateField(string string_0, esriFieldType esriFieldType_0) { IFieldEdit fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = string_0; fieldClass.AliasName_2 = string_0; fieldClass.Type_2 = esriFieldType_0; return(fieldClass); }
public static bool Register(IFeatureClass ifeatureClass_0, string string_0) { bool result; if (ZDRegister.IsZDFeatureClass(ifeatureClass_0)) { result = false; } else { string[] array = (ifeatureClass_0 as IDataset).Name.Split(new char[] { '.' }); ZDRegisterTable zDRegisterTable = new ZDRegisterTable(); ITable table = AppConfigInfo.OpenTable("ZDInfos"); IFeatureWorkspace featureWorkspace = (ifeatureClass_0 as IDataset).Workspace as IFeatureWorkspace; string finalName = WorkspaceOperator.GetFinalName2(featureWorkspace as IWorkspace, esriDatasetType.esriDTFeatureClass, "", array[array.Length - 1], "_His"); IRow row = table.CreateRow(); RowOperator.SetFieldValue(row, zDRegisterTable.FeatureClassNameField, array[array.Length - 1]); RowOperator.SetFieldValue(row, zDRegisterTable.ZDBHFieldName, string_0); RowOperator.SetFieldValue(row, zDRegisterTable.RegisterDateFieldName, System.DateTime.Now); RowOperator.SetFieldValue(row, zDRegisterTable.HistoryFeatureClassName, finalName); string workspaceConnectInfo = WorkspaceOperator.GetWorkspaceConnectInfo((ifeatureClass_0 as IDataset).Workspace); RowOperator.SetFieldValue(row, zDRegisterTable.GDBConnectInfoName, workspaceConnectInfo); RowOperator.SetFieldValue(row, zDRegisterTable.GuidName, System.Guid.NewGuid().ToString()); row.Store(); (ifeatureClass_0 as IDataset).Name.Split(new char[] { '.' }); IFields fields = (ifeatureClass_0.Fields as IClone).Clone() as IFields; IField field = new ESRI.ArcGIS.Geodatabase.Field(); (field as IFieldEdit).Name_2 = "OriginOID_"; (field as IFieldEdit).AliasName_2 = "原始宗地编号"; (field as IFieldEdit).Type_2 = esriFieldType.esriFieldTypeInteger; (fields as IFieldsEdit).AddField(field); IFeatureClass featureClass = featureWorkspace.CreateFeatureClass(finalName, fields, null, null, esriFeatureType.esriFTSimple, "shape", ""); if ((featureWorkspace as IWorkspace).Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) { IVersionedObject3 versionedObject = featureClass as IVersionedObject3; if (versionedObject != null) { versionedObject.RegisterAsVersioned3(false); } } result = true; } return(result); }
public void AddTabField(IFieldsEdit ifieldsEdit_0, IntPtr intptr_0) { int num = TabRead._mitab_c_get_field_count(intptr_0); for (int i = 0; i < num; i++) { IFieldEdit field = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; field.Name_2 = TabRead._mitab_c_get_field_name(intptr_0, i); int num3 = TabRead._mitab_c_get_field_type(intptr_0, i); int num4 = TabRead._mitab_c_get_field_width(intptr_0, i); int num5 = TabRead._mitab_c_get_field_precision(intptr_0, i); switch (num3) { case 1: case 7: field.Type_2 = esriFieldType.esriFieldTypeString; field.Length_2 = num4; break; case 2: field.Type_2 = esriFieldType.esriFieldTypeInteger; field.Precision_2 = num4; break; case 3: field.Type_2 = esriFieldType.esriFieldTypeSmallInteger; field.Precision_2 = num4; break; case 4: field.Type_2 = esriFieldType.esriFieldTypeDouble; field.Precision_2 = num4; field.Scale_2 = num5; break; case 5: field.Type_2 = esriFieldType.esriFieldTypeSingle; field.Precision_2 = num4; break; case 6: field.Type_2 = esriFieldType.esriFieldTypeDate; break; default: { continue; } } ifieldsEdit_0.AddField(field); } }
public void AddTabField(int int_0, IFieldsEdit ifieldsEdit_0) { IFieldEdit fieldClass; switch (int_0) { case 1: case 2: case 3: case 10: { fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "S_SID"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "S_Size"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "S_Color"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); return; } case 4: { fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_Text"; fieldClass.Type_2 = esriFieldType.esriFieldTypeString; fieldClass.Length_2 = 100; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_Font"; fieldClass.Type_2 = esriFieldType.esriFieldTypeString; fieldClass.Length_2 = 100; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_Height"; fieldClass.Type_2 = esriFieldType.esriFieldTypeDouble; fieldClass.Precision_2 = 5; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_Weight"; fieldClass.Type_2 = esriFieldType.esriFieldTypeDouble; fieldClass.Precision_2 = 5; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_BKC"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_FKC"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_Angle"; fieldClass.Type_2 = esriFieldType.esriFieldTypeDouble; fieldClass.Precision_2 = 5; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_Justi"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_LT"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "T_Space"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); return; } case 5: case 6: { fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "L_PID"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "L_Width"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "L_Color"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); return; } case 7: { fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "P_BID"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "P_BBkC"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "P_BFRC"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "P_BTTP"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "P_PID"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "P_PC"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); fieldClass = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; fieldClass.Name_2 = "P_PW"; fieldClass.Type_2 = esriFieldType.esriFieldTypeInteger; ifieldsEdit_0.AddField(fieldClass); return; } case 8: case 9: { return; } default: { return; } } }
public static IFeatureClass CreateFeatureClass(object object_0, string string_0, ISpatialReference ispatialReference_0, esriFeatureType esriFeatureType_0, esriGeometryType esriGeometryType_0, IFields ifields_0, UID uid_0, UID uid_1, string string_1) { if (object_0 == null) { throw new Exception("[objectWorkspace] 不能为空"); } if ((object_0 is IWorkspace ? false : !(object_0 is IFeatureDataset))) { throw new Exception("[objectWorkspace] 必须是IWorkspace或IFeatureDataset"); } if (string_0 == "") { throw new Exception("[name] cannot be empty"); } if ((!(object_0 is IWorkspace) ? false : ispatialReference_0 == null)) { throw new Exception("[spatialReference] cannot be null for StandAlong FeatureClasses"); } if (uid_0 == null) { uid_0 = new UID(); switch (esriFeatureType_0) { case esriFeatureType.esriFTSimple: { uid_0.Value = "{52353152-891A-11D0-BEC6-00805F7C4268}"; break; } case esriFeatureType.esriFTSimpleJunction: { esriGeometryType_0 = esriGeometryType.esriGeometryPoint; uid_0.Value = "{CEE8D6B8-55FE-11D1-AE55-0000F80372B4}"; break; } case esriFeatureType.esriFTSimpleEdge: { esriGeometryType_0 = esriGeometryType.esriGeometryPolyline; uid_0.Value = "{E7031C90-55FE-11D1-AE55-0000F80372B4}"; break; } case esriFeatureType.esriFTComplexJunction: { uid_0.Value = "{DF9D71F4-DA32-11D1-AEBA-0000F80372B4}"; break; } case esriFeatureType.esriFTComplexEdge: { esriGeometryType_0 = esriGeometryType.esriGeometryPolyline; uid_0.Value = "{A30E8A2A-C50B-11D1-AEA9-0000F80372B4}"; break; } case esriFeatureType.esriFTAnnotation: { esriGeometryType_0 = esriGeometryType.esriGeometryPolygon; uid_0.Value = "{E3676993-C682-11D2-8A2A-006097AFF44E}"; break; } case esriFeatureType.esriFTDimension: { esriGeometryType_0 = esriGeometryType.esriGeometryPolygon; uid_0.Value = "{496764FC-E0C9-11D3-80CE-00C04F601565}"; break; } } } if (uid_1 == null) { switch (esriFeatureType_0) { case esriFeatureType.esriFTAnnotation: { uid_1 = new UID() { Value = "{24429589-D711-11D2-9F41-00C04F6BC6A5}" }; break; } case esriFeatureType.esriFTDimension: { uid_1 = new UID() { Value = "{48F935E2-DA66-11D3-80CE-00C04F601565}" }; break; } } } if (ifields_0 == null) { ifields_0 = new ESRI.ArcGIS.Geodatabase.Fields(); IFieldsEdit ifields0 = (IFieldsEdit)ifields_0; IGeometryDef geometryDefClass = new GeometryDef(); IGeometryDefEdit esriGeometryType0 = (IGeometryDefEdit)geometryDefClass; esriGeometryType0.GeometryType_2 = esriGeometryType_0; esriGeometryType0.GridCount_2 = 1; esriGeometryType0.GridSize_2[0] = 0.5; esriGeometryType0.AvgNumPoints_2 = 2; esriGeometryType0.HasM_2 = false; esriGeometryType0.HasZ_2 = true; if (object_0 is IWorkspace) { esriGeometryType0.SpatialReference_2 = ispatialReference_0; } IField fieldClass = new ESRI.ArcGIS.Geodatabase.Field(); IFieldEdit fieldEdit = (IFieldEdit)fieldClass; fieldEdit.Name_2 = "OBJECTID"; fieldEdit.AliasName_2 = "OBJECTID"; fieldEdit.Type_2 = esriFieldType.esriFieldTypeOID; ifields0.AddField(fieldClass); IField field = new ESRI.ArcGIS.Geodatabase.Field(); IFieldEdit fieldEdit1 = (IFieldEdit)field; fieldEdit1.Name_2 = "SHAPE"; fieldEdit1.AliasName_2 = "SHAPE"; fieldEdit1.Type_2 = esriFieldType.esriFieldTypeGeometry; fieldEdit1.GeometryDef_2 = geometryDefClass; ifields0.AddField(field); } string name = ""; int num = 0; while (true) { if (num > ifields_0.FieldCount - 1) { break; } else if (ifields_0.Field[num].Type == esriFieldType.esriFieldTypeGeometry) { name = ifields_0.Field[num].Name; break; } else { num++; } } if (name == "") { throw new Exception("Cannot locate geometry field in FIELDS"); } IFeatureClass featureClass = null; if (object_0 is IWorkspace) { IFeatureWorkspace object0 = (IFeatureWorkspace)((IWorkspace)object_0); featureClass = object0.CreateFeatureClass(string_0, ifields_0, uid_0, uid_1, esriFeatureType_0, name, string_1); } else if (object_0 is IFeatureDataset) { IFeatureDataset featureDataset = (IFeatureDataset)object_0; featureClass = featureDataset.CreateFeatureClass(string_0, ifields_0, uid_0, uid_1, esriFeatureType_0, name, string_1); } return(featureClass); }
public static IFields createBasicFields(esriGeometryType shapeType, ISpatialReference pSpaRef, bool hasM = false, bool hasZ = false) { // Error Handling const string functionName = "createBasicFields"; IFields pFlds; IFieldsEdit pFldsEdt; IField pFld; IFieldEdit pFldEdt; IGeometryDefEdit pGeoDef; try { pFlds = new ESRI.ArcGIS.Geodatabase.Fields(); pFldsEdt = (IFieldsEdit)pFlds; pFld = new ESRI.ArcGIS.Geodatabase.Field(); pFldEdt = (IFieldEdit)pFld; pGeoDef = new GeometryDef() as IGeometryDefEdit; pGeoDef.GeometryType_2 = shapeType; pGeoDef.HasM_2 = hasM; pGeoDef.HasZ_2 = hasZ; pGeoDef.SpatialReference_2 = pSpaRef; // add Geometry field pFldEdt = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; pFldEdt.Name_2 = "Shape"; pFldEdt.IsNullable_2 = true; pFldEdt.Type_2 = esriFieldType.esriFieldTypeGeometry; pFldEdt.GeometryDef_2 = pGeoDef; pFldsEdt.AddField(pFldEdt); if (shapeType == esriGeometryType.esriGeometryPolygon) { pFldEdt = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; pFldEdt.Name_2 = "shape_area"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldEdt.Precision_2 = 19; pFldEdt.Scale_2 = 3; pFldsEdt.AddField(pFldEdt); } pFldEdt = new ESRI.ArcGIS.Geodatabase.Field() as IFieldEdit; pFldEdt.Name_2 = "area"; pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble; pFldEdt.Precision_2 = 19; pFldEdt.Scale_2 = 3; pFldsEdt.AddField(pFldEdt); } catch (Exception e) { MessageBox.Show(functionName + " :: " + e.Message, "SF10", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } return pFldsEdt; }