These parameters provide attribute, spatial, and temporal criteria that you can use to filter features. You can define attribute criteria using a standard SQL expression based on the available attribute fields, spatial criteria using a geometry and a spatial relationship (such as within, contains, intersect), or temporal filters using a single date/time, or a range. You can also control how the results are sorted and whether to return geometry.
In addition to querying features in a table, you can also use these parameters to count specific features,
calculate the extent of features, select features in layers, and populate service-based tables. If the query
method produces a set of features, they are returned in a FeatureQueryResult
.
Different query parameter objects are available to query data sources such as related features
(RelatedQueryParameters
), statistical information (StatisticsQueryParameters
), and portals
(PortalQueryParameters
). Specialized query parameters also exist for working
with utility networks and routing.
- Since:
- 100.0.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Represents the field the results are sorted by, and the sort order.static enum
Represents the order in which results of a query are sorted.static enum
Defines the spatial relationship between thegeometry
set on QueryParameters and the geometry of a feature table's feature. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the geometry used to filter the results.Gets the spatial reference of the set geometry.double
Gets the maximum allowable offset used for generalizing geometries returned by the query operation.int
Gets the maximum number of features the query should return.Gets a mutable list of object IDs of the features to be queried.Gets the fields by which query results will be ordered.Gets the spatial reference of the feature results' geometry.int
Gets the offset of results to fetch.Gets the spatial relationship that (along with thegetGeometry()
) defines features to be included in the query.Gets a span of time used to query features in a time-aware feature layer.Gets the attribute expression that defines features to be included in the query.boolean
True if geometry values are returned in the results, otherwise false.void
setGeometry
(Geometry geometry) Sets the geometry used to filter the results.void
setMaxAllowableOffset
(double maxAllowableOffset) Sets the maximum allowable offset used for generalizing geometries returned by the query operation.void
setMaxFeatures
(int maxFeatures) Sets the maximum number of features the query should return.void
Sets the spatial reference of the feature results' geometry.void
setResultOffset
(int resultOffset) Sets the starting offset of results to fetch.void
setReturnGeometry
(boolean returnGeometry) True if geometry values are returned in the results, otherwise false.void
setSpatialRelationship
(QueryParameters.SpatialRelationship spatialRelationship) Sets the spatial relationship that (along with thesetGeometry(Geometry)
) defines features to be included in the query.void
setTimeExtent
(TimeExtent timeExtent) Sets a span of time used to query features in a time-aware feature layer.void
setWhereClause
(String whereClause) Sets the attribute expression that defines features to be included in the query.
-
Constructor Details
-
QueryParameters
public QueryParameters()Creates a new instance.- Since:
- 100.0.0
-
-
Method Details
-
getWhereClause
Gets the attribute expression that defines features to be included in the query.The where clause should follow standard SQL syntax similar to that discussed in the document SQL reference for query expressions used in ArcGIS
If the where clause includes dates, they must be correctly formatted based on the geodatabase datasource used in the service. Refer to Dates and time for date formats expected by different data sources.
ArcGISFeatureTable
objects expect that anyField.Type.GLOBALID
orField.Type.GUID
parameters in the where clause are formatted as: '{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}'. All characters are uppercase, wrapped in curly braces and surrounded by single quotes.If the where clause is used to populate an
OgcFeatureCollectionTable
, you can use a CQL2-TEXT or CQL2-JSON string as defined in the document OGC API - Features - Part3.- Returns:
- the attribute expression that defines features to be included in the query
- Since:
- 100.0.0
- See Also:
-
setWhereClause
Sets the attribute expression that defines features to be included in the query.The where clause should follow standard SQL syntax similar to that discussed in the document SQL reference for query expressions used in ArcGIS
If the where clause includes dates, they must be correctly formatted based on the geodatabase datasource used in the service. Refer to Dates and time for date formats expected by different data sources.
ArcGISFeatureTable
objects expect that anyField.Type.GLOBALID
orField.Type.GUID
parameters in the where clause are formatted as: '{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}'. All characters are uppercase, wrapped in curly braces and surrounded by single quotes.If the where clause is used to populate an
OgcFeatureCollectionTable
, you can use a CQL2-TEXT or CQL2-JSON string as defined in the document OGC API - Features - Part3.- Parameters:
whereClause
- the attribute expression that defines features to be included in the query- Since:
- 100.0.0
- See Also:
-
getGeometry
Gets the geometry used to filter the results.The geometry that (along with the
getSpatialRelationship()
) defines features to be included in the query.- Returns:
- the geometry used to filter the results, or null if none
- Since:
- 100.0.0
-
setGeometry
Sets the geometry used to filter the results.The geometry that (along with the
getSpatialRelationship()
) defines features to be included in the query.- Parameters:
geometry
- the geometry used to filter the results- Since:
- 100.0.0
-
getSpatialRelationship
Gets the spatial relationship that (along with thegetGeometry()
) defines features to be included in the query.The default spatial relationship is
QueryParameters.SpatialRelationship.INTERSECTS
.- Returns:
- the spatial relationship that (along with the
QueryParameters.getGeometry()
) defines features to be included in the query. - Since:
- 100.0.0
-
setSpatialRelationship
Sets the spatial relationship that (along with thesetGeometry(Geometry)
) defines features to be included in the query.The default spatial relationship is
QueryParameters.SpatialRelationship.INTERSECTS
.- Parameters:
spatialRelationship
- the spatial relationship that (along with theQueryParameters.setGeometry()
) defines features to be included in the query.- Throws:
IllegalArgumentException
- if input is null- Since:
- 100.0.0
-
getOutSpatialReference
Gets the spatial reference of the feature results' geometry.If not specified, geometries are returned in the spatial reference of the service.
- Returns:
- the spatial reference of the feature results' geometry, or null if none
- Since:
- 100.0.0
-
setOutSpatialReference
Sets the spatial reference of the feature results' geometry.If not specified, geometries are returned in the spatial reference of the service.
- Parameters:
outSR
- the spatial reference of the feature results' geometry reference is same as the spatial reference of the input geometry.- Since:
- 100.0.0
-
getInSpatialReference
Gets the spatial reference of the set geometry.- Returns:
- the spatial reference of the set geometry. If no geometry is set, then null.
- Since:
- 100.0.0
-
setReturnGeometry
public void setReturnGeometry(boolean returnGeometry) True if geometry values are returned in the results, otherwise false.This is needed when you want to display the features on a map or a scene. When querying non-spatial data, results do not include geometry.
- Parameters:
returnGeometry
- true if geometry values are returned in the results, otherwise false- Since:
- 100.0.0
-
isReturnGeometry
public boolean isReturnGeometry()True if geometry values are returned in the results, otherwise false.This is needed when you want to display the features on a map or a scene. When querying non-spatial data, results do not include geometry.
- Returns:
- true if geometry values are returned in the results, otherwise false
- Since:
- 100.0.0
-
getObjectIds
Gets a mutable list of object IDs of the features to be queried. By default this list is empty. Add to this list to query for an object ID.- Returns:
- the object IDs of the features to be queried
- Since:
- 100.0.0
-
getOrderByFields
Gets the fields by which query results will be ordered.Results can be sorted by one or more fields. Each
QueryParameters.OrderBy
instance includes a field name and whether to sort by that field in ascending or descending order. If a service-based table is being queried it must support advanced queries.- Returns:
- the fields by which query results will be ordered
- Since:
- 100.0.0
-
setMaxFeatures
public void setMaxFeatures(int maxFeatures) Sets the maximum number of features the query should return. If 0, then there is no limit set on the number of features.For consistent ordering of results when using pagination, provide a value for
getOrderByFields()
. Note that if you provide a maximum features value to support paging of results, you must also set agetResultOffset()
value. Otherwise, the result may contain local features in place of server features if they satisfy the query. To ensure strict paging of server features, specify both maximum features andQueryParameters.getResultOffset()
.- Parameters:
maxFeatures
- the maximum number of features to be included in the result- Throws:
IllegalArgumentException
- if input is less than 0- Since:
- 100.0.0
-
getMaxFeatures
public int getMaxFeatures()Gets the maximum number of features the query should return.For consistent ordering of results when using pagination, provide a value for
getOrderByFields()
. Note that if you provide a maximum features value to support paging of results, you must also set agetResultOffset()
value. Otherwise, the result may contain local features in place of server features if they satisfy the query. To ensure strict paging of server features, specify both maximum features andQueryParameters.getResultOffset()
.- Returns:
- the maximum number of features the query should return
- Since:
- 100.0.0
-
setResultOffset
public void setResultOffset(int resultOffset) Sets the starting offset of results to fetch. This is useful for paging through results.For consistent ordering of results when using pagination, you should also provide a value for the
getOrderByFields()
. Note that if you provide a result offset to support paging of results, you must also set agetMaxFeatures()
value. Otherwise, the result offset is ignored.- Parameters:
resultOffset
- the starting offset of results to fetch. This is useful for paging through results.- Since:
- 100.2.1
-
getResultOffset
public int getResultOffset()Gets the offset of results to fetch. This is useful for paging through results.For consistent ordering of results when using pagination, you should also provide a value for the
getOrderByFields()
. Note that if you provide a result offset to support paging of results, you must also set agetMaxFeatures()
value. Otherwise, the result offset is ignored.- Returns:
- the offset of results to fetch. This is useful for paging through results.
- Since:
- 100.2.1
-
setTimeExtent
Sets a span of time used to query features in a time-aware feature layer.You can apply a temporal filter on any
FeatureLayer
that supports time filtering (FeatureLayer.isTimeFilteringSupported()
). Set theTimeExtent.getStartTime()
andTimeExtent.getEndTime()
to query features across a span of time. A single point in time can be queried by setting them to the same time value. By default, this value is null and no time criteria is applied by the query.- Parameters:
timeExtent
- a span of time used to query features in a time-aware feature layer- Since:
- 100.3.0
-
getTimeExtent
Gets a span of time used to query features in a time-aware feature layer.You can apply a temporal filter on any
FeatureLayer
that supports time filtering (FeatureLayer.isTimeFilteringSupported()
). Set theTimeExtent.getStartTime()
andTimeExtent.getEndTime()
to query features across a span of time. A single point in time can be queried by setting them to the same time value.By default, this value is null and no time criteria is applied by the query.
- Returns:
- a span of time used to query features in a time-aware feature layer, or null if none
- Since:
- 100.3.0
-
getMaxAllowableOffset
public double getMaxAllowableOffset()Gets the maximum allowable offset used for generalizing geometries returned by the query operation. The default is 0. If 0 is specified the value is not passed to the server in the query operation. The offset is in the units of theoutSpatialReference
. If an outSpatialReference is not defined, the spatial reference of the service is used.- Returns:
- the maximum allowable offset
- Since:
- 100.4.0
-
setMaxAllowableOffset
public void setMaxAllowableOffset(double maxAllowableOffset) Sets the maximum allowable offset used for generalizing geometries returned by the query operation. The default is 0. If 0 is specified the value is not passed to the server in the query operation. The offset is in the units of theoutSpatialReference
. If an outSpatialReference is not defined, the spatial reference of the service is used.- Parameters:
maxAllowableOffset
- the maximum allowable offset- Since:
- 100.4.0
-