AnsweredAssumed Answered

Wrong attributes when executing query on shapefile

Question asked by haukestieler on Nov 20, 2017
Latest reply on Nov 20, 2017 by MBranscomb-esristaff

Dear esri community,

 

we have the following problem searching for a feature at a certain map position:

 

We load a shapefile with ShapefileTable.OpenAsync and save its content in a FeatureTable variable. The shapefile contains a large number of features with Geometry which do not overlap.
Later, in a method in a different class, we use QueryAsync with a SpatialQueryFilter to find the feature at a certain MapPoint:

 

FeatureTable shapefile = ShapefileTable.OpenAsync(@"C:\Polygon.shp").Result;

...

public Feature GetFeatureAt(FeatureTable featureTable, MapPoint point)
{
    SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter
    {
        Geometry = point,
        SpatialRelationship = SpatialRelationship.Within
    };

    var features = featureTable.QueryAsync(spatialQueryFilter).Result;

    return features.FirstOrDefault();
}

 

This works fine the first time after the shapefile was opened, but never again after that. We get the same seemingly random result with wrong feature attributes for any MapPoint each time we execute the query, but the geometry we get is always correct. As a workaround, reopening the file before each query works fine.

 

The exact same code where the same FeatureTable is loaded via an online FeatureService equally works without problem.

 

We use ArcGis .net runtime 10.2.5 and tried 10.2.7 as well. We tried running the code under Windows 7, 8 and 10 with the same results.

 

Does anyone have an idea why this error occurs or whether this might be an error in the Esri framework?

 

Regards,

Hauke Stieler

Outcomes