usman.jamil

Overlay / Overlap Query

Discussion created by usman.jamil on May 19, 2012
Dear All,

i am using the following code to find the overlapping ( or duplicate) points in the same layer. can u kindly check if the code is correct logically?? will the code return me the "OBJECTID" of the overlapping points?? i have tested the code, but i'm not getting the desired results. would appreciate your help. Thanx

     string s = "";
            IMap pMap = axMapControl1.Map;          
           
            for (int i = 0; i < pMap.LayerCount; i++)
            {
                ILayer pLayer = pMap.get_Layer(i);
                IFeatureLayer pfLayer = (IFeatureLayer)pLayer;
                IFeatureClass pfClass = pfLayer.FeatureClass;
                IFeature pFeature1;
                IPoint pPoint;
                IFeatureCursor pfCursor1;
               
                pfCursor1 = pfClass.Update(null, false);
                pFeature1 = pfCursor1.NextFeature();

                double x = 0;
                double y = 0;
                while (pFeature1 != null)
                {
                    pPoint = (IPoint)pFeature1.Shape;
                   
                    if (pPoint.X == x & pPoint.Y == y)
                    {
                        int fieldIndexNAME = pfClass.FindField("OBJECTID");
                        s += pLayer.Name + " " + pFeature1.get_Value(fieldIndexNAME) + Environment.NewLine;                       
                    }
                   
                    x = pPoint.X;
                    y = pPoint.Y;
                    pFeature1 = pfCursor1.NextFeature();
                }               
            }
            StreamWriter writer = new StreamWriter("D:\\test.txt");
            writer.WriteLine(s);
            writer.Close();
            axMapControl1.Refresh();

Outcomes