AnsweredAssumed Answered

Incorrect list of features in calling function

Question asked by schneider.barbara@gmx.ch on Sep 18, 2020
Latest reply on Sep 20, 2020 by RRuh-esristaff

I have a function that calls another (static) function which returns a list of features:

private Feature GetNextFeature(FeatureLayer featLayer, MapPoint point)
{
    await QueuedTask.Run(() =>
    {
        var featList = Utils.GetFeaturesThatIntersectPoint(point, featLayer);

        // Do some more with the feature list
        ....
    });
}

 

public static List<Feature> GetFeaturesThatIntersectPoint(MapPoint point, FeatureLayer featLayer)
{
    List<Feature> featList = new List<Feature>();

    // Create spatial query filter
    SpatialQueryFilter spatialFilter = new SpatialQueryFilter()
    {               
        FilterGeometry = point,
        SpatialRelationship = SpatialRelationship.Intersects,
    };
    // Query the feature layer
    using (RowCursor rowCursor = featLayer.Search(spatialFilter))
    {
        while (rowCursor.MoveNext())
        {
            Row row = rowCursor.Current;
            featList.Add((Feature)row);
        }
    }
    return featList;
}

In the method "GetFeaturesThatIntersectPoint", the feature list is correct. However, in the calling function "GetNextFeature", the features in the list are not the same any more. What am I doing wrong?

As a workaround, I don't return a list of features, but a list of oids (of the features). This list is correct.

Outcomes