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


C# IFeatureClass.Search方法代码示例

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


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

示例1: FindValue

        public Dictionary<string,object> FindValue(IFeatureClass pFeatureClass, string keyName, string targetName)
        {
            //int keyFieldIndex = pFeatureClass.Fields.FindField(keyField);
            //int targetFieldIndex = pFeatureClass.Fields.FindField(targetField);
            //IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
            //IFeature pFeature;
            //while ((pFeature = pFeatureCursor.NextFeature()) != null)
            //{
            //    if (pFeature.Value[keyFieldIndex].ToString() == keyValue) break;

            //}
            //Marshal.ReleaseComObject(pFeatureCursor);
            //return pFeature == null ? null : pFeature.Value[targetFieldIndex];
            int keyFieldIndex = pFeatureClass.Fields.FindField(keyName);
            int targetFieldIndex = pFeatureClass.Fields.FindField(targetName);
            Dictionary<string,object> dic=new Dictionary<string, object>(pFeatureClass.FeatureCount(null));
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
            IFeature pFeature;
            while ((pFeature = pFeatureCursor.NextFeature()) != null)
            {
                if (!dic.ContainsKey(pFeature.Value[keyFieldIndex].ToString()))
                {
                    dic.Add(pFeature.Value[keyFieldIndex].ToString(), pFeature.Value[targetFieldIndex]);
                    
                }
            }
            Marshal.ReleaseComObject(pFeatureCursor);
            return dic;
        }
开发者ID:gaufung,项目名称:Accessibility,代码行数:29,代码来源:ShapeOp.cs

示例2: SearchContainFeat

 /// <summary>
 /// ��������ͼ�������ڵ�Ҫ��
 /// </summary>
 /// <param name="fc"></param>
 /// <param name="geo"></param>
 /// <returns></returns>
 public static IFeatureCursor SearchContainFeat(IFeatureClass fc, IGeometry geo)
 {
     ISpatialFilter pSpatialFilter = new SpatialFilterClass();
     pSpatialFilter.Geometry = geo;
     pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
     pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
     IFeatureCursor pfeatCursor = fc.Search(pSpatialFilter, false);
     return pfeatCursor;
 }
开发者ID:hijushen,项目名称:WindowDemo,代码行数:15,代码来源:ArcGisPublic.cs

示例3: SearchIntersectLineFeat

 /// <summary>
 /// ����Ҫ�ؼ����������ͼ���ཻ��Ҫ�أ��������α�
 /// </summary>
 /// <param name="LineFeatClass"></param>
 /// <param name="geo"></param>
 /// <returns></returns>
 public static IFeatureCursor SearchIntersectLineFeat(IFeatureClass LineFeatClass, IGeometry geo)
 {
     ISpatialFilter pSpatialFilter = new SpatialFilterClass();
     pSpatialFilter.Geometry = geo;
     pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
     pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
     IFeatureCursor pfeatCursor = LineFeatClass.Search(pSpatialFilter, false);
     return pfeatCursor;
 }
开发者ID:hijushen,项目名称:WindowDemo,代码行数:15,代码来源:ArcGisPublic.cs

示例4: QueryIntersectPoints

        public static Dictionary<int, List<IPoint>> QueryIntersectPoints(IPolyline line, IFeatureClass roadFC)
        {
            var cursor = roadFC.Search(new SpatialFilterClass { Geometry = line, SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects }, true);
            var topo = line as ITopologicalOperator;
            var rel = line as IRelationalOperator;
            var f = cursor.NextFeature();
            var dict = new Dictionary<int, List<IPoint>>();
            while(f!= null)
            {
                var shp = f.ShapeCopy;
                line.SpatialReference = shp.SpatialReference;
                var pc2 = shp as IPointCollection;
                var ret = topo.Intersect(shp, esriGeometryDimension.esriGeometry1Dimension);

                if (ret != null && ret.IsEmpty == false)
                {
                    dict.Add(f.OID, null);
                }
                else
                {
                    ret = topo.Intersect(shp, esriGeometryDimension.esriGeometry0Dimension);
                    if(ret is IPoint)
                    {
                        var pt = ret as IPoint;
                        if (IsStartOrEnd(pt, pc2) == false)
                        {
                            dict.Add(f.OID, new List<IPoint>(new[] { pt }));
                        }
                    }
                    else if(ret is IPointCollection)
                    {
                        var pc = ret as IPointCollection;
                        var list = new List<IPoint>();
                        for (var i = 0; i < pc.PointCount; i++)
                        {
                            if (IsStartOrEnd(pc.Point[i], pc2) == false)
                            {
                                list.Add(pc.Point[i]);
                            }
                        }
                        dict.Add(f.OID, list);
                    }
                    else
                    {
                        throw new NotSupportedException(string.Format("道路相交结果的类型‘{0}’不被支持", ret.GetType()));
                    }
                }
                f = cursor.NextFeature();
            }

            Marshal.ReleaseComObject(cursor);
            return dict;
        }
