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


C# FieldsClass.AddField方法代码示例

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


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

示例1: CreatePolylineFeatureClass

        /// <summary> 
        /// Create the polyline feature class 
        /// </summary> 
        /// <param name="featWorkspace">IFeatureWorkspace</param> 
        /// <param name="name">Name of the featureclass</param> 
        /// <returns>IFeatureClass</returns> 
        private IFeatureClass CreatePolylineFeatureClass(IFeatureWorkspace featWorkspace, string name)
        {
            IFieldsEdit pFldsEdt = new FieldsClass();
            IFieldEdit pFldEdt = new FieldClass();

            pFldEdt = new FieldClass();
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeOID;
            pFldEdt.Name_2 = "OBJECTID";
            pFldEdt.AliasName_2 = "OBJECTID";
            pFldsEdt.AddField(pFldEdt);

            IGeometryDefEdit pGeoDef;
            pGeoDef = new GeometryDefClass();
            pGeoDef.GeometryType_2 = esriGeometryType.esriGeometryPolyline;
            pGeoDef.SpatialReference_2 = ArcMap.Document.FocusMap.SpatialReference;

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "SHAPE";
            pFldEdt.AliasName_2 = "SHAPE";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeGeometry;
            pFldEdt.GeometryDef_2 = pGeoDef;
            pFldsEdt.AddField(pFldEdt);

            IFeatureClass pFClass = featWorkspace.CreateFeatureClass(name, pFldsEdt, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");

            return pFClass;
        }
开发者ID:Esri,项目名称:distance-direction-addin-dotnet,代码行数:33,代码来源:FeatureClassUtils.cs

示例2: 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

示例3: CreateFields

        public static IFields CreateFields(TableInfo tInfo)
        {
            if (tInfo == null || tInfo.FieldsInfo == null || tInfo.FieldsInfo.Count == 0)
                return null;

            IFieldsEdit fields=new FieldsClass();
            foreach (FieldInfo fInfo in tInfo.FieldsInfo)
            {
                fields.AddField(CreateField(fInfo));
            }
            return fields;
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:12,代码来源:StandardHelper.cs

示例4: UpdateParameters

        public void UpdateParameters(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr)
        {
            IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

            IGPParameter targetDatasetParameter = paramvalues.get_Element(out_targetDatasetNumber) as IGPParameter;
            IGPValue targetDatasetGPValue = gpUtilities3.UnpackGPValue(targetDatasetParameter);

            IDEFeatureDataset targetDEFeatureDataset = targetDatasetGPValue as IDEFeatureDataset;

            IGPParameter3 outPointsFeatureClassParameter = null;
            IGPValue outPointsFeatureClass = null;
            string outpointsPath = String.Empty;

            IGPParameter3 outLinesFeatureClassParameter = null;
            IGPValue outLinesFeatureClass = null;
            string outlinesPath = String.Empty;

            IGPParameter3 outPolygonFeatureClassParameter = null;
            IGPValue outPolygonFeatureClass = null;
            string outpolygonsPath = String.Empty;

            if (((IGPValue)targetDEFeatureDataset).GetAsText().Length != 0)
            {
                IDataElement dataElement = targetDEFeatureDataset as IDataElement;
                try
                {
                    gpUtilities3.QualifyOutputDataElement(gpUtilities3.UnpackGPValue(targetDatasetParameter));
                }
                catch
                {
                    return;
                }

                string nameOfPointFeatureClass = dataElement.GetBaseName() + "_osm_pt";
                string nameOfLineFeatureClass = dataElement.GetBaseName() + "_osm_ln";
                string nameOfPolygonFeatureClass = dataElement.GetBaseName() + "_osm_ply";


                try
                {
                    outpointsPath = dataElement.CatalogPath + System.IO.Path.DirectorySeparatorChar + nameOfPointFeatureClass;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
                outPointsFeatureClassParameter = paramvalues.get_Element(out_osmPointsNumber) as IGPParameter3;
                outPointsFeatureClass = gpUtilities3.UnpackGPValue(outPointsFeatureClassParameter);

                outlinesPath = dataElement.CatalogPath + System.IO.Path.DirectorySeparatorChar + nameOfLineFeatureClass;
                outLinesFeatureClassParameter = paramvalues.get_Element(out_osmLinesNumber) as IGPParameter3;
                outLinesFeatureClass = gpUtilities3.UnpackGPValue(outLinesFeatureClassParameter);

                outpolygonsPath = dataElement.CatalogPath + System.IO.Path.DirectorySeparatorChar + nameOfPolygonFeatureClass;
                outPolygonFeatureClassParameter = paramvalues.get_Element(out_osmPolygonsNumber) as IGPParameter3;
                outPolygonFeatureClass = gpUtilities3.UnpackGPValue(outPolygonFeatureClassParameter);
            }


            // TE - 10/20/2014
            if (((IGPParameter)paramvalues.get_Element(in_attributeSelector)).Altered)
            {
                IGPParameter tagCollectionParameter = paramvalues.get_Element(in_attributeSelector) as IGPParameter;
                IGPMultiValue tagCollectionGPValue = gpUtilities3.UnpackGPValue(tagCollectionParameter) as IGPMultiValue;

                IGPCodedValueDomain codedTagDomain = tagCollectionParameter.Domain as IGPCodedValueDomain;

                for (int attributeValueIndex = 0; attributeValueIndex < tagCollectionGPValue.Count; attributeValueIndex++)
                {
                    string valueString = tagCollectionGPValue.get_Value(attributeValueIndex).GetAsText();
                    IGPValue testFieldValue = codedTagDomain.FindValue(valueString);

                    if (testFieldValue == null)
                    {
                        codedTagDomain.AddStringCode(valueString, valueString);
                    }
                }

                string illegalCharacters = "`[email protected]#$%^&()-+=,{}.![];";
                IFieldsEdit fieldsEdit = new FieldsClass();

                for (int valueIndex = 0; valueIndex < tagCollectionGPValue.Count; valueIndex++)
                {
                    string tagString = tagCollectionGPValue.get_Value(valueIndex).GetAsText();

                    if (tagString != "ALL")
                    {
                        // Check if the input field already exists.
                        string cleanedTagKey = OSMToolHelper.convert2AttributeFieldName(tagString, illegalCharacters);

                        IFieldEdit fieldEdit = new FieldClass();
                        fieldEdit.Name_2 = cleanedTagKey;
                        fieldEdit.AliasName_2 = tagCollectionGPValue.get_Value(valueIndex).GetAsText();
                        fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                        fieldEdit.Length_2 = 100;
                        fieldsEdit.AddField(fieldEdit);
                    }
                }
                IFields fields = fieldsEdit as IFields;

//.........这里部分代码省略.........
开发者ID:leijiancd,项目名称:arcgis-osm-editor,代码行数:101,代码来源:OSMGPFileLoader.cs

示例5: UpdateParameters

        public void UpdateParameters(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager pEnvMgr)
        {
            try
            {
                IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

                IGPValue inputOSMGPValue = gpUtilities3.UnpackGPValue(paramvalues.get_Element(in_osmFeatureClass));

                IFeatureClass osmFeatureClass = null;
                ITable osmInputTable = null;
                IQueryFilter osmQueryFilter = null;

                try
                {
                    gpUtilities3.DecodeFeatureLayer(inputOSMGPValue, out osmFeatureClass, out osmQueryFilter);
                    osmInputTable = osmFeatureClass as ITable;
                }
                catch { }

                try
                {
                    if (osmInputTable == null)
                    {
                        gpUtilities3.DecodeTableView(inputOSMGPValue, out osmInputTable, out osmQueryFilter);
                    }
                }
                catch { }

                if (osmInputTable == null)
                {
                    return;
                }

                String illegalCharacters = String.Empty;

                ISQLSyntax sqlSyntax = ((IDataset)osmInputTable).Workspace as ISQLSyntax;
                if (sqlSyntax != null)
                {
                    illegalCharacters = sqlSyntax.GetInvalidCharacters();
                }

                // find the field that holds tag binary/xml field
                int osmTagCollectionFieldIndex = osmInputTable.FindField("osmTags");

                // if the Field doesn't exist - wasn't found (index = -1) get out
                if (osmTagCollectionFieldIndex == -1)
                {
                    return;
                }

                if (((IGPParameter)paramvalues.get_Element(in_attributeSelector)).Altered)
                {
                    IGPParameter tagCollectionParameter = paramvalues.get_Element(in_attributeSelector) as IGPParameter;
                    IGPMultiValue tagCollectionGPValue = gpUtilities3.UnpackGPValue(tagCollectionParameter) as IGPMultiValue;

                    IGPCodedValueDomain codedTagDomain = tagCollectionParameter.Domain as IGPCodedValueDomain;

                    for (int attributeValueIndex = 0; attributeValueIndex < tagCollectionGPValue.Count; attributeValueIndex++)
                    {
                        string valueString = tagCollectionGPValue.get_Value(attributeValueIndex).GetAsText();
                        IGPValue testFieldValue = codedTagDomain.FindValue(valueString);

                        if (testFieldValue == null)
                        {
                            codedTagDomain.AddStringCode(valueString, valueString);
                        }
                    }

                    // Get the derived output feature class schema and empty the additional fields. This ensures
                    // that you don't get dublicate entries.
                    // Derived output is the third parameter, so use index 2 for get_Element.
                    IGPParameter3 derivedFeatures = (IGPParameter3)paramvalues.get_Element(out_osmFeatureClass);
                    IGPFeatureSchema schema = (IGPFeatureSchema)derivedFeatures.Schema;
                    schema.AdditionalFields = null;

                    IFieldsEdit fieldsEdit = new FieldsClass();

                    for (int valueIndex = 0; valueIndex < tagCollectionGPValue.Count; valueIndex++)
                    {
                        string tagString = tagCollectionGPValue.get_Value(valueIndex).GetAsText();

                        if (tagString != "ALL")
                        {
                            // Check if the input field already exists.
                            string cleanedTagKey = convert2AttributeFieldName(tagString, illegalCharacters);
                            IField tagField = gpUtilities3.FindField(inputOSMGPValue, cleanedTagKey);
                            if (tagField == null)
                            {
                                IFieldEdit fieldEdit = new FieldClass();
                                fieldEdit.Name_2 = cleanedTagKey;
                                fieldEdit.AliasName_2 = tagCollectionGPValue.get_Value(valueIndex).GetAsText();
                                fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                                fieldEdit.Length_2 = 100;
                                fieldsEdit.AddField(fieldEdit);
                            }
                        }
                    }

                    // Add the additional field to the derived output.
                    IFields fields = fieldsEdit as IFields;
//.........这里部分代码省略.........
开发者ID:hallahan,项目名称:arcgis-osm-editor,代码行数:101,代码来源:OSMGPAttributeSelector.cs

示例6: CopyAndLabel

        static void CopyAndLabel(IFeatureClass inFC, IFeatureWorkspace destination, String name)
        {
            IFieldsEdit outFields = new FieldsClass();
            ISpatialReference outSR = null;
            for (int i = 0; i < inFC.Fields.FieldCount; i += 1) {
                IField field = inFC.Fields.get_Field(i);
                if (field.Type == esriFieldType.esriFieldTypeGeometry) {
                    outSR = field.GeometryDef.SpatialReference;
                } else {
                    outFields.AddField(field);
                }
            }
            outSR.SetMDomain(-137434824702, 137434824702);

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

            IFieldEdit geomField = new FieldClass();
            geomField.Name_2 = "SHAPE";
            geomField.AliasName_2 = "SHAPE";
            geomField.Type_2 = esriFieldType.esriFieldTypeGeometry;
            geomField.GeometryDef_2 = geom;
            outFields.AddField(geomField);

            IFeatureClass outFC = destination.CreateFeatureClass(name, outFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
            // Start numbering from 1, because index 0 is used by clipping cell
            int vIndex = 1;
            IFeatureCursor featureCursor = inFC.Search(null, true);
            IFeature inFeature;
            while ((inFeature = featureCursor.NextFeature()) != null) {
                IFeature outFeature = outFC.CreateFeature();
                for (int i = 0; i < outFields.FieldCount; i += 1) {
                    IField field = outFields.Field[i];
                    if (field.Editable && (field.Type != esriFieldType.esriFieldTypeGeometry)) {
                        outFeature.set_Value(i, inFeature.get_Value(i));
                    }
                }
                IPolygon4 inShape = inFeature.Shape as IPolygon4;
                PolygonClass outShape = new PolygonClass();

                IGeometryBag extRingBag = inShape.ExteriorRingBag;
                IGeometryCollection extRings = extRingBag as IGeometryCollection;
                for (int i = 0; i < extRings.GeometryCount; i += 1) {
                    IGeometry inExtRingGeom = extRings.get_Geometry(i);
                    IPointCollection inExtRing = inExtRingGeom as IPointCollection;
                    RingClass outExtRing = new RingClass();
                    for (int j = 0; j < inExtRing.PointCount; j += 1) {
                        IPoint point = inExtRing.get_Point(j);
                        point.M = vIndex;
                        vIndex += 2;
                        outExtRing.AddPoint(point);
                    }
                    outShape.AddGeometry(outExtRing);
                    IGeometryBag intRingBag = inShape.get_InteriorRingBag(inExtRingGeom as IRing);
                    IGeometryCollection intRings = intRingBag as IGeometryCollection;
                    for (int j = 0; j < intRings.GeometryCount; j += 1) {
                        IGeometry intRingGeom = intRings.get_Geometry(j);
                        IPointCollection inIntRing = intRingGeom as IPointCollection;
                        RingClass outIntRing = new RingClass();
                        for (int k = 0; k < inIntRing.PointCount; k += 1) {
                            IPoint point = inExtRing.get_Point(k);
                            point.M = vIndex;
                            vIndex += 2;
                            outIntRing.AddPoint(point);
                        }
                        outShape.AddGeometry(outIntRing);
                    }
                }
                outFeature.Shape = outShape;
                outFeature.Store();
            }
        }
开发者ID:NGFieldScope,项目名称:Geoprocessing,代码行数:75,代码来源:Program.cs

示例7: CreateArcTable

    private ITable CreateArcTable(DataTable dt, bool regionIsInt)
    {
        IWorkspaceFactory workspaceFactory = new InMemoryWorkspaceFactoryClass();
        IWorkspaceName workspaceName = workspaceFactory.Create("", "MyWorkspace",
        null, 0);

        IName name = (IName)workspaceName;
        IFeatureWorkspace workspace = (IFeatureWorkspace)name.Open();
        IFieldsEdit fe;

        fe = new FieldsClass();
        IField oid, key, measure;
        oid = createField("ObjectId", esriFieldType.esriFieldTypeOID);
        if (regionIsInt)
        {
            key = createField("Region", esriFieldType.esriFieldTypeInteger);
        }
        else
        {
            key = createField("Region", esriFieldType.esriFieldTypeString);
        }

        measure = createField("Measure", esriFieldType.esriFieldTypeDouble);
        fe.AddField(oid);
        fe.AddField(key);
        fe.AddField(measure);

        UID clsid = new UIDClass();
        clsid.Value = "esriGeoDatabase.Object";
        ITable table = workspace.CreateTable("joinedTable", (IFields)fe, clsid, null, null);

        IRowBuffer rowBuffer = table.CreateRowBuffer();
        ICursor cursor = table.Insert(true);

        foreach (DataRow dr in dt.Rows)
        {
            /*Set the Region and the Measure fields
             The dataTable has 2 columns and the ArcTable has 3 columns.
             The first column in the OID field which is generated internally
             by the ArcGIS engine.*/
            for (int x = 1; x <= dt.Columns.Count; x++)
            {
                rowBuffer.set_Value(x, dr[x-1]);
            }
            cursor.InsertRow(rowBuffer);
        }

        cursor.Flush();

        return table;
    }
开发者ID:mateo41,项目名称:mapmaker,代码行数:51,代码来源:QueryTable.cs

示例8: CreateFields

        /// <summary>
        /// This initialises all of the different fields that are required for the locator to function
        /// It contains declarations for the Match and Candidate fields for the locator
        /// </summary>
        protected override void CreateFields()
        {
            IFieldsEdit fieldsEdit = new FieldsClass();
            IFieldEdit shapeField = new FieldClass();
            IFieldEdit statusField = new FieldClass();
            IFieldEdit scoreField = new FieldClass();
            IFieldEdit xField = new FieldClass();
            IFieldEdit yField = new FieldClass();
            IFieldEdit matchField = new FieldClass();

            m_spatialReference = new SpatialReferenceEnvironmentClass().CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_BritishNationalGrid);
            SearchDistanceUnits = esriUnits.esriMeters;
            // Set up the spatial Reference and Geometry Definition
            IGeometryDefEdit geometryDefEdit = new GeometryDefClass();
            geometryDefEdit.SpatialReference_2 = m_spatialReference;
            geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;

            // Create the matchFields
            shapeField.Name_2 = "Shape";
            shapeField.Type_2 = esriFieldType.esriFieldTypeGeometry;
            shapeField.GeometryDef_2 = geometryDefEdit as IGeometryDef;
            fieldsEdit.AddField(shapeField);

            statusField.Name_2 = "Status";
            statusField.Type_2 = esriFieldType.esriFieldTypeString;
            statusField.Length_2 = 1;
            fieldsEdit.AddField(statusField);

            scoreField.Name_2 = "Score";
            scoreField.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
            fieldsEdit.AddField(scoreField);

            matchField.Name_2 = "Match_addr";
            matchField.Type_2 = esriFieldType.esriFieldTypeString;
            matchField.Length_2 = 50;
            fieldsEdit.AddField(matchField);

            xField.Name_2 = "X";
            xField.Type_2 = esriFieldType.esriFieldTypeDouble;
            xField.Length_2 = 16;
            xField.Precision_2 = 10;
            fieldsEdit.AddField(xField);

            yField.Name_2 = "Y";
            yField.Type_2 = esriFieldType.esriFieldTypeDouble;
            yField.Length_2 = 16;
            yField.Precision_2 = 10;
            fieldsEdit.AddField(yField);

            IFieldEdit XMinField = new FieldClass();
            IFieldEdit YMinField = new FieldClass();
            IFieldEdit XMaxField = new FieldClass();
            IFieldEdit YMaxField = new FieldClass();
            IFieldEdit addrType = new FieldClass();

            XMinField.Name_2 = "XMin";
            YMinField.Name_2 = "YMin";
            XMaxField.Name_2 = "XMax";
            YMaxField.Name_2 = "YMax";
            addrType.Name_2 = "Addr_type";

            XMinField.Type_2 = esriFieldType.esriFieldTypeDouble;
            YMinField.Type_2 = esriFieldType.esriFieldTypeDouble;
            XMaxField.Type_2 = esriFieldType.esriFieldTypeDouble;
            YMaxField.Type_2 = esriFieldType.esriFieldTypeDouble;
            addrType.Type_2 = esriFieldType.esriFieldTypeString;

            XMinField.Precision_2 = 8;
            YMinField.Precision_2 = 8;
            XMaxField.Precision_2 = 8;
            YMaxField.Precision_2 = 8;
            addrType.Length_2 = 20;

            fieldsEdit.AddField(XMinField);
            fieldsEdit.AddField(YMinField);
            fieldsEdit.AddField(XMaxField);
            fieldsEdit.AddField(YMaxField);
            fieldsEdit.AddField(addrType);

            m_matchFields = fieldsEdit as IFields;

            fieldsEdit = new FieldsClass();
            shapeField = new FieldClass();
            scoreField = new FieldClass();
            xField = new FieldClass();
            yField = new FieldClass();
            matchField = new FieldClass();

            // Create the CandidateFields
            shapeField.Name_2 = "Shape";
            shapeField.Type_2 = esriFieldType.esriFieldTypeGeometry;
            shapeField.GeometryDef_2 = geometryDefEdit as GeometryDef;
            fieldsEdit.AddField(shapeField);

            scoreField.Name_2 = "Score";
            scoreField.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
//.........这里部分代码省略.........
开发者ID:EsriUK,项目名称:dynamic-locator-sdk,代码行数:101,代码来源:BNGLocator.cs

示例9: UpdateParameters

        // This method will update the output parameter value with the additional area field.
        public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager pEnvMgr)
        {
            m_Parameters = paramvalues;

            // Retrieve the input parameter value
            IGPValue parameterValue = m_GPUtilities.UnpackGPValue(m_Parameters.get_Element(0));

            // Get the derived output feature class schema and empty the additional fields. This will ensure you don't get duplicate entries.
            IGPParameter3 derivedFeatures = (IGPParameter3)paramvalues.get_Element(2);
            IGPFeatureSchema schema = (IGPFeatureSchema)derivedFeatures.Schema;
            schema.AdditionalFields = null;

            // If we have an input value, create a new field based on the field name the user entered.            
            if  (parameterValue.IsEmpty() == false)
            {
                IGPParameter3 fieldNameParameter = (IGPParameter3)paramvalues.get_Element(1);
                string fieldName = fieldNameParameter.Value.GetAsText();
                
                // Check if the user's input field already exists
                IField areaField = m_GPUtilities.FindField(parameterValue, fieldName);
                if (areaField == null)
                {
                    IFieldsEdit fieldsEdit = new FieldsClass();
                    IFieldEdit fieldEdit = new FieldClass();
                    fieldEdit.Name_2 = fieldName;
                    fieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                    fieldsEdit.AddField(fieldEdit);

                    // Add an additional field for the area values to the derived output.
                    IFields fields = fieldsEdit as IFields;                    
                    schema.AdditionalFields = fields;
                }
                
            }
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:36,代码来源:CalculateAreaFunction.cs

示例10: ValidateFieldName

        /// <summary>
        /// Validates a field name
        /// </summary>
        /// <param name="name">The field name to validate</param>
        /// <param name="message">If field name fails then this variable will contain a description</param>
        /// <returns>True if passed. False if failed.</returns>
        public bool ValidateFieldName(string name, out string message) {
            // Validate Input Arguments
            if (string.IsNullOrEmpty(name)) {
                throw new NullReferenceException("<name> argument cannot be null");
            }

            // Create Field Checker
            IFieldChecker fieldChecker = new FieldCheckerClass();
            fieldChecker.ValidateWorkspace = this._workspace;

            // Create Field
            IFieldEdit fieldEdit = new FieldClass();
            fieldEdit.Name_2 = name;
            fieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger;

            // Create Fields
            IFieldsEdit fieldsEdit = new FieldsClass();
            fieldsEdit.AddField((IField)fieldEdit);

            // Create Field Error Enumerator
            IEnumFieldError enumFieldError = null;
            IFields fieldsFixed = null;

            // Validate Field Name
            fieldChecker.ValidateField(0, (IFields)fieldsEdit, out enumFieldError, out fieldsFixed);

            // Get Validated Name (if any)
            string newName = null;
            if (fieldsFixed != null) {
                IField fieldFixed = fieldsFixed.get_Field(0);
                newName = fieldFixed.Name;
            }

            // Get Errors (if any)
            if (enumFieldError != null) {
                enumFieldError.Reset();
                IFieldError fieldError = enumFieldError.Next();
                if (fieldError != null) {
                    switch (fieldError.FieldError) {
                        case esriFieldNameErrorType.esriDuplicatedFieldName:
                            message = "is duplicated";
                            return false;
                        case esriFieldNameErrorType.esriInvalidCharacter:
                            message = "contains one or more invalid characters";
                            return false;
                        case esriFieldNameErrorType.esriInvalidFieldNameLength:
                            message = "is too long";
                            return false;
                        case esriFieldNameErrorType.esriNoFieldError:
                            message = "has no field error";
                            return false;
                        case esriFieldNameErrorType.esriSQLReservedWord:
                            message = "contains one or more reserved word";
                            return false;
                        default:
                            message = "contains an unknown error";
                            return false;
                    }
                }
            }

            // The FieldChecker may have renamed the field without returning an error.
            if (newName != null) {
                if (newName != name) {
                    message = "has an invalid field name";
                    return false;
                }
            }

            // No Errors
            message = null;
            return true;
        }
开发者ID:savagemat,项目名称:arcgis-diagrammer,代码行数:79,代码来源:Validator.cs

示例11: UpdateParameters

        // This method will update the output parameter value with the additional area field.
        public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager pEnvMgr)
        {
            m_Parameters = paramvalues;

            IGPMultiValue inputValues = (IGPMultiValue)m_GPUtilities.UnpackGPValue(m_Parameters.get_Element(0));

            // Get the derived output feature class schema and empty the additional fields. This will ensure you don't get duplicate entries.
            IGPParameter3 derivedFeatures = (IGPParameter3)paramvalues.get_Element(1);
            IGPValue derivedValue = m_GPUtilities.UnpackGPValue(derivedFeatures);
            IGPFeatureSchema schema = (IGPFeatureSchema)derivedFeatures.Schema;
            schema.AdditionalFields = null;

            // If we have an input value, create a new field based on the field name the user entered.
            if (!derivedValue.IsEmpty() && inputValues.Count > 0)
            {
                IFields inputFields = m_GPUtilities.GetFields(inputValues.get_Value(0));
                IField shapeField = null;
                for(int i = 0; i < inputFields.FieldCount; i++)
                {
                    if (inputFields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry)
                    {
                        shapeField = inputFields.get_Field(i);
                        break;
                    }
                }

                IFields fields = new FieldsClass();
                fields.AddField("ObjectID", esriFieldType.esriFieldTypeOID);
                fields.AddField(FEATURE_SOURCE_FIELD_NAME, esriFieldType.esriFieldTypeString);
                fields.AddField(FEATURE_ID_FIELD_NAME, esriFieldType.esriFieldTypeInteger);
                fields.AddField(shapeField);

                schema.AdditionalFields = fields;
            }
        }
开发者ID:EsriCanada,项目名称:TechTrek_Idol_2016,代码行数:36,代码来源:Class1.cs

示例12: CreateObserversFeatureClass

        /// <summary> 
        /// Create the point feature class for observer locations
        /// </summary> 
        /// <param name="featWorkspace"></param> 
        /// <param name="name"></param> 
        /// <returns></returns> 
        public static IFeatureClass CreateObserversFeatureClass(IFeatureWorkspace featWorkspace, string name)
        {
            IFieldsEdit pFldsEdt = new FieldsClass();
            IFieldEdit pFldEdt = new FieldClass();

            pFldEdt = new FieldClass();
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeOID;
            pFldEdt.Name_2 = "OBJECTID";
            pFldEdt.AliasName_2 = "OBJECTID";
            pFldsEdt.AddField(pFldEdt);

            IGeometryDefEdit pGeoDef;
            pGeoDef = new GeometryDefClass();
            pGeoDef.GeometryType_2 = esriGeometryType.esriGeometryPoint;
            pGeoDef.SpatialReference_2 = ArcMap.Document.FocusMap.SpatialReference;
            pGeoDef.HasZ_2 = true;

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "SHAPE";
            pFldEdt.AliasName_2 = "SHAPE";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeGeometry;
            pFldEdt.GeometryDef_2 = pGeoDef;
            pFldsEdt.AddField(pFldEdt);

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "OFFSETA";
            pFldEdt.AliasName_2 = "OFFSETA";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble;
            pFldsEdt.AddField(pFldEdt);

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "OFFSETB";
            pFldEdt.AliasName_2 = "OFFSETB";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble;
            pFldsEdt.AddField(pFldEdt);

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "AZIMUTH1";
            pFldEdt.AliasName_2 = "AZIMUTH1";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble;
            pFldsEdt.AddField(pFldEdt);

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "AZIMUTH2";
            pFldEdt.AliasName_2 = "AZIMUTH2";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble;
            pFldsEdt.AddField(pFldEdt);

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "RADIUS1";
            pFldEdt.AliasName_2 = "RADIUS1";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble;
            pFldsEdt.AddField(pFldEdt);

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "RADIUS2";
            pFldEdt.AliasName_2 = "RADIUS2";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble;
            pFldsEdt.AddField(pFldEdt);

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "VERT1";
            pFldEdt.AliasName_2 = "VERT1";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble;
            pFldsEdt.AddField(pFldEdt);

            pFldEdt = new FieldClass();
            pFldEdt.Name_2 = "VERT2";
            pFldEdt.AliasName_2 = "VERT2";
            pFldEdt.Type_2 = esriFieldType.esriFieldTypeDouble;
            pFldsEdt.AddField(pFldEdt);

            IFeatureClass pFClass = featWorkspace.CreateFeatureClass(name, pFldsEdt, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");

            return pFClass;
        }
开发者ID:Esri,项目名称:visibility-addin-dotnet,代码行数:82,代码来源:RLOSViewModel.cs


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