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


C# IFeatureClass.FindField方法代码示例

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


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

示例1: GetCity

        private City GetCity(IFeature city, IFeatureClass cityClass)
        {
            IPoint capitalShape = city.Shape as IPoint;
            int areaNameIndex = cityClass.FindField(CityConst.AREA_NAME);

            return new City()
            {
                AreaName = city.get_Value(areaNameIndex) as string,
                X = capitalShape.X,
                Y = capitalShape.Y
            };
        }
开发者ID:nyxz,项目名称:FMI-Projects,代码行数:12,代码来源:CityByStateSearchManager.cs

示例2: CreateFeature

        public static void CreateFeature(IFeatureClass featureClass, IPoint point)
        {
            // Build the feature
            IFeature feature = featureClass.CreateFeature();
            feature.Shape = point;

            //Update a value on string field - name of the new feature (city)
            int fieldIndex = featureClass.FindField("AREANAME");
            feature.set_Value(fieldIndex, "Mentone");

            //Commit the new feature to the geodatabase
            feature.Store();
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:13,代码来源:_CreateFeature.cs

示例3: Calculate

        /// <summary>
        /// 参数说明,栅格面,写入这个面的字段名称,点要素,点要素的速度字段,计算平均速度
        /// </summary>
        /// <param name="pPolygonFClass"></param>
        /// <param name="pFieldName"></param>
        /// <param name="pPointFClass"></param>
        /// <param name="FieldName"></param>
        public void Calculate(IFeatureClass pPolygonFClass, string pFieldName,IFeatureClass pPointFClass, string FieldName)
        {
            IFeatureCursor pPolyCursor = pPolygonFClass.Search(null, false);

            int pFieldIndex = pPointFClass.FindField(FieldName);

            IFeature pPolyFeature = pPolyCursor.NextFeature();

            int pPolygonIndex = pPolygonFClass.FindField(pFieldName);

            while (pPolyFeature != null)
            {
                IGeometry pPolGeo = pPolyFeature.Shape;

                int Count = 0;

                ISpatialFilter spatialFilter = new SpatialFilterClass();

                spatialFilter.Geometry = pPolGeo;

                spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;

                IFeatureCursor pPointCur = pPointFClass.Search(spatialFilter, false);
                double TotalSpeed = 0;

                if (pPointCur != null)
                {
                    IFeature pPointFeature = pPointCur.NextFeature();

                    while (pPointFeature != null)
                    {
                        pPointFeature = pPointCur.NextFeature();

                        TotalSpeed = TotalSpeed + (double)pPointFeature.get_Value(pFieldIndex);
                        Count++;
                    }

                }

                if (Count != 0)
                {
                    pPolyFeature.set_Value(pPolygonIndex, TotalSpeed / Count);

                }
                pPolyFeature = pPolyCursor.NextFeature();

            }
        }
开发者ID:esrichina,项目名称:Engine10DevApplication,代码行数:55,代码来源:Search.cs

示例4: UpdateFeature

        public static void UpdateFeature(IFeatureClass featureClass)
        {
            // Create a COM releaser for cursor management
            using (ComReleaser comReleaser = new ComReleaser())
            {
                // Use IFeatureClass.Update to create an update cursor
                IFeatureCursor featureCursor = featureClass.Update(null, true);
                comReleaser.ManageLifetime(featureCursor);

                // find the index of the field named "country"
                int fieldIndex = featureClass.FindField("Country");

                IFeature feature = null;
                while ((feature = featureCursor.NextFeature()) != null)
                {
                    feature.set_Value(fieldIndex, "USA");
                    featureCursor.UpdateFeature(feature); // Do not use IFeature.Store with UpdateCursors
                }
            }
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:20,代码来源:_CreateFeature.cs

示例5: Bind

 public void Bind(object pArgument)
 {
     if (pArgument is mergeFunctionArguments)
     {
         mergeFunctionArguments arg = (mergeFunctionArguments)pArgument;
         inrs = arg.InRaster;
         outrs = arg.OutRaster;
         //Console.WriteLine("Number of Bands in outrs = " + ((IRasterBandCollection)outrs).Count.ToString());
         ftrCls = arg.Boundary;
         //ftrCls = arg.Boundary.Catalog;
         catIndex = ftrCls.FindField("catIndex");
         IRasterProps rsProp = (IRasterProps)outrs;
         myFunctionHelper.Bind(outrs);
         myRasterInfo = myFunctionHelper.RasterInfo;
         myPixeltype = myRasterInfo.PixelType;
         myValidFlag = true;
     }
     else
     {
         throw new System.Exception("Incorrect arguments object. Expected: mergeFunctionArguments");
     }
 }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:22,代码来源:mergeFunctionDatasetBase.cs

示例6: GetStateDetails

        private StateDetails GetStateDetails(IFeature state, IFeatureClass statesClass)
        {
            int areaIdx = statesClass.FindField(StateConst.AREA);
            int stateNameIdx = statesClass.FindField(StateConst.STATE_NAME);
            int subRegionIdx = statesClass.FindField(StateConst.SUB_REGION);
            int stateAbbrIdx = statesClass.FindField(StateConst.STATE_ABBR);
            int pop2000Idx = statesClass.FindField(StateConst.POP2000);
            int pop00_sqmiIdx = statesClass.FindField(StateConst.POP00_SQMI);

            return new StateDetails
            {
                Area = (double)state.get_Value(areaIdx),
                StateName = state.get_Value(stateNameIdx) as string,
                SubRegion = state.get_Value(subRegionIdx) as string,
                StateAbbr = state.get_Value(stateAbbrIdx) as string,
                Pop2000 = (int)state.get_Value(pop2000Idx),
                Pop00_SQMI = (int)state.get_Value(pop00_sqmiIdx)
            };
        }
开发者ID:nyxz,项目名称:FMI-Projects,代码行数:19,代码来源:SearchStatesManager.cs

示例7: calcStandMeans

 private static void calcStandMeans(IFeatureClass strataFtr, IFeatureClass standsFtr, int[] meanStrataFldIndex, int[] varStrataFldIndex, int[] countFldStrataIndex, IField[] fldsToSummarize, geoDatabaseUtility geoUtil)
 {
     int cnt = 0;
     int[] ptFldIndex = new int[fldsToSummarize.Length];
     int[] meanFldIndex = new int[fldsToSummarize.Length];
     int[] varFldIndex = new int[fldsToSummarize.Length];
     int[] cntFldIndex = new int[fldsToSummarize.Length];
     foreach (IField fld in fldsToSummarize)
     {
         string sName = geoUtil.createField(standsFtr, "v_" + fld.Name, esriFieldType.esriFieldTypeDouble, false);
         varFldIndex[cnt] = standsFtr.FindField(sName);
         string mName = geoUtil.createField(standsFtr, "m_" + fld.Name, esriFieldType.esriFieldTypeDouble, false);
         meanFldIndex[cnt] = standsFtr.FindField(mName);
         string cName = geoUtil.createField(standsFtr, "n_" + fld.Name, esriFieldType.esriFieldTypeDouble, false);
         cntFldIndex[cnt] = standsFtr.FindField(cName);
         cnt++;
     }
     IFeatureCursor uCur = standsFtr.Update(null, true);
     IFeature uFtr = uCur.NextFeature();
     while (uFtr != null)
     {
         ESRI.ArcGIS.Geometry.IGeometry geo = uFtr.Shape;
         ISpatialFilter spFlt = new SpatialFilter();
         spFlt.Geometry = geo;
         spFlt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
         double totalArea = 0;
         IFeatureCursor sCur = strataFtr.Search(spFlt, true);
         IFeature sFtr = sCur.NextFeature();
         double[][] vlArr = new double[meanFldIndex.Length][];
         for (int i = 0; i < meanFldIndex.Length; i++)
         {
             vlArr[i] = new double[3];
         }
         while (sFtr != null)
         {
             ESRI.ArcGIS.Geometry.IGeometry sgeo = sFtr.Shape;
             ESRI.ArcGIS.Geometry.ITopologicalOperator4 topo = (ESRI.ArcGIS.Geometry.ITopologicalOperator4)sgeo;
             ESRI.ArcGIS.Geometry.IGeometry sgeo2 = topo.Intersect(geo, ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension);
             double subArea = (((ESRI.ArcGIS.Geometry.IArea)sgeo2).Area);
             totalArea += subArea;
             for (int i = 0; i < meanFldIndex.Length; i++)
             {
                 vlArr[i][0] += System.Convert.ToDouble(sFtr.get_Value(meanStrataFldIndex[i])) * subArea;
                 vlArr[i][1] += System.Convert.ToDouble(sFtr.get_Value(varStrataFldIndex[i])) * subArea;
                 vlArr[i][2] += System.Convert.ToDouble(sFtr.get_Value(countFldStrataIndex[i]));
             }
             sFtr = sCur.NextFeature();
         }
         System.Runtime.InteropServices.Marshal.ReleaseComObject(sCur);
         if (totalArea != 0)
         {
             for (int i = 0; i < meanFldIndex.Length; i++)
             {
                 uFtr.set_Value(meanFldIndex[i], vlArr[i][0]/totalArea);
                 uFtr.set_Value(varFldIndex[i], vlArr[i][1]/totalArea);
                 uFtr.set_Value(cntFldIndex[i], vlArr[i][2]);
             }
             uCur.UpdateFeature(uFtr);
         }
         uFtr = uCur.NextFeature();
     }
     System.Runtime.InteropServices.Marshal.ReleaseComObject(uCur);
 }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:63,代码来源:fiaIntegration.cs

示例8: summarizeBiomassPolygon

        public static void summarizeBiomassPolygon(IFeatureClass pointFtr, IField[] fldsToSummarize, IFunctionRasterDataset strataRaster, IFeatureClass standsFtr, geoDatabaseUtility geoUtil = null, rasterUtil rsUtil = null)
        {
            if (geoUtil == null) geoUtil = new geoDatabaseUtility();
            if(rsUtil == null) rsUtil = new rasterUtil();
            int cnt = 0;
            //need to work on calculating N
            Dictionary<string,double[][]> vlDic = getDictionaryValues(pointFtr, fldsToSummarize, strataRaster, geoUtil, rsUtil); //Strata: SummaryFields [{sum,sum2,cnt},...]
            int[] meanFldIndex = new int[fldsToSummarize.Length];
            int[] varFldIndex = new int[fldsToSummarize.Length];
            int[] cntFldIndex = new int[fldsToSummarize.Length];
            //string cntName = geoUtil.createField(standsFtr, "n", esriFieldType.esriFieldTypeInteger, false);
            //int cntIndex = standsFtr.FindField(cntName);
            foreach (IField fld in fldsToSummarize)
            {
                string sName = geoUtil.createField(standsFtr, "v_" + fld.Name, esriFieldType.esriFieldTypeDouble, false);
                varFldIndex[cnt] = standsFtr.FindField(sName);
                string mName = geoUtil.createField(standsFtr, "m_" + fld.Name, esriFieldType.esriFieldTypeDouble, false);
                meanFldIndex[cnt] = standsFtr.FindField(mName);
                string cntName = geoUtil.createField(standsFtr, "n_" + fld.Name, esriFieldType.esriFieldTypeDouble, false);
                cntFldIndex[cnt] = standsFtr.FindField(cntName);
                cnt++;
            }
            IFeatureCursor uCur = standsFtr.Update(null, true);
            IFeature uFtr = uCur.NextFeature();
            while (uFtr != null)
            {
                ESRI.ArcGIS.Geometry.IGeometry geo = uFtr.Shape;
                IFunctionRasterDataset cRs = rsUtil.clipRasterFunction(strataRaster, geo, esriRasterClippingType.esriRasterClippingOutside);
                //Console.WriteLine("Clipping raster");
                Dictionary<string, double> rsStrataPropDic = getStrataProportion(cRs,rsUtil); //Strata: proportion of area
                //int tn = 0;
                //double[] tn = new double[meanFldIndex.Length];
                double[][] updateValuesArr = new double[meanFldIndex.Length][];
                for (int i = 0; i < meanFldIndex.Length; i++)
                {
                    updateValuesArr[i] = new double[3];
                }
                foreach (KeyValuePair<string, double> kvp in rsStrataPropDic)
                {
                    string stratum = kvp.Key;
                    double proportion = kvp.Value;
                    //Console.WriteLine(stratum + " = " + proportion.ToString());
                    double[][] vlDicArr;
                    if (vlDic.TryGetValue(stratum, out vlDicArr))
                    {
                        //double n = vlDicArr[0][2];
                        //tn += System.Convert.ToInt32(n);
                        for (int i = 0; i < meanFldIndex.Length; i++)
                        {
                            double[] dArr = vlDicArr[i];
                            double n = dArr[2];
                            //tn[i] += n;
                            double s=dArr[0];
                            double s2=dArr[1];
                            updateValuesArr[i][0] += (s/n) * proportion;//mean
                            updateValuesArr[i][1] += (s2-Math.Pow(s,2)/n)/(n-1) * proportion;//variance
                            updateValuesArr[i][2] += n;
                        }

                    }
                }
                //uFtr.set_Value(cntIndex, tn);
                for (int i = 0; i < meanFldIndex.Length; i++)
                {
                    uFtr.set_Value(meanFldIndex[i], updateValuesArr[i][0]);
                    uFtr.set_Value(varFldIndex[i], updateValuesArr[i][1]);
                    uFtr.set_Value(cntFldIndex[i], updateValuesArr[i][2]);
                }
                uCur.UpdateFeature(uFtr);
                uFtr = uCur.NextFeature();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(uCur);
        }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:73,代码来源:fiaIntegration.cs

示例9: CreateTrackUniqueValueRenderer

    private IUniqueValueRenderer CreateTrackUniqueValueRenderer(IFeatureClass featureClass, string fieldName)
    {
      IRgbColor color = new RgbColorClass();
      color.Red = 0;
      color.Blue = 0;
      color.Green = 255;

      ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
      simpleLineSymbol.Color = (IColor)color;
      simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
      simpleLineSymbol.Width = 1.0;

      IUniqueValueRenderer uniqueRenderer = new UniqueValueRendererClass();
      uniqueRenderer.FieldCount = 1;
      uniqueRenderer.set_Field(0, fieldName);
      uniqueRenderer.DefaultSymbol = (ISymbol)simpleLineSymbol;
      uniqueRenderer.UseDefaultSymbol = true;

      Random rand = new Random();
      bool bValFound = false;
      IFeatureCursor featureCursor = featureClass.Search(null, true);
      IFeature feature = null;
      string val = string.Empty;
      int fieldID = featureClass.FindField(fieldName);
      if (-1 == fieldID)
        return uniqueRenderer;

      while ((feature = featureCursor.NextFeature()) != null)
      {
        bValFound = false;
        val = Convert.ToString(feature.get_Value(fieldID));
        for (int i = 0; i < uniqueRenderer.ValueCount - 1; i++)
        {
          if (uniqueRenderer.get_Value(i) == val)
            bValFound = true;
        }

        if (!bValFound)//need to add the value to the renderer
        {
          color.Red = rand.Next(255);
          color.Blue = rand.Next(255);
          color.Green = rand.Next(255);

          simpleLineSymbol = new SimpleLineSymbolClass();
          simpleLineSymbol.Color = (IColor)color;
          simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
          simpleLineSymbol.Width = 1.0;

          //add the value to the renderer
          uniqueRenderer.AddValue(val, "name", (ISymbol)simpleLineSymbol);
        }
      }

      //release the featurecursor
      ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(featureCursor);

      return uniqueRenderer;
    }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:58,代码来源:PlaybackDataButton.cs

示例10: reprojectInFeatureClass

        public IFeatureClass reprojectInFeatureClass(IFeatureClass InFeatureClass, ISpatialReference SpatialReference)
        {
            IWorkspace tempWorkspace = geoUtil.OpenWorkSpace(tempWksStr);
            string outNm = ((IDataset)InFeatureClass).BrowseName+"_PR";
            outNm = geoUtil.getSafeOutputNameNonRaster(wks,outNm);
            IFields outFlds = new FieldsClass();
            IFieldsEdit outFldsE = (IFieldsEdit)outFlds;
            IField inFld = InFeatureClass.Fields.get_Field(InFeatureClass.FindField(ftrField));
            IField outFld = new FieldClass();
            if (inFld.Type == esriFieldType.esriFieldTypeOID)
            {
                IFieldEdit outFldE = (IFieldEdit)outFld;
                outFldE.Type_2 = esriFieldType.esriFieldTypeInteger;
                outFldE.Name_2 = inFld.Name;
            }
            else
            {
                IClone cl = (IClone)inFld;
                outFld = (IField)cl.Clone();
            }
            outFldsE.AddField(outFld);
            IFeatureClass outFtrCls = geoUtil.createFeatureClass((IWorkspace2)tempWorkspace,outNm,outFldsE,InFeatureClass.ShapeType,SpatialReference);
            string ozName = ftrField;
            int ozIndex = outFtrCls.FindField(ozName);
            if (ozIndex == -1)
            {
                ozName = ftrField+"_1";
                ozIndex = outFtrCls.FindField(ozName);

            }
            int izIndex = InFeatureClass.FindField(ftrField);
            IQueryFilter qf = new QueryFilterClass();
            qf.SubFields = InFeatureClass.ShapeFieldName + "," + ftrField;
            IFeatureCursor fCur = InFeatureClass.Search(qf, false);
            IFeature ftr = fCur.NextFeature();
            IWorkspaceEdit wksE = (IWorkspaceEdit)tempWorkspace;
            bool weStart = true;
            if(wksE.IsBeingEdited())
            {
                weStart=false;
            }
            else
            {
                wksE.StartEditing(false);
            }
            wksE.StartEditOperation();
            try
            {
                while (ftr != null)
                {
                    object vl = ftr.get_Value(izIndex);
                    IFeatureProject ftrP = (IFeatureProject)ftr;
                    ftrP.Project(SpatialReference);
                    IFeature oFtr = outFtrCls.CreateFeature();
                    oFtr.Shape = ftr.Shape;
                    if(ozIndex>-1) oFtr.set_Value(ozIndex, vl);
                    oFtr.Store();
                    ftr = fCur.NextFeature();
                }
                ftrField = ozName;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                wksE.StopEditOperation();
                if (weStart) wksE.StopEditing(true);
            }
            return outFtrCls;
        }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:72,代码来源:zonalHelper.cs

示例11: AddQALayerToActiveView

        private void AddQALayerToActiveView(IMap map, IFeatureClass SourceLineFeatureClass, IFeatureClass SourcePolygonFeatureClass,
      string layerPathFile, double metersPerUnit, bool bIsBefore1022, bool bFabricIsInGCS)
        {
            if (map == null || layerPathFile == null || !layerPathFile.EndsWith(".lyr"))
              {
            return;
              }

              // Create a new GxLayer
              IGxLayer gxLayer = new GxLayerClass();
              IGxFile gxFile = (IGxFile)gxLayer;

              // Set the path for where the layerfile is located on disk
              gxFile.Path = layerPathFile;

              // Test if we have a valid layer and add it to the map
              if (!(gxLayer.Layer == null))
              {
            if (!(gxLayer.Layer is ICompositeLayer))
              return;
            ICompositeLayer pCompLyr = (ICompositeLayer)gxLayer.Layer;
            for (int i=0; i<pCompLyr.Count; i++)
            {
              ILayer pLyr = pCompLyr.get_Layer(i);
              //
              if (pLyr is IFeatureLayer)
              {
            IFeatureLayer pFlyr = (IFeatureLayer)pLyr;
            //now update the definition query
            IFeatureLayerDefinition pFeatLyrDef = (IFeatureLayerDefinition)pFlyr;
            string sLyrName = pFlyr.Name;
            bool bExc = false;
            if (sLyrName.Contains("Minus"))
            {
              pFlyr.FeatureClass = SourceLineFeatureClass;
              bExc = false;

              //ILayerFields pLayerFields = pFlyr as ILayerFields;
              //First turn off all layers
              //for (int kk = 0; kk < pLayerFields.FieldCount; kk++)
              //{
              //  IFieldInfo pFieldInfo = pLayerFields.get_FieldInfo(kk);
              //  pFieldInfo.Visible = false;
              //}

              SetLabelExpressionOnFeatureLayer(pFlyr, out bExc);
              if (bExc || bFabricIsInGCS)
              {
                int jj=pFlyr.FeatureClass.FindField("ComputedMinusObserved");
                if (jj>-1)
                {
                  string sVal = (0.1 / metersPerUnit).ToString("0.00");
                  string sCminusO=pFlyr.FeatureClass.Fields.get_Field(jj).Name;
                  pFeatLyrDef.DefinitionExpression = sCminusO + " > "+sVal+" AND " + sCminusO + " < "+sVal;

                  //IFieldInfo pFieldInfo = pLayerFields.get_Field(jj) as IFieldInfo;
                  //pFieldInfo.Visible = true;

                }
                continue;
              }
              string s = pFeatLyrDef.DefinitionExpression;
              int iField = SourceLineFeatureClass.FindField("ArcLength");
              if (iField > -1)
              {

                //IFieldInfo pFieldInfo = pLayerFields.get_Field(iField) as IFieldInfo;
                //pFieldInfo.Visible = true;

                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                pFeatLyrDef.DefinitionExpression = s.Replace("\"ArcLength\"", s2);
                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ArcLength", s2);
              }

              s = pFeatLyrDef.DefinitionExpression;
              iField = SourceLineFeatureClass.FindField("Distance");
              if (iField > -1)
              {

                //IFieldInfo pFieldInfo = pLayerFields.get_Field(iField) as IFieldInfo;
                //pFieldInfo.Visible = true;

                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                pFeatLyrDef.DefinitionExpression = s.Replace("\"Distance\"", s2);
                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Distance", s2);
              }

              s = pFeatLyrDef.DefinitionExpression;
              iField = SourceLineFeatureClass.FindField("DensifyType");
              if (iField > -1)
              {
                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                pFeatLyrDef.DefinitionExpression = s.Replace("\"DensifyType\"", s2);
                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("DensifyType", s2);
              }

              s = pFeatLyrDef.DefinitionExpression;
              pFeatLyrDef.DefinitionExpression = s.Replace("\"Shape_Length\"", SourceLineFeatureClass.LengthField.Name);
              pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Shape_Length", SourceLineFeatureClass.LengthField.Name);

//.........这里部分代码省略.........
开发者ID:Esri,项目名称:parcel-fabric-desktop-addins,代码行数:101,代码来源:AddQCLayers.cs

示例12: UpdateCircularArcValues

        private bool UpdateCircularArcValues(IFeatureClass LineTable, IQueryFilter QueryFilter, bool Unversioned, IDictionary<int, InferredCurve> CurveLookup, myProgessor progressor, Dictionary<int, int> MaxSequenceCache)
        {
            IFeature pLineFeat = null;
            IFeatureBuffer buffer = null;
            IFeatureCursor pLineCurs = null;
            IFeatureCursor pRadialCur = null;
            IFeatureCursor maxCursor = null;
            IDataStatistics dataStatistics = null;

            IGeometryFactory3 geometryFactory = new GeometryEnvironmentClass();
            IGeometry geometry = new PolylineClass();
            geometryFactory.CreateEmptyGeometryByType(LineTable.ShapeType, out geometry);

            IGeometryDef geometryDef = LineTable.Fields.get_Field(LineTable.FindField(LineTable.ShapeFieldName)).GeometryDef;

            if (geometryDef.HasZ)
            {
                IZAware zAware = (IZAware)(geometry);
                zAware.ZAware = true;
            }
            if (geometryDef.HasM)
            {
                IMAware mAware = (IMAware)(geometry);
                mAware.MAware = true;
            }


            try
            {
                CurveByInferenceSettings.FieldPositions positions = new CurveByInferenceSettings.FieldPositions((ITable)LineTable);

                buffer = LineTable.CreateFeatureBuffer();
                pLineCurs = LineTable.Update(QueryFilter, false);
                pRadialCur = LineTable.Insert(false);

                while ((pLineFeat = pLineCurs.NextFeature()) != null)
                {
                    //loop through all of the given lines, and update centerpoint ids, radius, and arc length values
                    if (!progressor.Continue())
                        return false;
                    progressor.Step();

                    InferredCurve curveInfo = CurveLookup[pLineFeat.OID];

                    pLineFeat.set_Value(positions.RadiusFieldIdx, curveInfo.InferredRadius);
                    pLineFeat.set_Value(positions.CenterpointIDFieldIdx, curveInfo.InferredCenterpointID);
                    IFeature feature = pLineFeat as IFeature;
                    double length = 0;
                    if (feature != null)
                    {
                        IPolyline polyline = feature.ShapeCopy as IPolyline;
                        if (polyline != null)
                        {
                            length = ((IProximityOperator)polyline.FromPoint).ReturnDistance(polyline.ToPoint);
                            pLineFeat.set_Value(positions.ArcLengthFieldIdx, length);
                            Marshal.ReleaseComObject(polyline);
                        }
                    }

                    if (Unversioned)
                        pLineCurs.UpdateFeature(pLineFeat);
                    else
                        pLineFeat.Store();

                    //fine the max sequence value 
                    int maxSequence = -1;
                    if (MaxSequenceCache.ContainsKey(curveInfo.Parcel))
                    {
                        maxSequence = MaxSequenceCache[curveInfo.Parcel];
                    }
                    else
                    {
                        maxCursor = LineTable.Search(new QueryFilter() {
                            SubFields = String.Format("{0}, {1}, {2}", LineTable.OIDFieldName, CurveByInferenceSettings.Instance.SequenceFieldName, CurveByInferenceSettings.Instance.ParcelIDFieldName),
                            WhereClause = String.Format("{0} = {1}", CurveByInferenceSettings.Instance.ParcelIDFieldName, curveInfo.Parcel) }, true);

                        int seqenceIdx = maxCursor.Fields.FindField(CurveByInferenceSettings.Instance.SequenceFieldName);

                        IRow maxFeat = null;
                        while ((maxFeat = maxCursor.NextFeature()) != null)
                        {
                            maxSequence = Math.Max((int)maxFeat.get_Value(seqenceIdx), maxSequence);
                            Marshal.ReleaseComObject(maxFeat);
                        }
                        Marshal.ReleaseComObject(maxCursor);

                        MaxSequenceCache.Add(curveInfo.Parcel, maxSequence);
                        dataStatistics = null;
                        maxCursor = null;                        
                    }
                    if (maxSequence <= 0)
                        throw new Exception("Failed to find max sequence value");

                    //the chord bearing
                    double featureBearing = (double)pLineFeat.get_Value(positions.BearingFieldIdx);

                    //half the delta of the proposed curve would be:
                    double halfdelta = toDegrees(Math.Asin(length / 2 / curveInfo.InferredRadius.Value));

                    //perpendicular to the chord
//.........这里部分代码省略.........
开发者ID:travisval,项目名称:ParcelFabricCurveByInference,代码行数:101,代码来源:CurveByInference.cs

示例13: MatchTable

        /// <summary>
        /// Geocodes a table of addresses
        /// </summary>
        /// <param name="addressTable">Input address table</param>
        /// <param name="addressFieldNames">Fields defined in the table</param>
        /// <param name="whereClause">Query filter where clause</param>
        /// <param name="outputFeatureClass">Output feature class for matched addresses</param>
        /// <param name="outputFieldNames">Output field names</param>
        /// <param name="fieldsToCopy"></param>
        /// <param name="cancelTracker"></param>
        public virtual void MatchTable(ITable addressTable, String addressFieldNames, String whereClause,
          IFeatureClass outputFeatureClass, String outputFieldNames, IPropertySet fieldsToCopy, ITrackCancel cancelTracker)
        {
            _log.Debug("IAddressGeocoding MatchTable");

              // Obtain the read and insert cursors
              IQueryFilter queryFilter = new QueryFilterClass();
              queryFilter.WhereClause = whereClause;
              ICursor readCursor = null;
              IFeatureCursor insertCursor = null;
              IFeatureCursor updateCursor = null;

              // m_needToUpdate will be True when a Rematch is being preformed
              if (m_needToUpdate)
              {
              // Create update cursor to update matched records
              updateCursor = outputFeatureClass.Update(queryFilter, false);
              if (isSameObject(addressTable, outputFeatureClass))
                  readCursor = updateCursor as ICursor;
              else
                  readCursor = addressTable.Search(queryFilter, true);
              }
              else
              {
              // Create insert cursor to add new records
              readCursor = addressTable.Search(queryFilter, true);
              insertCursor = outputFeatureClass.Insert(true);
              }

              int count = addressTable.RowCount(queryFilter);

              // Progress dialog setup
              IStepProgressor progressor = null;
              if (cancelTracker != null)
              progressor = cancelTracker.Progressor as IStepProgressor;
              IProgressStatistics progStats = cancelTracker as IProgressStatistics;
              if (progressor != null)
              {
              progressor.StepValue = 1;
              progressor.MaxRange = addressTable.RowCount(null);
              }

              // Separate the input field names
              string[] multilineFields = addressFieldNames.Split(',');

              // Read the first row and get the address field
              IRow row = readCursor.NextRow();

              Dictionary<int, string> addressFieldIndexes = new Dictionary<int, string>();

              // Get the index of each valid field
              for (int i = 0; i < multilineFields.Length; i++)
              {
              if (multilineFields[i].Trim().Length > 0)
                  addressFieldIndexes.Add(row.Fields.FindField(multilineFields[i].Trim()), multilineFields[i].Trim());
              }

              string address;
              IPropertySet addressProperties = new PropertySetClass();
              IPropertySet resultSet;
              IFeatureBuffer featureBuffer;
              object copyTo, copyFrom, key, value;

              // Get the name and value of all the properties in the property set
              fieldsToCopy.GetAllProperties(out copyTo, out copyFrom);
              string[] copyToArray = copyTo as string[];
              object[] copyFromArray = copyFrom as object[];
              string matchStatus = "U";

              // Populate the output feature class
              while (row != null)
              {
              featureBuffer = outputFeatureClass.CreateFeatureBuffer();
              foreach (KeyValuePair<int,string> entry in addressFieldIndexes)
              {
                  if (entry.Key != -1)
                      address = row.get_Value(entry.Key) as string;
                  else
                      address = row.get_Value(0) as string;

                  addressProperties.SetProperty(entry.Value, address);
              }

              resultSet = MatchAddress(addressProperties);

              // Get all of the fields and values of the result
              resultSet.GetAllProperties(out key, out value);
              string[] names = key as string[];
              object[] items = value as object[];

//.........这里部分代码省略.........
开发者ID:EsriUK,项目名称:dynamic-locator-sdk,代码行数:101,代码来源:LocatorWrapper.cs

示例14: FindFKey

        private string FindFKey(FeatureClassField[] theFkeys, IFeatureClass fc, out int fkeyIndex)
        {
            string theReturn = "";
            fkeyIndex = -1;
            IDataset theDataset = (IDataset)fc;

            foreach (FeatureClassField fcf in theFkeys)
            {
                if (fcf.FeatureClassName == theDataset.Name)
                {
                    fkeyIndex = fc.FindField(fcf.FieldName);
                    if (fkeyIndex == -1)
                        return "";
                    theReturn = fcf.FieldName;
                    break;
                }
            }

            return theReturn;
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:20,代码来源:DBUniqueValue.cs

示例15: InsertTopoError

        private bool InsertTopoError(IFeatureClass destFClass)
        {
            try
            {
                string strSQL = @"SELECT
                            b.CheckType,
                            IIF(b.TargetFeatClass1 is Null,'',b.TargetFeatClass1) as YSTC,
                            IIF(a.SourceBSM is Null,'',a.SourceBSM) as SourceBSM,
                            IIF(a.MBTC is Null,'',a.MBTC) as MBTC,
                            IIF(a.TargetBSM is Null,'',a.TargetBSM) as BSM2,
                            a.TPTC as TopoLayerName,
                            a.Reason as Description,
                            a.IsException as IsException,
                            IIf(a.Remark is Null,'',a.Remark) as Remark,
                            b.GZBM ,
                            a.ArcGisRule as ArcGisRule,
                            a.JHLX as JHLX,
                            a.SourceLayerID,
                            a.TargetLayerID,
                            a.SourceOID as OID,
                            a.TargetOID as OID2
                            from LR_ResAutoTopo as a, LR_ResultEntryRule as b where a.RuleInstID=b.RuleInstID
                            ";

                DataTable dtError = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(this.ResultConnection, strSQL);

                IFeatureCursor fCusorInsert = destFClass.Insert(false);
                Dictionary<int, int> dictFieldIndex = new Dictionary<int, int>();
                for (int i = 0; i < m_FieldCaptions.Count; i++)
                {
                    dictFieldIndex.Add(i,destFClass.FindField(m_FieldCaptions[i]));
                }
                int xFieldIndex = destFClass.FindField("X����");
                int yFieldIndex = destFClass.FindField("Y����");

                IErrorFeatureContainer errFeatureContainer = this.Topology as IErrorFeatureContainer;
                ISpatialReference spatialRef = (this.Topology as IGeoDataset).SpatialReference;
                for (int i = 0; i < dtError.Rows.Count; i++)
                {
                    DataRow rowError = dtError.Rows[i];
                    int fClassID = Convert.ToInt32(rowError["SourceLayerID"]);
                    int fClassID2 = Convert.ToInt32(rowError["TargetLayerID"]);
                    int oid = Convert.ToInt32(rowError["OID"]);
                    int oid2 = Convert.ToInt32(rowError["OID2"]);
                    esriGeometryType geoType = (esriGeometryType)Convert.ToInt32(rowError["JHLX"]);
                    esriTopologyRuleType ruleType = (esriTopologyRuleType)Convert.ToInt32(rowError["ArcGISRule"]);

                    IFeature srcFeature = errFeatureContainer.get_ErrorFeature(spatialRef, ruleType, geoType, fClassID, fClassID2, oid, oid2) as IFeature;

                    IFeatureBuffer fNew = destFClass.CreateFeatureBuffer();
                    for (int j = 0; j < m_FieldCaptions.Count; j++)
                    {
                        int fIndex = dictFieldIndex[j];
                        if (fIndex < 0)
                            continue;

                        fNew.set_Value(fIndex, rowError[j]);
                    }
                    fNew.Shape = GetErrorGeometry(srcFeature);
                    IPoint point = fNew.Shape as IPoint;
                    fNew.set_Value(xFieldIndex, point.X);
                    fNew.set_Value(yFieldIndex, point.Y);

                    fCusorInsert.InsertFeature(fNew);

                    if (i % 2000 == 0)
                        fCusorInsert.Flush();

                }

                fCusorInsert.Flush();

                return true;
            }
            catch(Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
                return false;
            }
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:80,代码来源:ErrorExporter.cs


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