Returns the count of the rows that meet the query filter selection criteria for the specified table.
[Visual Basic .NET] Public Function QueryRowCount ( _ ByVal MapName As String, _ ByVal pTableDescription As IMapTableDescription, _ ByVal pFilter As IQueryFilter _ ) As Integer
[C#] public int QueryRowCount ( string MapName, IMapTableDescription pTableDescription, IQueryFilter pFilter );
[C++]
HRESULT QueryRowCount(
BSTR MapName,
IMapTableDescription* pTableDescription,
IQueryFilter* pFilter,
long* pCount
);
[C++]Parameters
MapName [in] MapName is a parameter of type BSTR pTableDescription [in]pTableDescription is a parameter of type IMapTableDescription
pFilter [in]pFilter is a parameter of type IQueryFilter
pCount [out, retval] pCount is a parameter of type long
Product Availability
Remarks
QueryRowCount returns the number of map features from a layer or of row from a table that match the parameters of a given query filter.
QueryRowCount requires a number of input parameters. These include: a MapName, IMapTableDescription and a IQueryFilter.
LayerDescription for a layer can be obtained from MapServerInfo::DefaultMapDescription while StandaloneTableDescription can be obtained using MapServerInfo::StandaloneTableDescriptions property.
QueryFilter
QueryFilter provides the ability to query based on attribute filter (SQL expression), a spatial filter, time filter, a combination of both or null. Attribute filters take any valid non-GIS data specific SQL statement. For example, CNTRY_CODE = BD or POPULATION = 12345. Syntax for querying date fields depend on the underlying data. If you are working with Shapefile or File GeoDatabase data the syntax is <FieldName> = date YYYY-MM-DD; for Access-based Personal GeoDatabase the sytax is #YYYY-MM-DD#. For SDE database, check with the specific databases help.
TimeQueryFilter
When a layer is time aware (use IMapTableTimeInfo::SupportsTime property), a query can be made to retrieve a set of features that are available at a specific time or for a period of time. In order to perform a time query, TimeQueryFilter object needs to created and passed in to this function. Since the object implements IQueryFilter and ISpatialFilter interfaces, an attribute or spatial query can be combined with time.
SearchShape
Geometry set in ISpatialFilter should meet the following criteria:
- It should have the Spatial Reference System defined. In cases where it is not defined, the coordinate system is assumed to be in DataFrames coordinate system
- It must be one of the high-level geometries i.e. Point, Multipoint, Polyline, Polygon or Multipatch. Low-level geometry e.g. BezierCurve, CircularCurve must be wrapped into a high-level geometry
- It must be topologically correct. For more information, see help on IPolygon and ITopologicalOperator::Simplify .
DefinitionExpressions
A DefinitionExpression can be set on a layer in order to limit layer features available for display or query. This expression can be also be set in the source map document as a definition query. Any DefinitionExpression set in the LayerDescription will override any definition query set in the source map. MapServer QueryFeatureCount2 honors DefinitionExpression.
Let's look at some examples. You have a layer in your map that represents sales regions. The layer includes fields REGIONS, SALES and MANAGER.
Example #1: In the source map the layer has a definition query, "REGION = 'North'". No DefintionExpression is specified in LayerDescription. Your QueryFilter where clause is "MANAGER = 'Bob'". The result will be a count of all sale region features that fall within the North region and are managed by Bob.
Example #2: In the source map the layer has a definition query, "REGION = 'North'". You apply a DefinitionExpression in LayerDescription as "SALES > 1000". Your QueryFilter where clause is "MANAGER = 'Bob'". The result will be a count of all sale region features with sales over 1000 and are managed by Bob. QueryFeatureCount2 honors the DefinitionExpression set in LayerDescription. The DefinitionExpression overrides the definition query set in the source map. If you wish to include the layer's original defintion query, "REGION = 'North'" in your final query, you must include this in your QueryFilter, ""MANAGER = 'Bob' AND "REGION = 'North'".
Example #3: In the source map the layer has no definition query. You apply a DefinitionExpression in LayerDescription as "SALES > 1000". Your QueryFilter where clause is "MANAGER = 'Bob'". The result will be a count of all sale region features with sales over 1000 and are managed by Bob. QueryFeatureCount2 honors the DefinitionExpression set in LayerDescription.
Miscellaneous
MaxRecordCount does not affect QueryRowCount.