开发者ID:LooWooTech,项目名称:Traffic,代码行数:53,代码来源:RoadHelper.cs

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

示例6: returMatrizDataUnique

 public List<objetos> returMatrizDataUnique(IFeatureClass fc, string fld, string fld2)
 {
     int iFldIndex = fc.Fields.FindField(fld);
     int iFldIndex2 = fc.Fields.FindField(fld2);
     IFeatureCursor pFCursor = fc.Search(null, false);
     IFeature pFeature = default(IFeature);
     ArrayList col = new ArrayList();
     ArrayList col2 = new ArrayList();
     clsToys toy  = new clsToys();
     List<objetos> matriz = null;
     int i = 0;
     try
     {
         pFeature = pFCursor.NextFeature();
         while (!(pFeature == null))
         {
             col.Add(pFeature.get_Value(iFldIndex));
             col2.Add(pFeature.get_Value(iFldIndex2));
             if (i > 1)
                 if (col[i - 1].ToString() == col[i].ToString())
                 {
                     col.Remove(i);
                     col2.Remove(i);
                     i = i - 1;
                 }
             i = i + 1;
             pFeature = pFCursor.NextFeature();
         }
         if (i > 0)
             matriz = toy.eliminaDuplicadosM(col, col2);
         else
             toy.insertaDatosM("ERROR", "0", ref matriz);
         return matriz;
     }catch (System.Exception ex){
         MessageBox.Show("Error: " + ex.Message, "clsFeatureTools.returMatrizDataUnique");
         MessageBox.Show("Error: " + ex.StackTrace);
         return null;
     }
 }
开发者ID:gnro,项目名称:autoplanos,代码行数:39,代码来源:clsFeatureTools.cs

示例7: setFeatureClassFieldValue

 private void setFeatureClassFieldValue(IFeatureClass feacls, string strfield, int val)
 {
     if(feacls.FindField(strfield)<0)
     {
         IField field = new FieldClass();
         IFieldEdit fe = field as IFieldEdit;
         fe.Name_2 = strfield;
         fe.Type_2 = esriFieldType.esriFieldTypeInteger;
         feacls.AddField(field);
     }
     int index = feacls.FindField(strfield);
     IFeatureCursor cursor = feacls.Search(null, false);
     IFeature fea = cursor.NextFeature();
     while (fea != null)
     {
         fea.set_Value(index, val);
         fea.Store();
         fea = cursor.NextFeature();
     }
 }
开发者ID:weigiser,项目名称:AOProjects,代码行数:20,代码来源:PolygonsPartitionAggregation.cs

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

示例9: IntersectAll

        private bool IntersectAll(IFeatureClass lineLayer, IPolygon polygon2, List<ziduan> list)
        {
            try
            {
                if (radioBtnKJ.Checked && polygon2 != null)
                {
                    //  根据组合成的面裁剪压力等值线
                    SpatialFilterClass qfilter = new SpatialFilterClass();
                    qfilter.Geometry = polygon2;
                    qfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                    IFeatureCursor qfeatureCursor = lineLayer.Search(qfilter, false);

                    if (qfeatureCursor != null)
                    {
                        IFeature feature = qfeatureCursor.NextFeature();
                        IGeometryArray geometryArray = new GeometryArrayClass();
                        while (feature != null)
                        {
                            geometryArray.Add(feature.Shape);
                            feature = qfeatureCursor.NextFeature();
                        }

                        IGeometryServer2 geometryServer2 = new GeometryServerClass();
                        IGeometryArray geometryArray2 = geometryServer2.Intersect(polygon2.SpatialReference, geometryArray, polygon2);
                        //DataEditCommon.DeleteFeatureByWhereClause(lineLayer, "");
                        IFeatureLayer pFeatureLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, EditLayerName) as IFeatureLayer;
                        DataEditCommon.CreateFeature(pFeatureLayer.FeatureClass, geometryArray2, list);

                    }
                }
                return true;
            }
            catch
            { return false; }
        }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:36,代码来源:MakeContours.cs

