Attributes of arc engiene reading documents

Source: Internet
Author: User

Design Interface

Create class

The Code is as follows:

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. Threading. tasks;
Using ESRI. ArcGIS. controls;
Using system. Data;
Using ESRI. ArcGIS. CARTO;
Using ESRI. ArcGIS. Geodatabase;
Using ESRI. ArcGIS. geometry;

Namespace Test
{
Public class datahelper
{
# Region read the mapcontrol Attribute Table
Public static datatable getattribute (axmapcontrol)
{
Int layercount = axmapcontrol. Map. layercount;

// Ifeature pfeature;
String fieldname = string. empty;
Int fieldcount;
Bool firstthroght = true;
Datatable = new datatable ();
// Loop layer to obtain data for each layer
For (int l = 0; L <layercount; l ++)
{
Ifeaturelayer pfeaturelayer = axmapcontrol. Map. get_layer (l) as ifeaturelayer;
Ifeatureclass pfeatureclass = pfeaturelayer. featureclass;
Fieldcount = pfeatureclass. Fields. fieldcount;
Int featurecount = pfeatureclass. featurecount (New queryfilterclass ());
If (firstthroght)
{
For (INT I = 0; I <fieldcount; I ++)
{
String fieldheadname = pfeatureclass. Fields. get_field (I). aliasname;
Datatable. Columns. Add (fieldheadname );

}
Firstthroght = false;
}
// Determine the feature type
Int indexofshape = pfeatureclass. findfield ("shape ");
ESRI. ArcGIS. Geometry. esrigeometrytype pfeatureclassshapetype = pfeatureclass. shapetype;
For (INT I = 0; I <featurecount; I ++)
{
Datarow = datatable. newrow ();
For (Int J = 0; j <fieldcount; j ++)
{
If (j = indexofshape)
{
// Geometroy. shapetype Conversion
Switch (pfeatureclassshapetype)
{
Case esrigeometrytype. esrigeometrypoint:
Fieldname = "point ";
Break;
Case esrigeometrytype. esrigeometrypolyline:
Fieldname = "polyline ";
Break;
Case esrigeometrytype. esrigeometrypolygon:
Fieldname = "polygon ";
Break;
Default:
Break;
}
// Fieldname = pfeatureclass. getfeature (I). get_value (j). tostring ();
// Datatable. Columns. Add (fieldname );

Datarow [J] = fieldname;
}
Else
{
// Add a non-shape field to the table
Fieldname = pfeatureclass. getfeature (I). get_value (j). tostring ();
// Datatable. Columns. Add (fieldname );

Datarow [J] = fieldname;
}

// Datatable [I] [J] = fieldname;
}
Datatable. Rows. Add (datarow );

}
}
Return datatable;
}
# Endregion
}
}

Attributes of arc engiene reading documents

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.