AnsweredAssumed Answered

Topology: Overlapped Features

Question asked by shaningesri on Jul 18, 2017
Latest reply on Jul 19, 2017 by shaningesri

Below is a piece of code used in my program to determine if a polygon feature is overlapped with another polygon feature by referring to A feature overlapped with another feature 

        public bool feature_Intersect_feature(ESRI.ArcGIS.Geodatabase.IFeature f1, ESRI.ArcGIS.Geodatabase.IFeature f2) {
            // Create a geometrybag for f1
            ESRI.ArcGIS.Geometry.IGeometry geometryBag = new ESRI.ArcGIS.Geometry.GeometryBagClass();
            geometryBag = (ESRI.ArcGIS.Geometry.GeometryBag)f1.ShapeCopy;


            // set the topology operator
            ESRI.ArcGIS.Geometry.ITopologicalOperator pTopOp;
            pTopOp = (ESRI.ArcGIS.Geometry.ITopologicalOperator)f1.Shape; // new ESRI.ArcGIS.Geometry.PolygonClass();


            // set for f2
            ESRI.ArcGIS.Geometry.IGeometry5 pInGeometry = (ESRI.ArcGIS.Geometry.IGeometry5)f2.ShapeCopy;


            //ESRI.ArcGIS.Geometry.IGeometry pInGeometry = (ESRI.ArcGIS.Geometry.IGeometry)f2.ShapeCopy;
            if (pInGeometry.Dimension == ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension)  {
                if (f1.ShapeCopy.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) {
                    ESRI.ArcGIS.Geometry.IGeometry pOverlapGeometry = pTopOp.Intersect(pInGeometry,
                    if (pOverlapGeometry != null)
                        return true;
            return false;

However, when it is executed for 2 far-away and not interacted polygons, the returned result is true, which means they are interacted.  What is wrong in my code?  Thanks if you can point it out?