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


C# IFeatureClass.FeatureCount方法代码示例

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


在下文中一共展示了IFeatureClass.FeatureCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: overlapStandard

        private List<double> overlapStandard(IFeatureClass featureClass, string targetLayerName)
        {
            List<double> overlapList = new List<double>();
            IFeatureClass targetFeatureClass = GisUtil.getFeatureClass(mapFolder, targetLayerName);
            for (int i = 0; i < featureClass.FeatureCount(null); i++)
            {
                IFeature feature = featureClass.GetFeature(i);
                IGeometry geometry = feature.ShapeCopy;
                geometry.SpatialReference = mapControl.SpatialReference;
                ITopologicalOperator tpOp = geometry as ITopologicalOperator;
                IArea area = geometry as IArea;
                ISpatialFilter cityFilter = new SpatialFilterClass();
                cityFilter.Geometry = geometry;
                cityFilter.GeometryField = "SHAPE";
                cityFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                IFeatureCursor feaCursor = targetFeatureClass.Search(cityFilter, false);

                //获取所有与该块相交的要素, 然后检测其相交的面积, 依照比例计算最终的值.
                IFeature cityFea = feaCursor.NextFeature();
                double overlap = 0;
                while (cityFea != null)
                {
                    if (cityFea != null)
                    {
                        IGeometry intersectedGeom = tpOp.Intersect(cityFea.ShapeCopy, esriGeometryDimension.esriGeometry2Dimension);
                        IArea intersectedGeomArea = intersectedGeom as IArea;
                        //获取gridcode.
                        ITable table = cityFea.Table;
                        IRow row = table.GetRow(0);
                        int fieldNum = table.FindField("GRIDCODE");
                        double value = (double)cityFea.get_Value(fieldNum);
                        overlap = overlap + value * (intersectedGeomArea.Area / area.Area);
                    }
                    cityFea = feaCursor.NextFeature();
                }
                overlapList.Add(overlap);
            }
            return overlapList;
        }
开发者ID:wingzhangmaybe,项目名称:CGXM,代码行数:39,代码来源:SiteSelector.cs

示例3: distanceStandard

        private List<double> distanceStandard(IFeatureClass featureClass, string targetLayerName)
        {
            List<double> distanceList = new List<double>();
            IFeatureClass targetFeatureClass = GisUtil.getFeatureClass(mapFolder, targetLayerName);
            //将所有的geometry放入一个arraylist.
            List<IGeometry> geometryList = new List<IGeometry>();
            for (int i = 0; i < targetFeatureClass.FeatureCount(null); i++)
            {
                geometryList.Add(targetFeatureClass.GetFeature(i).ShapeCopy);
            }
            IGeometry geometry = GisUtil.unionAllFeature(geometryList);
            IProximityOperator proOp = geometry as IProximityOperator;

            //求到路的距离.
            for (int i = 0; i < featureClass.FeatureCount(null); i++)
            {
                IFeature fea = featureClass.GetFeature(i);
                IGeometry geom = fea.ShapeCopy;
                geom.SpatialReference = mapControl.SpatialReference;
                double distance = proOp.ReturnDistance(geom);
                distanceList.Add(distance);
            }
            return distanceList;
        }
开发者ID:wingzhangmaybe,项目名称:CGXM,代码行数:24,代码来源:SiteSelector.cs

示例4: IntersectRestraint

        private List<double> IntersectRestraint(IFeatureClass featureClass, string targetLayerName)
        {
            List<double> ratioList = new List<double>();
            IFeatureClass targetFeatureClass = GisUtil.getFeatureClass(mapFolder, targetLayerName);
            List<IGeometry> geometryList = new List<IGeometry>();
            for (int i = 0; i < targetFeatureClass.FeatureCount(null); i++)
            {
                geometryList.Add(targetFeatureClass.GetFeature(i).Shape);
            }
            IGeometry geometry = GisUtil.unionAllFeature(geometryList); //e0图层所有的几何图形.
            ITopologicalOperator toOp = geometry as ITopologicalOperator;

            for (int i = 0; i < featureClass.FeatureCount(null); i++)
            {
                IFeature feature = featureClass.GetFeature(i);
                IGeometry srcGeom = feature.ShapeCopy;
                srcGeom.SpatialReference = mapControl.SpatialReference;
                IGeometry intersectedGeom = toOp.Intersect(srcGeom, esriGeometryDimension.esriGeometry2Dimension);
                //测量相交图形的面积, 超过原图形的一半, 有效.
                IArea area = intersectedGeom as IArea;
                IArea srcArea = srcGeom as IArea;
                double ratio = (area.Area / srcArea.Area) * 100;
                ratioList.Add(ratio);
            }
            return ratioList;
        }
开发者ID:wingzhangmaybe,项目名称:CGXM,代码行数:26,代码来源:SiteSelector.cs

