When adding a FeatureLayer to the map, is it possible to filter out features with invalid geometries (e.g., using a definitionExpression, or via some other technique)?
We have an point feature layer we are trying to add to our map where one of the records has the latitude and longitude mixed up, resulting in an invalid geometry (latitude outside web mercator bounds). This feature layer is managed by another group, and it may take a while for them to fix it on their end. In the meantime, this layer is causing issues in our app.
The issue we are seeing is that calling layerView.queryFeatures with any sort of geometry query always returns an empty result when in SceneView (3D). If we use definitionExpression to manually filter out the problematic record by OBJECTID, then querying the layer view works fine. However, we can't rely on OBJECTID since the layer gets updated frequently. If possible, we would like to just filter out all records with invalid geometry, since that seems to be the root cause.
FYI, we are using ArcGIS JS SDK v4.28.10. Stepping through the minified framework code, it appears the pooled R-Bush spatial index does not get built property if there is any record with invalid geometry (minX, minY, maxX, maxY are all NaN).
Yes, you can use a RequestInterceptor to examine the results from the server before they get delivered to the layer. In that process, you can remove any features with an invalid geometry from the array.
Some other threads where this intercept-and-modify process is discussed can be found here and here.