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


C# ESRI.FindField方法代码示例

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


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

示例1: BuildShapefileSpatialIndex

        public System.Boolean BuildShapefileSpatialIndex(ESRI.ArcGIS.Geodatabase.IFeatureClass ShapefileFeatureClass)
        {
            ESRI.ArcGIS.Geodatabase.IFields     indexShapefileFields      = null;
              ESRI.ArcGIS.Geodatabase.IFieldsEdit indexShapefileFieldsEdit  = null;
              ESRI.ArcGIS.Geodatabase.IField      shapefileGeometryField    = null;
              ESRI.ArcGIS.Geodatabase.IIndex      shapefileSpatialIndex     = null;
              ESRI.ArcGIS.Geodatabase.IIndexEdit  shapefileSpatialIndexEdit = null;
              ESRI.ArcGIS.Geodatabase.IEnumIndex  shapefileExistingIndices  = null;
              ESRI.ArcGIS.Geodatabase.IIndex      shapefileDeleteIndex      = null;

              try
              {
            //  Make sure the Feature Class Object is not a NULL Pointer before moving on.
            if (ShapefileFeatureClass == null)
            {
              //  Let the User know that a valid Shapefile Name MUST be passed before the index can
              //  be created.
              if (ErrorMessage != null)
              {
            ErrorMessage("A Valid Shapefile Object must be passed to this method! The MaintTools.FeatureClassUtilities.BuildShapefileSpatialIndex() Method failed!");
              }

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

            }

            //  If the Process Message Event has been instantiated, let the user know what is happening.
            if (ProcessMessage != null)
            {
              ProcessMessage("      -  Opening the Shapefile Geometry Field and preparing it to be indexed...");
            }

            //  Create a Fields Object and open an Editing Object on it so that new fields can be added.
            indexShapefileFields = new ESRI.ArcGIS.Geodatabase.FieldsClass();
            indexShapefileFieldsEdit = (ESRI.ArcGIS.Geodatabase.IFieldsEdit)indexShapefileFields;

            //  Find the Geometry Field in the Field in the Shapefile Fields Object and add it to the
            //  Fields Collection.
            indexShapefileFieldsEdit.FieldCount_2 = 1;
            int l = ShapefileFeatureClass.FindField(ShapefileFeatureClass.ShapeFieldName);
            if (l < 0)
            {
              //  Let the user know that the Geometry Field of the Shapefile Feature Class could not
              //  be found.
              if (ErrorMessage != null)
              {
            ErrorMessage("The Shapefile Geometry Field could not be found! The MaintTools.FeatureClassUtilities.BuildShapefileSpatialIndex() Method failed!");
              }

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

            }
            shapefileGeometryField = ShapefileFeatureClass.Fields.get_Field(l);
            indexShapefileFieldsEdit.set_Field(0, shapefileGeometryField);

            //  If the Process Message Event has been instantiated, let the user know what is happening.
            if (ProcessMessage != null)
            {
              ProcessMessage("      -  Creating the Index and applying it to the Shapefile Feature Class Geometry Field...");
            }

            //  Create a new index and prepare it to be added to the table.
            shapefileSpatialIndex = new ESRI.ArcGIS.Geodatabase.IndexClass();
            shapefileSpatialIndexEdit = (ESRI.ArcGIS.Geodatabase.IIndexEdit)shapefileSpatialIndex;
            shapefileSpatialIndexEdit.Fields_2 = indexShapefileFields;
            shapefileSpatialIndexEdit.Name_2 = "Idx_1";

            //  Remove all Indices from the table.
            shapefileExistingIndices = ShapefileFeatureClass.Indexes.FindIndexesByFieldName(ShapefileFeatureClass.ShapeFieldName);

            shapefileDeleteIndex = shapefileExistingIndices.Next();
            while (shapefileDeleteIndex != null)
            {
              ShapefileFeatureClass.DeleteIndex(shapefileDeleteIndex);
              shapefileDeleteIndex = shapefileExistingIndices.Next();
            }

            //  Add the index to the Shapefile.
            ShapefileFeatureClass.AddIndex(shapefileSpatialIndex);

            //  If the process made it to here it was successful so return TRUE to the calling method.
            return true;

              }
              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.BuildShapefileSpatialIndex() Method failed with error message - " + caught.Message + " (Line:  " + lineNumber.ToString() + ")!");

            }

//.........这里部分代码省略.........
开发者ID:MitchVan,项目名称:DataMaintenanceUtilities,代码行数:101,代码来源:FeatureClassUtilities.cs

示例2: getDictionaryValues

 private static Dictionary<string, double[][]> getDictionaryValues(ESRI.ArcGIS.Geodatabase.IFeatureClass pointFtr, ESRI.ArcGIS.Geodatabase.IField[] fldsToSummarize, IFunctionRasterDataset strataRaster, geoDatabaseUtility geoUtil, rasterUtil rsUtil)
 {
     IRaster2 rs2 = (IRaster2)rsUtil.createRaster(strataRaster);
     int[] ptfldIndex = new int[fldsToSummarize.Length];
     for (int i = 0; i < ptfldIndex.Length; i++)
     {
         ptfldIndex[i] = pointFtr.FindField(fldsToSummarize[i].Name);
     }
     Dictionary<string, double[][]> outDic = new Dictionary<string, double[][]>();
     IFeatureCursor sCur = pointFtr.Search(null, true);
     IFeature sFtr = sCur.NextFeature();
     while (sFtr != null)
     {
         IGeometry geo = sFtr.Shape;
         IPoint pnt = (IPoint)geo;
         int clm, rw;
         rs2.MapToPixel(pnt.X, pnt.Y,out clm, out rw);
         object strataVlObj = rs2.GetPixelValue(0, clm, rw);
         if(strataVlObj!=null)
         {
             string strataVl = strataVlObj.ToString();
             double[][] vlArr;
             if (outDic.TryGetValue(strataVl, out vlArr))
             {
                 for (int i = 0; i < ptfldIndex.Length; i++)
                 {
                     object vlObj = sFtr.get_Value(ptfldIndex[i]);
                     if (vlObj != null)
                     {
                         double vl = System.Convert.ToDouble(vlObj);
                         vlArr[i][0] += vl;
                         vlArr[i][1] += (vl * vl);
                         vlArr[i][2] += 1;
                     }
                 }
             }
             else
             {
                 vlArr = new double[fldsToSummarize.Length][];
                 for (int i = 0; i < ptfldIndex.Length; i++)
                 {
                     double[] vlSumArr = new double[3];
                     object vlObj =sFtr.get_Value(ptfldIndex[i]);
                     if (vlObj != null)
                     {
                         double vl =  System.Convert.ToDouble(vlObj);
                         vlSumArr[0] = vl;
                         vlSumArr[1] = (vl * vl);
                         vlSumArr[2] = 1;
                     }
                     vlArr[i] = vlSumArr;
                 }
                 outDic[strataVl] = vlArr;
             }
         }
         sFtr = sCur.NextFeature();
     }
     System.Runtime.InteropServices.Marshal.ReleaseComObject(sCur);
     return outDic;
 }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:60,代码来源:fiaIntegration.cs


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