mhamsa

Executing a Spatial Query on a Feature Layer

Discussion created by mhamsa on Jul 26, 2019
Latest reply on Jul 31, 2019 by mhamsa

Hello,

 

I was wondering if there were any good examples that would show me how to execute a QueryFeaturesAsync call on a FeatureTable using a SpatialRelationship of Within. I've got some code wired up but it doesn't seem to be returning any results, when I know there should be.

 

Here's the code I'm currently using. An exception is getting caught - no elements in this sequence when I try to get the First item from the query results.

 

                QueryParameters qp = new QueryParameters();
                qp.Geometry = new Envelope(Location, Radius, Radius);
                qp.SpatialRelationship = SpatialRelationship.Within;
                var table = layer.FeatureTable as GeodatabaseFeatureTable;
                try
                {
                    FeatureQueryResult queryResult = await table.QueryFeaturesAsync(qp);
                    Feature ftr = queryResult.First();
                }
                catch (Exception ex)
                {
                    string m = ex.Message;
                }

 

Thanks,

Mike...

Outcomes