• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FieldClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FieldClass的典型用法代码示例。如果您正苦于以下问题:C# FieldClass类的具体用法?C# FieldClass怎么用?C# FieldClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FieldClass类属于命名空间,在下文中一共展示了FieldClass类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InMemoryWorkspaceFactoryClass

        private void 添加点型图层ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //创建要素类
            #region 创建新的内存工作空间
            IWorkspaceFactory pWSF = new InMemoryWorkspaceFactoryClass();
            IWorkspaceName pWSName = pWSF.Create("", "Temp", null, 0);

            IName pName = (IName)pWSName;
            IWorkspace pMemoryWS = (IWorkspace)pName.Open();
            #endregion

            IField oField = new FieldClass();
            IFields oFields = new FieldsClass();
            IFieldsEdit oFieldsEdit = null;
            IFieldEdit oFieldEdit = null;
            IFeatureClass oFeatureClass = null;
            IFeatureLayer oFeatureLayer = null;

            oFieldsEdit = oFields as IFieldsEdit;
            oFieldEdit = oField as IFieldEdit;
            oFieldEdit.Name_2 = "OBJECTID";
            oFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
            oFieldEdit.IsNullable_2 = false;
            oFieldEdit.Required_2 = false;
            oFieldsEdit.AddField(oField);

            oField = new FieldClass();
            oFieldEdit = oField as IFieldEdit;
            IGeometryDef pGeoDef = new GeometryDefClass();
            IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef;
            pGeoDefEdit.AvgNumPoints_2 = 5;
            pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
            pGeoDefEdit.GridCount_2 = 1;
            pGeoDefEdit.HasM_2 = false;
            pGeoDefEdit.HasZ_2 = false;
            pGeoDefEdit.SpatialReference_2 = axMapControl1.SpatialReference;
            oFieldEdit.Name_2 = "SHAPE";
            oFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            oFieldEdit.GeometryDef_2 = pGeoDef;
            oFieldEdit.IsNullable_2 = true;
            oFieldEdit.Required_2 = true;
            oFieldsEdit.AddField(oField);

            oField = new FieldClass();
            oFieldEdit = oField as IFieldEdit;
            oFieldEdit.Name_2 = "Code";
            oFieldEdit.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
            //oFieldEdit.Length = 10;
            oFieldEdit.IsNullable_2 = true;
            oFieldsEdit.AddField(oField);
            //创建要素类
            oFeatureClass = (pMemoryWS as IFeatureWorkspace).CreateFeatureClass("Temp", oFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
            oFeatureLayer = new FeatureLayerClass();
            oFeatureLayer.Name = "PointLayer";
            oFeatureLayer.FeatureClass = oFeatureClass;
            //创建唯一值符号化对象


            IUniqueValueRenderer pURender = new UniqueValueRendererClass();
            pURender.FieldCount = 1;
            pURender.set_Field(0, "Code");
            pURender.UseDefaultSymbol = false;
            //创建SimpleMarkerSymbolClass对象
            ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
            //创建RgbColorClass对象为pSimpleMarkerSymbol设置颜色
            IRgbColor pRgbColor = new RgbColorClass();
            pRgbColor.Red = 255;
            pSimpleMarkerSymbol.Color = pRgbColor as IColor;
            //设置pSimpleMarkerSymbol对象的符号类型,选择钻石
            pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;
            //设置pSimpleMarkerSymbol对象大小,设置为5
            pSimpleMarkerSymbol.Size = 5;
            //显示外框线
            pSimpleMarkerSymbol.Outline = true;
            //为外框线设置颜色
            IRgbColor pLineRgbColor = new RgbColorClass();
            pLineRgbColor.Green = 255;
            pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor;
            //设置外框线的宽度
            pSimpleMarkerSymbol.OutlineSize = 1; 

            //半透明颜色

 


            pURender.AddValue("1", "", pSimpleMarkerSymbol as ISymbol);

            //唯一值符号化内存图层
            (oFeatureLayer as IGeoFeatureLayer).Renderer = pURender as IFeatureRenderer;
            ILayerEffects pLyrEffect = oFeatureLayer as ILayerEffects;
            //透明度
            pLyrEffect.Transparency = 0;


            oFeatureLayer.Visible = true;

            this.axMapControl1.AddLayer(oFeatureLayer,axMapControl1.LayerCount);
            insertpoint = true;
        }
