AnsweredAssumed Answered

Method Contains of IRelationalOperator doesn't work well

Question asked by smunoz on Jan 11, 2012
Latest reply on Jan 12, 2012 by sshetty
Hello everyone,

I belong to a company which has bought a license for ArcGIS. We are still learning how to use it, and I have a problem with Contains method. I have a simple polygon and a point, created like this:

            //Create the centroid of the arc
            IPoint tempPoint = new PointClass();
            tempPoint.PutCoords(x, y);

            //Create an arc with given radius
            ICircularArc pConstructCArc = new CircularArcClass();
            pConstructCArc.PutCoordsByAngle(tempPoint, fromAngle, centralAngle, radius);
            ILine line = new LineClass();
            line.PutCoords(tempPoint, pConstructCArc.ToPoint);
            
            //Add the arc segment to a polygon geometry
            ISegmentCollection pSegmentCollection = new PolygonClass();
            pSegmentCollection.AddSegment((ISegment)line, ref missing, ref missing);
            pSegmentCollection.AddSegment((ISegment)pConstructCArc, ref missing, ref missing);
            PolygonClass pPolygon = (PolygonClass)pSegmentCollection;
            pPolygon.Close();
            pPolygon.SpatialReference = map.SpatialReference;

            IPoint target = new PointClass();
            target.PutCoords(i, j);
            
            if (pPolygon.Contains(target))
            {
                 //Do whatever
            }


I am pretty sure that the point is contained into the polygon, because I have painted both of them, and the result is this:

[ATTACH=CONFIG]11076[/ATTACH]

However, Contains method is always returning false, even I have created a simple triangle like this:

[ATTACH=CONFIG]11079[/ATTACH]

And it still returns false. Am I doing anything wrong?

Thank you very much!

Attachments

Outcomes