ExecuteQueryAsync

This method returns all the features in a layer that have a specified attribute value. When a combined attribute and spatial query is required, an IGeometry parameter can be defined that filters the returned features by a selection area geometry in addition to the attribute value. When splitting a large query into multiple “sub-queries” using the NumOfFeatures parameter (to prevent excessively long response time), the FromDataSourceFeatureId parameter for each subsequent call to ExecuteQuery should be set equal to the ID of the last feature returned in the previous call.

ExecuteQueryAsync executes asynchronously, immediately returning an ITerraExplorerAsync80 object, thereby ensuring that control is promptly handed back to the calling function. The ITerraExplorerAsync80 object provides a callback-based mechanism similar to the JavaScript promise and the C# Task that offers the following functionality:

§   Allows for handling the various stages of the asynchronous operation, from tracking progress to managing rejection/error, and finally resolving the operation (using OnProgress, OnReject, and OnResolve respectively).

§   Upon resolution of the query, enables the passing of an IFeatures80, containing all the features returned by the attribute and spatial query, to the OnResolve callback.

If you want to execute synchronously, use ExecuteQuery instead.

Note:    When only a spatial query is required, “ExecuteSpatialQuery” can be called instead. Note that in addition to combining the spatial query with an attribute query, ExecuteQueryAsync also offers the advantage of performing the query without rendering. ExecuteSpatialQuery, on the other has the advantage of rendering all the data in the 3D Window. SeeExecuteSpatialQuery” for more information.

Note:    In Javascript, if you do not want to use an area filter, you can call ICreator80. GeometryCreator.CreatePolygonGeometry(null)) to create a null IGeometry object.

 

JavaScript

 

ExecuteQueryAsync(

       AttributeFilter,

       NumOfFeatures,

       FromDataSourceFeatureId,

       AreaFilter)

 

C#

 

ITerraExplorerAsync80 ExecuteQueryAsync(

       string AttributeFilter,

       int NumOfFeatures = -1,

       string FromDataSourceFeatureId = "",

       IGeometry* AreaFilter = null)

 

C++

 

HRESULT ExecuteQueryAsync(

       BSTR AttributeFilter,

       long NumOfFeatures,

       BSTR FromDataSourceFeatureId,

       IGeometry* AreaFilter,

       ITerraExplorerAsync80** pITerraExplorerObject)

Parameters

AttributeFilter

Any valid SQL WHERE clause that filters the layer’s features, thereby designating which of the layer’s features should be queried.

NumOfFeatures

The maximum number of features to return. This property can have a significant impact on the method’s execution speed.

FromDataSourceFeatureId

The ID of the first feature that should be returned. When splitting a large query into multiple “sub-queries” using the NumOfFeatures parameter (to prevent excessively long response time), the FromDataSourceFeatureId for each subsequent call to ExecuteQuery should be set equal to the ID of the last feature returned in the previous call.

AreaFilter

An IGeometry representing the polygon, multipolygon, or linear ring that designates which part of the layer should be selected (only layer features that are spatially related to the polygon/ multipolygon/ linear ring will be selected).  

Note:    In Javascript, if you do not want to use an area filter, you can call ICreator80. GeometryCreator.CreatePolygonGeometry(null)) to create a null IGeometry object.

Return Value

pITerraExplorerObject

An ITerraExplorerAsync80 object, which provides a callback-based mechanism similar to the JavaScript promise and the C# Task that offers the following functionality:

·          Allows for handling the various stages of the asynchronous operation, from tracking progress to managing rejection/error, and finally resolving the operation (using OnProgress, OnReject, and OnResolve respectively).

·          Upon resolution of the query, enables the passing of an IFeatures80, containing all the features returned by the attribute and spatial query, to the OnResolve callback.

Exceptions

See: HRESULT Return Values for a list of possible values returned by the HRESULT.