yanasdf789

how to find  any two features whether Cover in One featureclass?

Discussion created by yanasdf789 on Oct 22, 2013
Latest reply on Oct 25, 2013 by agray1
i want to find  any two features whether Cover in One featureclass. the code as following,
it works ok,but if  the featureclass have  100000 features ,it work so slowly.
how  to make it fast by modify the code? thank  you

      public void CheckInOneLayer(IFeatureClass IChecklayer)
        {
          
            string Layername = IChecklayer.AliasName;
            int nn = 0;
            int count=IChecklayer.FeatureCount(null);
            IFeatureCursor IfeaCur = IChecklayer.Search(null, false);
            IFeature Ifea;
            while ((Ifea = IfeaCur.NextFeature()) != null)
            {
                nn++;
            

                GetFeature(Ifea, IChecklayer);
             
                
            }

            MessageBox.Show("finish!");

        }

        public void GetFeature(IFeature Mfeature, IFeatureClass IChecklayer)
        {
            try
            {
                string layername = IChecklayer.AliasName;
                IRelationalOperator pRelOperator;
                pRelOperator = Mfeature.Shape as IRelationalOperator;

                IFeatureCursor pFeatureCursor = IChecklayer.Search(null, false);
                IFeature pComFeature;
                while ((pComFeature = pFeatureCursor.NextFeature()) != null)
                {
                    if (pRelOperator.Overlaps(pComFeature.Shape))
                    {
                         //here get the feature!!!!!

                        //addToGrid(Mfeature, pComFeature, layername);

                    }

                }


                if (pFeatureCursor != null)
                {
                    Marshal.ReleaseComObject(pFeatureCursor);
                }
            }
            catch (Exception e)
            {

                MessageBox.Show("Error:"+e.Message.ToString());
            }

        }

Outcomes