ESRI.ArcGIS.ADF.IMS
GetFeatureCount(Filter,SelectionBuffer,Envelope) Method
See Also  Example
ESRI.ArcGIS.ADF.IMS.Carto.Layer Namespace > FeatureLayer Class > GetFeatureCount Method : GetFeatureCount(Filter,SelectionBuffer,Envelope) Method




queryFilter
Filter that defines the attribute and spatial criteria for the query.
selectionBuffer
Buffer to be applied to features found with the filter. May be null (Nothing).
globalEnvelope
Envelope that surrounds all features found with the query, including any selection buffer.
A function that returns the number of features in a query.

Syntax

Visual Basic (Declaration) 
Public Overloads Function GetFeatureCount( _
   ByVal queryFilter As Filter, _
   ByVal selectionBuffer As SelectionBuffer, _
   ByRef globalEnvelope As Envelope _
) As Integer
Visual Basic (Usage)Copy Code
Dim instance As FeatureLayer
Dim queryFilter As Filter
Dim selectionBuffer As SelectionBuffer
Dim globalEnvelope As Envelope
Dim value As Integer
 
value = instance.GetFeatureCount(queryFilter, selectionBuffer, globalEnvelope)
C# 
public int GetFeatureCount( 
   Filter queryFilter,
   SelectionBuffer selectionBuffer,
   out Envelope globalEnvelope
)

Parameters

queryFilter
Filter that defines the attribute and spatial criteria for the query.
selectionBuffer
Buffer to be applied to features found with the filter. May be null (Nothing).
globalEnvelope
Envelope that surrounds all features found with the query, including any selection buffer.

Return Value

The number of features that would be returned from the query on the layer.

Example

This example gets the count of features that match a query, and also gets the envelope around the features. It assumes an existing feature layer and a label control.
C#Copy Code
// Create a filter for the query - where clause in constructor 

Filter filter = new Filter("POPULATION > 100000"); 

  

// Declare envelope for out parameter 

Envelope env = null; 

  

// Get feature count - using previously retrieved layer object; no selection buffer 

int featureCount = myLayer.GetFeatureCount(filter, null, env); 

  

// Display results - assume Label1 is a label control on page 

Label1.Text = featureCount.toString() + " features found.<br>" + 

    "Envelope of features: min x = " + String.Format("{0:#0.00}", env.XMin) 

    + ", min y = " + String.Format("{0:#0.00}", env.YMin) 

    + ", max x = " + String.Format("{0:#0.00}", env.XMax) 

    + ", max y = " + String.Format("{0:#0.00}", env.YMax) 

    
Visual BasicCopy Code
' Create a filter For the query - where clause In constructor

Dim filter As New Filter("POPULATION > 100000")



' Declare envelope For out parameter

Dim env As Envelope = null



' Get feature count - using previously retrieved layer Object; no selection buffer

Dim featureCount As Integer = myLayer.GetFeatureCount(filter, null, env);



' Display results - assume Label1 Is a label control On page

Label1.Text = featureCount.toString() + " features found.<br>" + _

    "Envelope of features: min x = " + String.Format("{0:#0.00}", env.XMin) _

    + ", min y = " + String.Format("{0:#0.00}", env.YMin) _

    + ", max x = " + String.Format("{0:#0.00}", env.XMax) _

    + ", max y = " + String.Format("{0:#0.00}", env.YMax)

Remarks

This form of GetFeatureCount is used to retrieve both the number of features satisfying the query, as well as the envelope that surrounds all features that satisfy the query.

This method does not actually return any records. If you need features returned, use Query().

The queryFilter parameter defines the selection on the layer. It can contain attribute and spatial criteria, including a buffer around user-supplied geometry. If no features are found with the queryFilter, then this method will return zero. The selectionBuffer will expand the selection to include an area surrounding any features found with the queryFilter.

See Also

© 2010 All Rights Reserved.