示例10: CreateUniqueValueRenderer

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

      ICharacterMarkerSymbol charMarkersymbol = new CharacterMarkerSymbolClass();
      charMarkersymbol.Font = Converter.ToStdFont(new Font(new FontFamily("ESRI Default Marker"), 12.0f, FontStyle.Regular));
      charMarkersymbol.CharacterIndex = 96;
      charMarkersymbol.Size = 12.0;
      charMarkersymbol.Color = (IColor)color;


      IRandomColorRamp randomColorRamp = new RandomColorRampClass();
      randomColorRamp.MinSaturation = 20;
      randomColorRamp.MaxSaturation = 40;
      randomColorRamp.MaxValue = 85;
      randomColorRamp.MaxValue = 100;
      randomColorRamp.StartHue = 75;
      randomColorRamp.EndHue = 190;
      randomColorRamp.UseSeed = true;
      randomColorRamp.Seed = 45;

      IUniqueValueRenderer uniqueRenderer = new UniqueValueRendererClass();
      uniqueRenderer.FieldCount = 1;
      uniqueRenderer.set_Field(0, fieldName);
      uniqueRenderer.DefaultSymbol = (ISymbol)charMarkersymbol;
      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);

          charMarkersymbol = new CharacterMarkerSymbolClass();
          charMarkersymbol.Font = Converter.ToStdFont(new Font(new FontFamily("ESRI Default Marker"), 10.0f, FontStyle.Regular));
          charMarkersymbol.CharacterIndex = rand.Next(40, 118);
          charMarkersymbol.Size = 20.0;
          charMarkersymbol.Color = (IColor)color;

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

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

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

