bturler

Inaccurate results when using esriSpatialRelContains filter

Discussion created by bturler on May 10, 2010
Latest reply on May 15, 2010 by skutz
I have an application that lets users draw a shape on a map and then filters a feature class according to which features are contained by the shape. This works well for drawing a polygon, but gives inaccurate result for the processing behind my circle tool.

Both tools use the IRubberBand interface. The  polygon tool does simply this to create the geometry:

            IRubberBand rubberPoly = new RubberPolygonClass();
            //Return a new polygon from the tracker object using TrackNew
            poly = (IPolygon)rubberPoly.TrackNew(activeView.ScreenDisplay, null);

The circle has additional processing to create a polygon:

            IRubberBand rubberCircle = new RubberCircleClass();
            IGeometry circle = rubberCircle.TrackNew(activeView.ScreenDisplay, null);
            ISegment segment = circle as ISegment;
            ISegmentCollection polygon = new PolygonClass();
            object Missing = Type.Missing;
            polygon.AddSegment(segment, ref Missing, ref Missing);

I do notice that at this point the geometries differ with regard to their Spatial Reference - the polygon has the same Spatial Reference as the map, the circle has a null Spatial Reference. I don't know if this is relevant.

Further processing is common to both tools. I use the Spatial Reference Factory to create a spatial reference based on a prj file, then project the geometries to that reference:

mSpRef = pSpRefFactory.CreateESRISpatialReferenceFromPRJFile(prjPath);

//this is because the circle has a null Sp Ref - so tried setting it to that of the map to start with
if (mGeom.SpatialReference == null)
{
       mGeom.SpatialReference = mMap.SpatialReference;
}

mGeom.Project(mSpRef);


The feature class is populated by the result of a query on our database, with coordinates corresponding to the coordinate system in the file in prjpath above. If I plot the individual features on the map, the results are very accurate.

The results of the polygon/circle tool operations are as follows: the polygon tool returns an accurate set of features contained by the geometry. The circle tool overreports features, i.e. nearby features are included when they are close to, but not inside the circle.

I would appreciate any suggestion on what I may be able to do to correct this.

Outcomes