/// <summary>
/// 得到需要的字段名和字段值
/// </summary>
/// <param name="layer"></param>
private void GetField(ILayer layer)
{
int index = 0;
int i = 0;
//要素类转换为要素
IFeatureClass pFeaterClass = (layer as IFeatureLayer).FeatureClass;
string where="";
IQueryFilter filter = new QueryFilterClass();
filter.WhereClause = where;
IFeatureCursor cursor = pFeaterClass.Search(filter, false);
IFeature pFeature = cursor.NextFeature();
while (cursor.Fields != null)
{
DateAndLife dateAndLife = new DateAndLife();
if (pFeature == null)
{
break;
}
//获取到图层
if (layer.Name == "道路")
{
dateAndLife.LayerName = "道路";
}
IField field = null;
for (i = 0; i < pFeature.Fields.FieldCount; i++)
{
field = pFeature.Fields.get_Field(i);
//根据要素名称去操作
if (field.AliasName == "名称")
{
dateAndLife.Name = pFeature.get_Value(i).ToString();
}
}
pFeature = cursor.NextFeature();
dateAndLifes.Add(dateAndLife);
index++;
}
}
WPF、AE技术交流群:94234450
群链接:http://wp.qq.com/wpa/qunwpa?idkey=14e3d476b4a53a3a1502183e5a384d94b8be74b7510c0a76e67c4dec61f23781