ESRI.ArcGIS.ADF.IMS
FeatureTable Class
Members  Example  See Also 
ESRI.ArcGIS.ADF.IMS.Carto.Layer Namespace : FeatureTable Class




Class that represents features on a FeatureLayer.

Object Model



Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class FeatureTable 
   Inherits DataTable
Visual Basic (Usage)Copy Code
Dim instance As FeatureTable
C# 
[SerializableAttribute()]
public class FeatureTable : DataTable 

Example

The following example performs a query on a point layer, including a request for feature geometry. The query returns a FeatureTable. We first find the geometry column in the table. Then we loop through the features and retrieve the city's point (technically the first point in the Multipoint collection of the feature). We add the point to a separate point collection. At this point we could use the points in a new query or display. The code assumes a pre-existing MapView object.
C#Copy Code
FeatureLayer theLayer = (FeatureLayer)mapView.Layers.FindByName("Cities"); 

  

// Set up query on the Cities layer 

Filter queryFilter = new Filter(new Envelope(0, 30, 10, 40)); 

QueryParameters queryParams = new QueryParameters(queryFilter); 

queryParams.ReturnGeometries = true; 

  

// Perform query, get FeatureTable as result 

FeatureTable queryResults = theLayer.Query(queryParams); 

  

// Find the Geometry column in the results FeatureTable 

string geometryColumn = String.Empty; 

foreach (DataColumn col in queryResults.Columns) 



    if (col.DataType == typeof(ESRI.ArcGIS.ADF.IMS.Geometry.Geometry)) 

    geometryColumn = col.ColumnName; 



  

PointCollection pointColl = new PointCollection(); 

Multipoint featureMultiPt; 

ESRI.ArcGIS.ADF.IMS.Geometry.Point pt; 

  

if (geometryColumn != String.Empty) 



    // Retrieve the geometry (point) for each city, add to point collection 

    foreach (DataRow featureRow in queryResults.Rows) 

    { 

        featureMultiPt = (ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint)featureRow[geometryColumn]; 

        pt = featureMultiPt.Points[0]; 

        pointColl.Add(pt); 

    } 



  

// Do something with the point collection 

int numPoints = pointColl.Count; 

    
Visual BasicCopy Code
Dim theLayer As FeatureLayer = CType(mapView.Layers.FindByName("Cities"), FeatureLayer)



' Set up query on the Cities layer

Dim queryFilter As New Filter(New Envelope(0, 30, 10, 40))

Dim queryParams As New QueryParameters(queryFilter)

queryParams.ReturnGeometries = True



' Perform query, get FeatureTable as result

Dim queryResults As FeatureTable = theLayer.Query(queryParams)



' Find the Geometry column in the results FeatureTable

Dim geometryColumn As String = String.Empty

For Each col As DataColumn In queryResults.Columns



    If col.DataType Is GetType(ESRI.ArcGIS.ADF.IMS.Geometry.Geometry) Then

        geometryColumn = col.ColumnName

    End If

Next



Dim pointColl As New PointCollection()

Dim featureMultiPt As Multipoint

Dim pt As ESRI.ArcGIS.ADF.IMS.Geometry.Point



If geometryColumn <> String.Empty Then



    ' Retrieve the geometry (point) for each city, add to point collection

    For Each featureRow As DataRow In queryResults.Rows



        featureMultiPt = CType(featureRow(geometryColumn), ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint)

        pt = featureMultiPt.Points(0)

        pointColl.Add(pt)

    Next

End If



' Do something with the point collection

Dim numPoints As Integer = pointColl.Count

Remarks

A FeatureTable is returned from the FeatureLayer.Identify methods and the FeatureLayer.Query methods.

A FeatureTable contains rows (records) of feature attributes and columns of fields. Each row corresponds to a feature in the layer from which the data was drawn. FeatureTable is derived from the ASP.NET DataTable class. It can therefore be used in any situation appropriate to a DataTable. Most importantly, it can be used as the data source for data-bound Web controls, such as GridView or DetailsView. This can make it simple to display the results of an identify or query operation. For examples of doing this, see FeatureLayer.Identify(int, int, double) and FeatureLayer.Query(QueryParameters).

If necessary, individual features can be retrieved from the FeatureTable by iterating through the DataRowCollection in the Rows property of the table. Each row corresponds to one feature's attributes. The Columns property of the table contains a DataColumnCollection. Individual columns can be examined to find the data type and other properties of the attribute fields.

If the QueryParameters.ReturnGeometries property was set to true when the Query was performed, then the FeatureTable will include a column with the geometry of features. The column in the FeatureTable will be named "#SHAPE#" and will have a DataType of ESRI.ArcGIS.ADF.IMS.Geometry.Geometry. Note that as of ArcIMS 9.2, the administrator of the server can disable returning of geometry. If geometry is disabled, the shape column will either be missing or will not contain geometry data.

FeatureTable also has the FromLayer property, which identifies the layer from which the data originated . If the FeatureTable was generated from a FeatureLayer.Query and more features were found than in the QueryParameters.FeatureLimit setting used during the Query, then the HasMore property will be true. In that case, FeatureLayer.Query(QueryParameters, int) can be used to retrieve additional feature records.

If the QueryParameters.ReturnGlobalEnvelope property was set to true when the Query was performed, then the GlobalEnvelope property will contain an envelope that surrounds all features found.

Inheritance Hierarchy

System.Object
   System.ComponentModel.MarshalByValueComponent
      System.Data.DataTable
         ESRI.ArcGIS.ADF.IMS.Carto.Layer.FeatureTable

See Also

© 2010 All Rights Reserved.