示例11: getMatchedRules

        private HashSet<string> getMatchedRules(IFeatureClass inputFeatureClass, string sidcFieldName)
        {
            HashSet<string> matchedRules = new HashSet<string>();

            if ((inputFeatureClass == null) || (mapper == null) || (!mapper.Initialized))
                return matchedRules; // = nothing

            IFeatureCursor featureCursor = inputFeatureClass.Search(null, true);
            if (featureCursor == null)
                return matchedRules; // = nothing

            IFeature currentFeature = featureCursor.NextFeature();
            if (currentFeature == null)
            {
                Console.WriteLine("No features in input Feature Class - ABORTING");
                return matchedRules; // = nothing
            }

            string geometryString = SicToFeatureClassMapper.POINT_STRING;

            if ((inputFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) ||
                (inputFeatureClass.ShapeType == esriGeometryType.esriGeometryMultipoint))
                geometryString = SicToFeatureClassMapper.LINE_STRING;
            else
                if (inputFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    geometryString = SicToFeatureClassMapper.AREA_STRING;

            int sicFieldIndex = currentFeature.Fields.FindField(sidcFieldName);

            if (sicFieldIndex < 0)
            {
                Console.WriteLine("SIDC field not found: {0} - ABORTING", sidcFieldName);
                return matchedRules;
            }

            while (currentFeature != null)
            {
                string sidc = currentFeature.get_Value(sicFieldIndex) as string;

                string matchingRule = mapper.RuleNameFromSymbolIdAndGeometry(sidc, geometryString);

                if (!((matchingRule == SicToFeatureClassMapper.NOT_FOUND) || (matchedRules.Contains(matchingRule))))
                    matchedRules.Add(matchingRule);

                currentFeature = featureCursor.NextFeature();
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
            featureCursor = null;
            currentFeature = null;

            Console.WriteLine("Applicable Rules:");
            foreach (string rule in matchedRules)
            {
                Console.WriteLine("   Rules: " + rule);
            }

            return matchedRules;
        }
开发者ID:rkBiswal,项目名称:military-feature-toolbox,代码行数:59,代码来源:MilitaryFeatureAppender.cs

示例12: convertFeatureToRaster

        public void convertFeatureToRaster(IFeatureClass InFeatureClass, string fldName)
        {
            ftrCls = InFeatureClass;
            ftrField = fldName;
            IDataset dSet = (IDataset)InFeatureClass;
            string outRsNm = dSet.BrowseName;
            wks = dSet.Workspace;
            if (vRs != null)
            {
                if (!checkProjectionsFtr())
                {
                    if (rd != null) rd.addMessage("Re-projecting feature class to match value raster's projection");
                    InFeatureClass = reprojectInFeatureClass(InFeatureClass, vRs.RasterInfo.SpatialReference);

                }
            }
            IWorkspace wksTemp = geoUtil.OpenRasterWorkspace(tempWksStr);
            IFunctionRasterDataset rs = rsUtil.createIdentityRaster(rsUtil.convertFeatureClassToRaster(InFeatureClass, rasterUtil.rasterType.IMAGINE, wksTemp, outRsNm, vRs.RasterInfo.CellSize.X, (IRasterDataset)vRs));
            rs = rsUtil.createIdentityRaster(rs, rstPixelType.PT_FLOAT);
            int fieldIndex = InFeatureClass.FindField(fldName);
            if(fieldIndex == -1)
            {
                fieldIndex = InFeatureClass.FindField(fldName + "_1");
            }
            if (fldName.ToLower() == InFeatureClass.OIDFieldName.ToLower()||fieldIndex == -1)
            {
                zRs = rs;
            }
            else
            {
                IRemapFilter rFilt = new RemapFilterClass();
                IFeatureCursor ftrCur = InFeatureClass.Search(null, false);
                IFeature ftr = ftrCur.NextFeature();

                while (ftr != null)
                {
                    double id = ftr.OID;
                    double nVl = System.Convert.ToDouble(ftr.get_Value(fieldIndex));
                    if (Double.IsNaN(nVl) || Double.IsInfinity(nVl))
                    {
                        ftr = ftrCur.NextFeature();
                    }
                    else
                    {
                        //Console.WriteLine("adding oid = " + id.ToString() + " and value = " + nVl.ToString());
                        rFilt.AddClass(id, id + 1, nVl);
                        ftr = ftrCur.NextFeature();
                    }
                }
                zRs = rsUtil.calcRemapFunction(rs, rFilt);
            }
        }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:52,代码来源:zonalHelper.cs

示例13: setFeatureClassFieldValue

 private void setFeatureClassFieldValue(IFeatureClass feacls,string strfield,int val)
 {
     IFeatureCursor cursor = feacls.Search(null, false);
     IFeature fea = cursor.NextFeature();
     while(fea!=null)
     {
         IFields fds = feacls.Fields;
         fea.set_Value(fds.FindField(strfield), val);
         fea.Store();
         fea = cursor.NextFeature();
     }
 }
开发者ID:weigiser,项目名称:LandPriceOnline,代码行数:12,代码来源:Aggregation.cs

示例14: populateOIDBox

 private void populateOIDBox(IFeatureClass featureClass)
 {
     IFeatureCursor featureCursor = featureClass.Search(new QueryFilterClass(), true);
     objectIDListBox.Items.Clear();
     IFeature feature = featureCursor.NextFeature();
     while (feature != null)
     {
         objectIDListBox.Items.Add(feature.OID.ToString());
         feature = featureCursor.NextFeature();
     }
     Marshal.FinalReleaseComObject(featureCursor);
 }
开发者ID:nohe427,项目名称:MyAddins,代码行数:12,代码来源:Form1.cs

示例15: FindStreets

        //Start the logic for finding the cross streets.
        public string FindStreets(IPoint point, IFeatureClass featureClass, int StreetField, string StreetName, string join)
        {
            ISpatialFilter pSFilter = new SpatialFilter();
            IFeatureCursor pFCursor;
            IFeature pFeature = default(IFeature);
            Collection<string> cValues = new Collection<string>();
            string sValue = null;
            string sResult = null;
            bool bFound = false;

            pSFilter.GeometryField = featureClass.ShapeFieldName;
            pSFilter.Geometry = point;
            pSFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

            pFCursor = featureClass.Search(pSFilter, false);
            pFeature = pFCursor.NextFeature();
            do
            {

                sValue = (string)pFeature.Value[StreetField];
                if (sValue != StreetName)
                {
                    bFound = false;
                    for(int i = 0; i <cValues.Count; i++)
                    {
                        if (sValue == cValues[i])
                        {
                            bFound = true;
                            break;
                        }
                    }


                    if (!bFound)
                    {
                        cValues.Add(sValue);
                        if (cValues.Count == 1)
                        {
                            sResult = sValue;
                        }
                        else
                        {
                            sResult = sResult + sJoin + sValue;
                        }
                    }
                }
                pFeature = pFCursor.NextFeature();

            } while (!(pFeature == null));

            return sResult;
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:53,代码来源:PopulateCrossStreetNames.cs


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