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 <SPAN class="operator token">=</SPAN> ShapefileTable<SPAN class="punctuation token">.</SPAN><SPAN class="token function">OpenAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">@"C:\Polygon.shp"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>Result<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN>
<SPAN class="keyword token">public</SPAN> Feature <SPAN class="token function">GetFeatureAt</SPAN><SPAN class="punctuation token">(</SPAN>FeatureTable featureTable<SPAN class="punctuation token">,</SPAN> MapPoint point<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
SpatialQueryFilter spatialQueryFilter <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">SpatialQueryFilter</SPAN>
<SPAN class="punctuation token">{</SPAN>
Geometry <SPAN class="operator token">=</SPAN> point<SPAN class="punctuation token">,</SPAN>
SpatialRelationship <SPAN class="operator token">=</SPAN> SpatialRelationship<SPAN class="punctuation token">.</SPAN>Within
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> features <SPAN class="operator token">=</SPAN> featureTable<SPAN class="punctuation token">.</SPAN><SPAN class="token function">QueryAsync</SPAN><SPAN class="punctuation token">(</SPAN>spatialQueryFilter<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>Result<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> features<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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