示例5: CreateFillerPolygon

        /// <summary>
        /// used by the GenerateFlatAreas and GenerateExcludedAreas logic to add in at least one polygon if their
        /// processes result in zero polygons being generated
        /// </summary>
        public static void CreateFillerPolygon(IFeatureClass ThisFeatureClass, int SurveyID, ref string ErrorMessage)
        {
            IFeatureCursor ThisFCursor;
            IFeatureBuffer ThisFBuffer;
            IQueryFilter ThisQueryFilter;
            IPolygon BoundarPoly;
            int SurveyIDIndex;

            ThisQueryFilter = new QueryFilterClass();
            ThisQueryFilter.WhereClause = "SurveyID=" + SurveyID;

            SurveyIDIndex = ThisFeatureClass.FindField("SurveyID");
            if (SurveyIDIndex == -1)
            {
                ErrorMessage = "Could not find SurveyID field in " + ((IDataset)ThisFeatureClass).Name + " FeatureClass.";
                return;
            }

            if (ThisFeatureClass.FeatureCount(ThisQueryFilter) > 0) return;

            BoundarPoly = Util.GetSurveyBoundary(Convert.ToString(SurveyID), ref ErrorMessage);
            if (string.IsNullOrEmpty(ErrorMessage) == false) return;

            try
            {
                BoundarPoly = Util.EnvelopeToPolygon(BoundarPoly.Envelope.UpperLeft.Envelope);

                ThisFCursor = ThisFeatureClass.Insert(true);
                ThisFBuffer = ThisFeatureClass.CreateFeatureBuffer();

                ThisFBuffer.Shape = BoundarPoly;
                ThisFBuffer.set_Value(SurveyIDIndex, SurveyID);

                ThisFCursor.InsertFeature(ThisFBuffer);
            }
            catch (Exception ex)
            {
                ErrorMessage = "Error occured while inserting filler shape for "
                    + ((IDataset)ThisFeatureClass).Name + " FeatureClass. " + ex.Message;
            }

            ThisFCursor = null;
        }
开发者ID:regan-sarwas,项目名称:NPSTransectTool,代码行数:47,代码来源:Utility.cs

示例6: FeatureCount

        /// <summary>
        /// count the number of features in a feature class
        /// </summary>
        public static int FeatureCount(IFeatureClass ThisFC, string WhereClause)
        {
            IQueryFilter ThisQF;

            ThisQF = new QueryFilterClass();
            ThisQF.WhereClause = WhereClause;

            try
            {
                return ThisFC.FeatureCount(ThisQF);
            }
            catch
            {
            }

            return -1;
        }
开发者ID:regan-sarwas,项目名称:NPSTransectTool,代码行数:20,代码来源:Utility.cs

示例7: GetFeaturesForInput

        public static int GetFeaturesForInput(IGPValue inputValue, out IFeatureClass inputFClass, out IFeatureCursor inputFeatures)
        {
            //
            // GET FEATURECURSOR RESPECTING SELECTION
            IGPUtilities gpUtils = new GPUtilitiesClass();
            int numFeatures = 0;
            IGeoFeatureLayer inputFLayer = null;

            if (inputValue is IDEFeatureClass)
            {
                // IF THE INPUT IS A FEATURECLASS THEN JUST OPEN THE DATASET AND
                // CREATE A FEATURE CURSOR OF ALL THE FEATURES AND RETURN THE TOTAL
                // NUMBER OF FEATURES IN THE FEATURECLASS
                inputFClass = (IFeatureClass)gpUtils.OpenDataset(inputValue);
                inputFeatures = inputFClass.Search(null, false);
                numFeatures = inputFClass.FeatureCount(null);
            }
            else
            {
                // IF THE INPUT IS A FEATURELAYER THEN OPEN THE FEATURELAYER
                // AND USE THE DISPLAYFEATURECLASS THAT RESPECTS JOINED FIELDS.
                inputFLayer = (IGeoFeatureLayer)gpUtils.OpenDataset(inputValue);
                inputFClass = inputFLayer.DisplayFeatureClass;
                IFeatureSelection inputSelection = (IFeatureSelection)inputFLayer;
                if (inputSelection.SelectionSet.Count > 0)
                {
                    // IF THE FEATURELAYER HAS A SELECTION THEN CREATE A FEATURECURSOR
                    // OF ALL THE SELECTED FEATURES AND RETURN THE NUMBER OF FEATURES
                    // IN THE SELECTION
                    ICursor selectionCursor = null;
                    inputSelection.SelectionSet.Search(null, false, out selectionCursor);
                    inputFeatures = (IFeatureCursor)selectionCursor;
                    numFeatures = inputSelection.SelectionSet.Count;
                }
                else
                {
                    // IF THE FEATURELAYER HAS NO SELECTION THEN CREATE A FEATURECURSOR
                    // USING THE DEFINITIONEXPRESSION OF THE LAYER AND RETURN THE NUMBER
                    // OF FEATURES BASED ON THE DEFINITIONEXPRESSION.
                    IFeatureLayerDefinition layerDef = (IFeatureLayerDefinition)inputFLayer;
                    IQueryFilter queryFilter = new QueryFilterClass();
                    queryFilter.WhereClause = layerDef.DefinitionExpression;
                    inputFeatures = inputFLayer.SearchDisplayFeatures(queryFilter, false);
                    numFeatures = inputFLayer.FeatureClass.FeatureCount(queryFilter);
                }
            }

            return numFeatures;
        }
开发者ID:ZerionSoftware,项目名称:iFormEsriIntegration,代码行数:49,代码来源:APLGPUtils.cs

示例8: updateAcetate

        public static void updateAcetate(SEE see, IFeatureClass featureClass, ISDUTExtension ext)
        {
            if(see == null)
            {
                return;
            }

            Logger.Write("Update acetate");
            IFeature feat = null;
            if(featureClass.FeatureCount(null) < 1)
            {
                feat = featureClass.CreateFeature();
                feat.Shape = see.Shape;
                feat.Store();
            }
            else
            {
                feat = featureClass.Update(null,false).NextFeature();
                feat.Shape = see.Shape;
                feat.Store();
            }
            Logger.Write("Update acetate -- Refresh");

            ((IActiveView)ext.FocusMap).Refresh();
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:25,代码来源:CmdNew.cs


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