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


C# ESRI.get_Field方法代码示例

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


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

示例1: CreatePointFeatureClass


//.........这里部分代码省略.........
                IFieldEdit osmuidField = new FieldClass() as IFieldEdit;
                osmuidField.Name_2 = "osmuid";
                osmuidField.Type_2 = esriFieldType.esriFieldTypeInteger;
                fieldsEdit.AddField((IField)osmuidField);

                IFieldEdit osmvisibleField = new FieldClass() as IFieldEdit;
                osmvisibleField.Name_2 = "osmvisible";
                osmvisibleField.Type_2 = esriFieldType.esriFieldTypeString;
                osmvisibleField.Length_2 = 20;
                fieldsEdit.AddField((IField)osmvisibleField);

                IFieldEdit osmversionField = new FieldClass() as IFieldEdit;
                osmversionField.Name_2 = "osmversion";
                osmversionField.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
                fieldsEdit.AddField((IField)osmversionField);

                IFieldEdit osmchangesetField = new FieldClass() as IFieldEdit;
                osmchangesetField.Name_2 = "osmchangeset";
                osmchangesetField.Type_2 = esriFieldType.esriFieldTypeInteger;
                fieldsEdit.AddField((IField)osmchangesetField);

                IFieldEdit osmtimestampField = new FieldClass() as IFieldEdit;
                osmtimestampField.Name_2 = "osmtimestamp";
                osmtimestampField.Type_2 = esriFieldType.esriFieldTypeDate;
                fieldsEdit.AddField((IField)osmtimestampField);

                IFieldEdit osmrelationIDField = new FieldClass() as IFieldEdit;
                osmrelationIDField.Name_2 = "osmMemberOf";
                    osmrelationIDField.Type_2 = esriFieldType.esriFieldTypeBlob;
                fieldsEdit.AddField((IField)osmrelationIDField);

                IFieldEdit hasOSMTagsField = new FieldClass() as IFieldEdit;
                hasOSMTagsField.Name_2 = "hasOSMTags";

                IFieldEdit osmSupportingElementField = new FieldClass() as IFieldEdit;
                osmSupportingElementField.Name_2 = "osmSupportingElement";
                osmSupportingElementField.Type_2 = esriFieldType.esriFieldTypeString;
                osmSupportingElementField.Length_2 = 5;
                fieldsEdit.AddField((IField) osmSupportingElementField);

                IFieldEdit wayRefCountField = new FieldClass() as IFieldEdit;
                wayRefCountField.Name_2 = "wayRefCount";
                wayRefCountField.Type_2 = esriFieldType.esriFieldTypeInteger;
                wayRefCountField.DefaultValue_2 = 0;
                fieldsEdit.AddField((IField)wayRefCountField);

                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.esriGeometryPoint;
                    geometryDef.HasZ_2 = false;
                    geometryDef.HasM_2 = false;
                    geometryDef.GridCount_2 = 1;
                    geometryDef.set_GridSize(0, 1);

                    ISpatialReferenceFactory spatialRefFactory = new SpatialReferenceEnvironmentClass();
                    ISpatialReference wgs84 = spatialRefFactory.CreateGeographicCoordinateSystem((int) esriSRGeoCSType.esriSRGeoCS_WGS1984) as ISpatialReference;
                    geometryDef.SpatialReference_2 = wgs84;

                    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
                try
                {
                    featureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, CLSID, null, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, strShapeField, "");
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }

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

示例2: CreateFeatureClass

        public bool CreateFeatureClass(ESRI.ArcGIS.Geodatabase.IWorkspace OutputWorkspace, string OutputFeatureClassName, ESRI.ArcGIS.Geodatabase.IFields OutputFeatureClassFields, ESRI.ArcGIS.Geodatabase.esriFeatureType OutputFeatureType)
        {
            ESRI.ArcGIS.Geodatabase.IFeatureWorkspace outputFeatureWorkspace = null;
              ESRI.ArcGIS.Geodatabase.IFeatureClass     newFeatureClass        = null;

              try
              {
            //  QI to the Output Feature Workspace.
            outputFeatureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)OutputWorkspace;

            //  Determine the Name of the Shape Field in the Output Fields Collection.
            string shapeFieldName = null;
            for (int i = 0; i < OutputFeatureClassFields.FieldCount; i++)
            {
              //  Grab the Current Field.
              if (OutputFeatureClassFields.get_Field(i).Type == ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry)
              {
            //  Set the name of the current Field to be the "Shape Field Name".
            shapeFieldName = OutputFeatureClassFields.get_Field(i).Name;
              }

            }

            //  If the Shape Field was not found, abort the process.
            if (System.String.IsNullOrEmpty(shapeFieldName))
            {
              //  Let the User know that this method failed.
              if (ErrorMessage != null)
              {
            ErrorMessage("The Output Fields Collection does not include a Shape Field. Aborting the MaintTools.FeatureClassUtilities.CreateFeatureClass() Method!");
              }

              //  Return FALSE to the calling Method to indicate that this Method failed.
              return false;

            }

            //  Attempt to Build the Feature Class.
            newFeatureClass = outputFeatureWorkspace.CreateFeatureClass(OutputFeatureClassName, OutputFeatureClassFields, null, null, OutputFeatureType, shapeFieldName, "");

            //  Make sure the Feature Class was created successfully.
            if (newFeatureClass != null)
            {
              //  The Feature Class was created successfully so return TRUE to the calling method.
              return true;

            }
            else
            {
              //  The Feature Class was not created successfully so retrun FALSE to the calling method.
              return false;

            }

              }
              catch (System.Runtime.InteropServices.COMException comException)
              {
            //  Determine the Line Number from which the exception was thrown.
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(comException, true);
            System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1);
            int lineNumber = stackFrame.GetFileLineNumber();

            //  Let the User know that this method failed.
            if (ErrorMessage != null)
            {
              ErrorMessage("The MaintTools.FeatureClassUtilities.CreateFeatureClass() Method failed while opening the Feature Class in the Geodatabase Workspace with COM Exception - " + comException.Message + " (" + comException.ErrorCode + " Line:  " + lineNumber.ToString() + ")!");
            }

            //  Return FALSE to the calling method to indicate that this methdo failed.
            return false;

              }
              catch (System.Exception caught)
              {
            //  Determine the Line Number from which the exception was thrown.
            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(caught, true);
            System.Diagnostics.StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1);
            int lineNumber = stackFrame.GetFileLineNumber();

            //  Let the User know that this method failed.
            if (ErrorMessage != null)
            {
              ErrorMessage("The MaintTools.FeatureClassUtilities.CreateFeatureClass() Method failed with error message - " + caught.Message + " (Line:  " + lineNumber.ToString() + ")!");
            }

            //  Return FALSE to the calling Method to indicate that this Method failed.
            return false;

              }
              finally
              {
            //  If the Output ESRI Geodatabase Feature Workspace Object was instantiated, close it.
            if (outputFeatureWorkspace != null)
            {
              outputFeatureWorkspace = null;
            }

              }
        }
开发者ID:MitchVan,项目名称:DataMaintenanceUtilities,代码行数:99,代码来源:FeatureClassUtilities.cs

示例3: 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
开发者ID:hallahan,项目名称:arcgis-osm-editor,代码行数:67,代码来源:OSMToolHelper.cs


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