开发者ID:hijushen,项目名称:WindowDemo,代码行数:100,代码来源:MainForm.cs


示例2: CreateFeatureClass

        //http://resources.esri.com/help/9.3/arcgisengine/arcobjects/esriGeoDatabase/IFeatureWorkspace.CreateFeatureClass_Example.htm
        static IFeatureClass CreateFeatureClass(string name, IFeatureWorkspace ftrSpc, esriGeometryType type, int epsg, List<dynamic> extraFields)
        {
            IFeatureClass ftrc = null;
            if(null != ftrSpc && null != name)
            {
                IFieldsEdit flds = new FieldsClass();
                flds.FieldCount_2 = 2 + (extraFields == null ? 0 : extraFields.Count);

                IFieldEdit fld = new FieldClass();
                fld.Name_2 = OBJECT_ID;
                fld.Type_2 = esriFieldType.esriFieldTypeOID;
                flds.Field_2[0] = fld;

                fld = new FieldClass();
                fld.Name_2 = SHP_NAME;
                fld.Type_2 = esriFieldType.esriFieldTypeGeometry;
                fld.GeometryDef_2 = CreateGeometryDef(type, epsg);
                flds.Field_2[1] = fld;
                int eidx = 2;
                foreach(var efld in extraFields)
                {
                    fld = new FieldClass();
                    fld.Name_2 = efld.Name;
                    fld.Type_2 = efld.Type;
                    flds.Field_2[eidx++] = fld;
                }
                ftrc = ftrSpc.CreateFeatureClass(name, flds, null, null, esriFeatureType.esriFTSimple, SHP_NAME, null);
            }
            return ftrc;
        }
开发者ID:hellocomrade,项目名称:ArcObject,代码行数:31,代码来源:Program.cs


示例3: addScoreToolStripMenuItem_Click

        private void addScoreToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IFeatureLayer fealyr = axMapControl1.get_Layer(0) as IFeatureLayer;
            IFeatureClass feacls = fealyr.FeatureClass;
            IField field = new FieldClass();
            IFieldEdit2 fe = field as IFieldEdit2;
            fe.Name_2 = "FinalScore";
            fe.Type_2 = esriFieldType.esriFieldTypeDouble;

            feacls.AddField(field);
            int index = feacls.FindField("FinalScore");
            object obj = null;
            Random rand = new Random();
            using (ComReleaser com = new ComReleaser())
            {

                IFeatureCursor cursor = feacls.Search(null, true);
                com.ManageLifetime(cursor);

                IFeature fea = cursor.NextFeature();
                while (fea != null)
                {
                    obj = rand.NextDouble() * 100;
                    fea.set_Value(index, obj);
                    fea.Store();
                    fea = cursor.NextFeature();
                }
            }
        }
开发者ID:weigiser,项目名称:AOProjects,代码行数:29,代码来源:FormMain.cs


示例4: CreateFClassInPDB

        public static IFeatureClass CreateFClassInPDB(IWorkspace accessworkspace, string feaDSname, string FCname, esriGeometryType esriGeometryType,ISpatialReference sprf)
        {
            try
            {
                IFeatureDataset featureDataset = ((IFeatureWorkspace)accessworkspace).OpenFeatureDataset(feaDSname);
                //IGeoDataset geoDataset = featureDataset as IGeoDataset;

                IFields pFields = new FieldsClass();
                IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
                IField pField = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = "SHAPE";
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;

                IGeometryDef pGeometryDef = new GeometryDefClass();
                IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;
                pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
                pFieldEdit.GeometryDef_2 = pGeometryDef;
                pFieldsEdit.AddField(pField);

                IFeatureClass fc = featureDataset.CreateFeatureClass(FCname, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
                return fc;
            }

            catch (Exception ee)
            {
                MessageBox.Show(ee.Message.ToString());
                return null;
            }
        }
开发者ID:chinasio,项目名称:minegis,代码行数:30,代码来源:GDBData.cs


示例5: CreateFeatureClass

        static IFeatureClass CreateFeatureClass(IFeatureWorkspace workspace, string name, ISpatialReference outSR)
        {
            IFieldsEdit fields = new FieldsClass();

            IFieldEdit field = new FieldClass();
            field.Type_2 = esriFieldType.esriFieldTypeOID;
            field.Name_2 = "OBJECTID";
            field.AliasName_2 = "OBJECTID";
            fields.AddField(field);

            IGeometryDefEdit geom = new GeometryDefClass();
            geom.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            geom.SpatialReference_2 = outSR;
            geom.HasM_2 = true;
            geom.HasZ_2 = false;

            field = new FieldClass();
            field.Name_2 = "SHAPE";
            field.AliasName_2 = "SHAPE";
            field.Type_2 = esriFieldType.esriFieldTypeGeometry;
            field.GeometryDef_2 = geom;
            fields.AddField(field);

            return workspace.CreateFeatureClass(name, fields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
        }
开发者ID:NGFieldScope,项目名称:Geoprocessing,代码行数:25,代码来源:Program.cs


示例6: AddField

 public static void AddField(this IFields fields, string name, esriFieldType type)
 {
     IFieldEdit fe = new FieldClass();
     fe.Name_2 = name;
     fe.Type_2 = type;
     ((IFieldsEdit)fields).AddField((IField)fe);
 }
开发者ID:EsriCanada,项目名称:TechTrek_Idol_2016,代码行数:7,代码来源:GPHelperFunctions.cs


示例7: CreatePointLayer

        /// <summary>
        /// �½���ͼ��
        /// </summary>
        public void CreatePointLayer()
        {
            SaveFileDialog sfdPoint = new SaveFileDialog();
            sfdPoint.Title = "��ѡ���ͼ��Ĵ洢λ��";
            sfdPoint.Filter = "Shapefile(*.shp)|*.shp|All files(*.*)|*.*";
            sfdPoint.RestoreDirectory = true;
            if (sfdPoint.ShowDialog() == DialogResult.OK)
            {
                LocalFilePath = sfdPoint.FileName;
                FilePath = System.IO.Path.GetDirectoryName(LocalFilePath);
                FileName = System.IO.Path.GetFileName(LocalFilePath);

                IFields pFields = new FieldsClass();
                IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
                IField pField = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = "SHAPE";
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;

                IGeometryDef pGeometryDef = new GeometryDefClass();
                IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;
                pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
                pFieldEdit.GeometryDef_2 = pGeometryDef;
                pFieldsEdit.AddField(pField);

                IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
                IFeatureWorkspace pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(FilePath, 0) as IFeatureWorkspace;
                pFeatureWorkspace.CreateFeatureClass(FileName, pFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
                m_mapControl.AddShapeFile(FilePath, FileName);
                m_mapControl.ActiveView.Refresh();
            }
        }
开发者ID:chinasio,项目名称:minegis,代码行数:35,代码来源:CreateLayer.cs


示例8: RunGPFieldMapping

        private static void RunGPFieldMapping()
        {
            // Initialize the Geoprocessor
            ESRI.ArcGIS.Geoprocessor.Geoprocessor GP = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            GP.OverwriteOutput = true;

            // Create the GPUtilites object
            IGPUtilities gputilities = new GPUtilitiesClass();

            // Create a DETable data element object 
            IDETable inputTableA = (IDETable)gputilities.MakeDataElement(@"C:\data\citiblocks.gdb\census", null, null);

            // Create an array of input tables
            IArray inputtables = new ArrayClass();
            inputtables.Add(inputTableA);

            // Initialize the GPFieldMapping
            IGPFieldMapping fieldmapping = new GPFieldMappingClass();
            fieldmapping.Initialize(inputtables, null);

            // Create a new output field
            IFieldEdit trackidfield = new FieldClass();
            trackidfield.Name_2 = "TRACTID";
            trackidfield.Type_2 = esriFieldType.esriFieldTypeString;
            trackidfield.Length_2 = 50;

            // Create a new FieldMap
            IGPFieldMap trackid = new GPFieldMapClass();
            trackid.OutputField = trackidfield;

            // Find field map "STFID" containing the input field "STFID". Add input field to the new field map.
            int fieldmap_index = fieldmapping.FindFieldMap("STFID");
            IGPFieldMap stfid_fieldmap = fieldmapping.GetFieldMap(fieldmap_index);
            int field_index = stfid_fieldmap.FindInputField(inputTableA, "STFID");
            IField inputField = stfid_fieldmap.GetField(field_index);
            trackid.AddInputField(inputTableA, inputField, 5, 10);

            // Add the new field map to the field mapping
            fieldmapping.AddFieldMap(trackid);

            // Execute Table to Table tool using the FieldMapping
            TableToTable tblTotbl = new TableToTable();
            tblTotbl.in_rows = inputTableA;
            tblTotbl.out_path = @"C:\data\citiblocks.gdb";
            tblTotbl.out_name = "census_out";
            tblTotbl.field_mapping = fieldmapping;

            object sev = null;
            try
            {
                GP.Execute(tblTotbl, null);
                System.Windows.Forms.MessageBox.Show(GP.GetMessages(ref sev));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                System.Windows.Forms.MessageBox.Show(GP.GetMessages(ref sev));
            }
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:59,代码来源:FieldMapping.cs


示例9: OnClick

        protected override void OnClick()
        {
            string tablePath = Path.Combine(DataPath, @"Geodatabase\ManhattanKS.gdb\ParcelIDs");
            string tableName = Path.GetFileName(tablePath);
            const string searchField = "PID";

            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
            IWorkspace workspace = workspaceFactory.OpenFromFile(Path.GetDirectoryName(tablePath), 0);

            IObjectClassDescription objClassDesc = new ObjectClassDescriptionClass();

            IFields fields = objClassDesc.RequiredFields;
            IFieldsEdit fieldsEdit = (IFieldsEdit) fields;

            IField field = new FieldClass();
            IFieldEdit fieldEdit = (IFieldEdit) field;

            fieldEdit.Name_2 = searchField;
            fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
            fieldEdit.IsNullable_2 = true;
            fieldEdit.AliasName_2 = searchField;
            fieldEdit.Editable_2 = true;
            fieldEdit.Length_2 = 250;

            fieldsEdit.AddField(field);
            fields = fieldsEdit;

            ITable table = CreateTable((IWorkspace2) workspace, tableName, fields);

            using (ComReleaser releaser = new ComReleaser())
            {
                ICursor cursor = table.Insert(true);
                releaser.ManageLifetime(cursor);

                string txtPath = Path.Combine(DataPath, "UniqueValues.txt");
                int searchFieldIndex = table.FindField(searchField);

                IRowBuffer buffer = table.CreateRowBuffer();

                using (StreamReader reader = new StreamReader(txtPath))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string id = line.Split(new[] {'.', ' '}, StringSplitOptions.RemoveEmptyEntries)[1];
                        buffer.Value[searchFieldIndex] = id;
                        cursor.InsertRow(buffer);
                    }

                    cursor.Flush();
                }
            }

            ((ITableCollection) ArcMap.Document.FocusMap).AddTable(table);
            ArcMap.Document.UpdateContents();
            Marshal.FinalReleaseComObject(table);
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:58,代码来源:ExecuteInsertCursor.cs


示例10: CreateIntField

 public static IField CreateIntField(string pFieldName, int pFieldLen)
 {
     FieldClass class2 = new FieldClass();
     IFieldEdit edit = class2;
     edit.Name_2 = pFieldName;
     edit.Precision_2 = pFieldLen;
     edit.Type_2 = esriFieldType.esriFieldTypeInteger;
     return class2;
 }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:9,代码来源:FieldHelper.cs


示例11: CreateFeatureClassOutput

        /// <summary>
        /// create feature class of output
        /// </summary>
        /// <param name="workspace">object workspace</param>
        /// <param name="spatialReference">spatial reference of feature class of output</param>
        /// <param name="nameFeatureClass">name of feature class</param>
        /// <returns>object feature class</returns>
        private static IFeatureClass CreateFeatureClassOutput(IWorkspace workspace, ISpatialReference spatialReference, string nameFeatureClass)
        {
            IFeatureClassDescription featureClassDescription = new FeatureClassDescriptionClass();
            IObjectClassDescription objectClassDescription = (IObjectClassDescription)featureClassDescription;

            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;

            // Create the fields collection.
            IFields fields = new FieldsClass();
            IFieldsEdit fieldsEdit = (IFieldsEdit)fields;

            IField oidField = new FieldClass();
            IFieldEdit oidFieldEdit = (IFieldEdit)oidField;
            oidFieldEdit.Name_2 = "OBJECTID";
            oidFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
            fieldsEdit.AddField(oidField);

            // Create the Shape field.
            IField shapeField = new Field();
            IFieldEdit shapeFieldEdit = (IFieldEdit)shapeField;

            // Set up the geometry definition for the Shape field.
            IGeometryDef geometryDef = new GeometryDefClass();
            IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
            geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;

            // By setting the grid size to 0, you're allowing ArcGIS to determine the appropriate grid sizes for the feature class.
            // If in a personal geodatabase, the grid size will be 1000. If in a file or ArcSDE geodatabase, the grid size
            // will be based on the initial loading or inserting of features.
            geometryDefEdit.HasM_2 = false;
            geometryDefEdit.HasZ_2 = false;

            geometryDefEdit.SpatialReference_2 = spatialReference;

            // Set standard field properties.
            shapeFieldEdit.Name_2 = featureClassDescription.ShapeFieldName;
            shapeFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            shapeFieldEdit.GeometryDef_2 = geometryDef;
            shapeFieldEdit.IsNullable_2 = true;
            shapeFieldEdit.Required_2 = true;
            fieldsEdit.AddField(shapeField);

            IField idField = new FieldClass();
            IFieldEdit idIsolaFieldEdit = (IFieldEdit)idField;
            idIsolaFieldEdit.Name_2 = Program.nameFieldIdOutput;
            idIsolaFieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger;
            fieldsEdit.AddField(idField);

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

            return featureWorkspace.CreateFeatureClass(nameFeatureClass, fields, objectClassDescription.InstanceCLSID, objectClassDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, featureClassDescription.ShapeFieldName, string.Empty);
        }
开发者ID:nicogis,项目名称:Voronoi,代码行数:64,代码来源:Program.cs


示例12: CreateDoubleField

 // Methods
 public static IField CreateDoubleField(string pFieldName, int pFieldLen, int pFieldScale)
 {
     FieldClass class2 = new FieldClass();
     IFieldEdit edit = class2;
     edit.Name_2 = pFieldName;
     edit.Type_2 = esriFieldType.esriFieldTypeDouble;
     edit.Precision_2 = pFieldLen;
     edit.Scale_2 = pFieldScale;
     return class2;
 }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:11,代码来源:FieldHelper.cs


示例13: AddField

 public  void AddField(IFeatureClass pFeatureClass,string fieldName,esriFieldType fieldType)
 {
     //如果存在不必添加字段,直接返回
     if (pFeatureClass.FieldExistCheck(fieldName)) return;
     var pField = new FieldClass();
     var pFieldEdit = (IFieldEdit)pField;
     pFieldEdit.Name_2 = fieldName;
     pFieldEdit.Type_2 = fieldType;  
     pFeatureClass.AddField(pFieldEdit);
 }
开发者ID:gaufung,项目名称:Accessibility,代码行数:10,代码来源:ShapeOp.cs


示例14: CreatePolygonFile

        public IFeatureClass CreatePolygonFile(String strFolder, String filename, IEnvelope pEnvBorder, ISpatialReference pSR)
        {
            // Open the folder to contain the shapefile as a workspace
            IWorkspaceFactory pWF = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace pfws = (IFeatureWorkspace)pWF.OpenFromFile(strFolder, 0);

            //Set up a simple fields collection
            IField pField = new FieldClass();
            IFieldEdit pFieldEdit = (IFieldEdit)pField;
            IFields pFields = new FieldsClass();
            IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;

            // Make the shape field
            //it will need a geometry definition, with a spatial reference

            pFieldEdit.Name_2 = "Shape";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;

            IGeometryDef pGeomDef = new GeometryDef();
            IGeometryDefEdit pGeomDefEdit = (IGeometryDefEdit)pGeomDef;

            pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            pGeomDefEdit.SpatialReference_2 = pSR;

            pFieldEdit.GeometryDef_2 = pGeomDef;
            pFieldsEdit.AddField(pField);

            // Add ID field
            IField pFieldOID = new Field();
            pFieldEdit = (IFieldEdit)pFieldOID;
            pFieldEdit.Name_2 = "OBJECTID";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
            pFieldEdit.IsNullable_2 = false;

            pFieldsEdit.AddField(pFieldOID);

            //EulerPoleReFrmgwn eulerfrm=new EulerPoleReFrmgwn();

            if (File.Exists(strFolder + filename + ".shp") == true)
            {
                DialogResult result = MessageBox.Show("There is a shapefile have the same name in this foler, do you want to overwrite it?", "", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    File.Delete(strFolder + filename);

                }
                else
                {
                    return null;
                }
            }

            IFeatureClass pFeatclass = pfws.CreateFeatureClass(filename, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
            return pFeatclass;
        }
开发者ID:afocusman,项目名称:PRSS_programYM,代码行数:55,代码来源:CCCreatePolygonFile.cs


示例15: AddField

        //添加字段并赋值
        private void AddField()
        {
            //添加温度字段
            string HighTemp = "HighTemperature";
            string LowTemp = "LowTemperature";
            IFeatureLayer lyrProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IFeatureLayer;
            IFeatureClass ProClass = lyrProVince.FeatureClass; ;
            if (ProClass.Fields.FindField(HighTemp) < 0)
            {
                IField pField = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = HighTemp;
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                IClass pClass = ProClass as IClass;
                pClass.AddField(pFieldEdit);
            }
            if (ProClass.Fields.FindField(LowTemp) < 0)
            {
                IField pField = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = LowTemp;
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                IClass pClass = ProClass as IClass;
                pClass.AddField(pFieldEdit);

            }
            //为字段赋值
            string[] provinces = new string[] { "黑龙江省", "内蒙古自治区", "新疆维吾尔自治区", "吉林省", "甘肃省", "河北省", "北京市", "山西省", "天津市", "陕西省", "宁夏回族自治区", "青海省", "辽宁省", "山东省", "西藏自治区", "河南省", "江苏省", "安徽省", "四川省", "湖北省", "重庆市", "上海市", "浙江省", "湖南省", "江西省", "云南省", "贵州省", "广西壮族自治区", "福建省", "台湾省", "海南省", "广东省", "香港特别行政区", "澳门" };
            TomorrowWeatherInfo weath;

            IFeatureCursor featCursor = null;
            IQueryFilter queryFilter = new QueryFilterClass();
            for (int i = 0; i < provinces.Length; i++)
            {
                string selCity = provinces[i];
                string whereClause = "[NAME] = '" + selCity + "'";
                queryFilter.WhereClause = whereClause;
                featCursor = ProClass.Search(queryFilter, false);
                IFeature pFeature = featCursor.NextFeature();
                string pcity = Utilities.getCity(selCity);
                weath = new TomorrowWeatherInfo(pcity);

                Random random=new Random();//测试用随机数产生器
                if (pFeature != null)
                {
                    pFeature.set_Value(pFeature.Fields.FindField("HighTemperature"), random.Next(20,40));
                    pFeature.set_Value(pFeature.Fields.FindField("LowTemperature"), random.Next(1,20));
                    pFeature.Store();
                }
            }
            IGeoFeatureLayer geoProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IGeoFeatureLayer;
            setColor(geoProVince);
        }
开发者ID:cwtok123,项目名称:ArcEngine,代码行数:54,代码来源:Form1.cs


示例16: CreateField

        public static IField CreateField(FieldInfo fInfo)
        {
            IFieldEdit normalField = new FieldClass();
            normalField.Name_2 = fInfo.Name;
            normalField.AliasName_2 = fInfo.AliasName;
            normalField.Type_2 = (esriFieldType)fInfo.Type;

            normalField.IsNullable_2 = fInfo.NullAble;
            normalField.Length_2 = fInfo.Length;
            normalField.Precision_2 = fInfo.Precision;

            return normalField;
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:13,代码来源:StandardHelper.cs


示例17: addAttributeField

        /// <summary> 
        /// ��ӵ�ͼ�����ֶ� 
        /// </summary> 
        /// <param name="name">����</param> 
        /// <param name="aliasName">����</param> 
        /// <param name="type">����</param> 
        /// <param name="length">����</param> 
        /// <param name="defaultValue">Ĭ��ֵ</param> 
        /// <param name="editAble">�Ƿ���Ա༭</param> 
        public static void addAttributeField(string name, string aliasName,string type, int length, string defaultValue, bool editAble,IMap pMap)
        {
            try
            {
                //����
                IFieldEdit pMyField;
                pMyField = new FieldClass();
                pMyField.Name_2 = name;
                pMyField.AliasName_2 = aliasName;
                pMyField.Length_2 =length;
                if (type == "Date")
                    pMyField.Type_2 = esriFieldType.esriFieldTypeDate;
                else if (type == "Integer")
                    pMyField.Type_2 = esriFieldType.esriFieldTypeInteger;
                else if (type == "Single")
                    pMyField.Type_2 = esriFieldType.esriFieldTypeSingle;
                else if (type == "Double")
                    pMyField.Type_2 = esriFieldType.esriFieldTypeDouble;
                else if (type == "String")
                    pMyField.Type_2 = esriFieldType.esriFieldTypeString;

                if (defaultValue.Equals(""))
                { }
                else
                {
                    pMyField.IsNullable_2 = false;
                    if (type == "Date")
                        pMyField.DefaultValue_2 =DateTime.Parse(defaultValue);
                    else if (type == "Integer")
                        pMyField.DefaultValue_2 =int.Parse(defaultValue);
                    else if (type == "Single")
                        pMyField.DefaultValue_2 =float.Parse(defaultValue);
                    else if (type == "Double")
                        pMyField.DefaultValue_2 =double.Parse(defaultValue);
                    else if (type == "String")
                        pMyField.DefaultValue_2 = defaultValue;
                }
                pMyField.Editable_2 = editAble;
                ITable pTable = (ITable)pMap.get_Layer(GetLayerIdByName(globalInfo.currentLayerName,pMap));
                pTable.AddField(pMyField);
                MessageBox.Show("����ֶ�" + name+ "�ɹ�");
            }
            catch (Exception ex)
            {
                MessageBox.Show("���ʧ�ܣ�" + ex.Message);
            }
        }
开发者ID:lovelll,项目名称:DQHP,代码行数:56,代码来源:FieldOperate.cs


示例18: CreateShapeField

        public static IField CreateShapeField(FeatureClassInfo fcInfo)
        {
            IFieldEdit shpField = new FieldClass();
            shpField.Name_2=string.IsNullOrWhiteSpace(fcInfo.ShapeFieldName)?"Shape":fcInfo.ShapeFieldName;
            shpField.Type_2 = esriFieldType.esriFieldTypeGeometry;
            IGeometryDefEdit geoDef=new GeometryDefClass();
            geoDef.AvgNumPoints_2 = fcInfo.AvgNumPoints;
            geoDef.GeometryType_2=fcInfo.ShapeType;
            geoDef.GridCount_2=fcInfo.GridCount;
            geoDef.HasM_2 = fcInfo.HasM;
            geoDef.HasZ_2 = fcInfo.HasZ;
            geoDef.SpatialReference_2 = fcInfo.SpatialReference;

            shpField.GeometryDef_2=geoDef;

            return shpField;
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:17,代码来源:StandardHelper.cs


示例19: CreatePolygonLayer

        /// <summary>
        /// �½���ͼ��
        /// </summary>
        public IFeatureClass CreatePolygonLayer(IPolygon polygon)
        {
            //LocalFilePath = sfdPoint.FileName;
               FilePath = Application.StartupPath + "\\tempSHP";
               FileName = "test";

               IFields pFields = new FieldsClass();
               IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
               IField pField = new FieldClass();
               IFieldEdit pFieldEdit = pField as IFieldEdit;
               pFieldEdit.Name_2 = "SHAPE";
               pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;

               IGeometryDef pGeometryDef = new GeometryDefClass();
               IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;
               pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
               pFieldEdit.GeometryDef_2 = pGeometryDef;
               pFieldsEdit.AddField(pField);

               pField = new FieldClass();
               pFieldEdit = pField as IFieldEdit;
               pFieldEdit.Name_2 = "HEIGHT";
               pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
               pFieldsEdit.AddField(pField);

               IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
               IFeatureWorkspace pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(FilePath, 0) as IFeatureWorkspace;
               IFeatureClass feaC = pFeatureWorkspace.CreateFeatureClass(FileName, pFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
               IFeature pFeature = feaC.CreateFeature();
               pFeature.Shape = polygon as IGeometry;
               pFeature.Store();

               IFeatureCursor feaCur = feaC.Search(null, true);
               pFeature = feaCur.NextFeature();
               while (pFeature != null)
               {
               //pFeature.set_Value(2, "181");
               pFeature.Store();
               pFeature = feaCur.NextFeature();
               }

               //m_mapControl.AddShapeFile(FilePath, FileName);
               //m_mapControl.ActiveView.Refresh();
               return feaC;
        }
开发者ID:chinasio,项目名称:minegis,代码行数:48,代码来源:CreateLayerM.cs


示例20: CreateGeometryField

        public static IField CreateGeometryField(esriGeometryType pGT, ISpatialReference pSR, bool pHasZ)
        {
            FieldClass class2 = new FieldClass();
            IFieldEdit edit = class2;
            edit.Name_2 = "SHAPE";
            edit.AliasName_2 = "图形对象";
            edit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            IGeometryDef pGeoDef = new GeometryDefClass();
            IGeometryDefEdit class3 = (IGeometryDefEdit)pGeoDef;

            class3.GeometryType_2 = pGT;
            class3.HasM_2 = false;
            class3.HasZ_2 = pHasZ;
            class3.GridCount_2 = 1;
            class3.set_GridSize(0, 1000.0);
            class3.SpatialReference_2 = pSR;
            edit.GeometryDef_2 = class3;
            return class2;
        }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:19,代码来源:FieldHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FieldCollection类代码示例发布时间:2022-05-24
下一篇:
C# FieldAttributes类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap