AE中如何由IFeature 如何获取所对应的FeatureClass
2012-12-27 23:38
399 查看
先获取FeatureClass,然后遍历Map中所有的FeatureLayer,然后比较
FeatureClass与FeatureLayer所对应的FeatureClass。
下面的例子中是在编辑功能里,删除一个Feature后,所触发的事件。目的是找到该Feature所在的FullPathName,并且输出该对象的坐标和ID号。
private void OnDeleteFeatureMethod(object o)
{
IFeature pFeature = o as IFeature;
IFeatureClass pFeatureClass = pFeature.Class as IFeatureClass;
for (int i = 0; i < axMapControl1.Map.LayerCount;i++ )
{
IFeatureLayer iFeatureLayer = axMapControl1.get_Layer(i) as IFeatureLayer;
IFeatureClass iFeatureCla = iFeatureLayer.FeatureClass;
if (iFeatureCla == pFeatureClass)
{
IWorkspace pWorkSpace = m_EngineEditor.EditWorkspace;
textBox3.Text += "操作的文件全路径:" + pWorkSpace.PathName + "\\" + axMapControl1.get_Layer(i).Name + ".shp " + "\r\n";
break;
}
}
if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
{
IGeometry iGe = pFeature.Shape;
IPoint ipo = new PointClass();
ipo = iGe as IPoint;
int a = 0;
int b = 0;
axMapControl1.FromMapPoint(ipo, ref a, ref
b);
textBox3.Text += "删除的点的ID号:" + pFeature.OID + ",坐标:(" + a + "," + b + ")" + "\r\n";
}
else if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
{
textBox3.Text += "删除的多边形对象的ID号:" + pFeature.OID + ",坐标:";
IPolygon pPolygon = (IPolygon)pFeature.Shape;
int a = 0;
int b = 0;
//把该feature强制转换为一个点的集合,再取点的坐标
IPointCollection pPointCollection = pPolygon as IPointCollection;
for (int i = 0; i < pPointCollection.PointCount - 1; i++)
{
IPoint ipo = pPointCollection.get_Point(i);
axMapControl1.FromMapPoint(ipo, ref a, ref
b);
textBox3.Text += "(" + a + "," + b + ")" + "\t";
}
textBox3.Text += "\r\n";
}
else if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
{
textBox3.Text += "删除的线对象的ID号:" + pFeature.OID + ",其坐标:";
IPolyline pPolygon = (IPolyline)pFeature.Shape;
int a = 0;
int b = 0;
//把该feature强制转换为一个点的集合,再取点的坐标
IPointCollection pPointCollection = pPolygon as IPointCollection;
for (int i = 0; i < pPointCollection.PointCount; i++)
{
IPoint ipo = pPointCollection.get_Point(i);
axMapControl1.FromMapPoint(ipo, ref a, ref
b);
textBox3.Text += "(" + a + "," + b + ")" + "\t";
}
textBox3.Text += "\r\n";
}
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
}
FeatureClass与FeatureLayer所对应的FeatureClass。
下面的例子中是在编辑功能里,删除一个Feature后,所触发的事件。目的是找到该Feature所在的FullPathName,并且输出该对象的坐标和ID号。
private void OnDeleteFeatureMethod(object o)
{
IFeature pFeature = o as IFeature;
IFeatureClass pFeatureClass = pFeature.Class as IFeatureClass;
for (int i = 0; i < axMapControl1.Map.LayerCount;i++ )
{
IFeatureLayer iFeatureLayer = axMapControl1.get_Layer(i) as IFeatureLayer;
IFeatureClass iFeatureCla = iFeatureLayer.FeatureClass;
if (iFeatureCla == pFeatureClass)
{
IWorkspace pWorkSpace = m_EngineEditor.EditWorkspace;
textBox3.Text += "操作的文件全路径:" + pWorkSpace.PathName + "\\" + axMapControl1.get_Layer(i).Name + ".shp " + "\r\n";
break;
}
}
if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
{
IGeometry iGe = pFeature.Shape;
IPoint ipo = new PointClass();
ipo = iGe as IPoint;
int a = 0;
int b = 0;
axMapControl1.FromMapPoint(ipo, ref a, ref
b);
textBox3.Text += "删除的点的ID号:" + pFeature.OID + ",坐标:(" + a + "," + b + ")" + "\r\n";
}
else if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
{
textBox3.Text += "删除的多边形对象的ID号:" + pFeature.OID + ",坐标:";
IPolygon pPolygon = (IPolygon)pFeature.Shape;
int a = 0;
int b = 0;
//把该feature强制转换为一个点的集合,再取点的坐标
IPointCollection pPointCollection = pPolygon as IPointCollection;
for (int i = 0; i < pPointCollection.PointCount - 1; i++)
{
IPoint ipo = pPointCollection.get_Point(i);
axMapControl1.FromMapPoint(ipo, ref a, ref
b);
textBox3.Text += "(" + a + "," + b + ")" + "\t";
}
textBox3.Text += "\r\n";
}
else if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
{
textBox3.Text += "删除的线对象的ID号:" + pFeature.OID + ",其坐标:";
IPolyline pPolygon = (IPolyline)pFeature.Shape;
int a = 0;
int b = 0;
//把该feature强制转换为一个点的集合,再取点的坐标
IPointCollection pPointCollection = pPolygon as IPointCollection;
for (int i = 0; i < pPointCollection.PointCount; i++)
{
IPoint ipo = pPointCollection.get_Point(i);
axMapControl1.FromMapPoint(ipo, ref a, ref
b);
textBox3.Text += "(" + a + "," + b + ")" + "\t";
}
textBox3.Text += "\r\n";
}
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
}
相关文章推荐
- [转] AE中如何由IFeature 如何获取所对应的FeatureClass
- 关于AE中IFeatureWorkspace接口的CreateFeatureClass方法
- geodatabase中如何获取feature class的ObjectID
- JS获取按键的代码,Js如何屏蔽用户的按键,Js获取用户按键对应的ASII码(兼容所有浏览器)
- PHP的继承方法如何获取子类名?get_class() 和 get_called_class()
- IFeatureClass 获取字段值
- AE中FeatureClass的Label的属性设置
- Windows CE如何根据文件名获取其对应文件图标icon
- 如何根据字数多少获取字符串对应高度
- Asp.net Core Startup Class中是如何获取配置信息的
- js中如何复制一个对象,如何获取所有属性和属性对应的值
- 关于Java的泛型在所声明的对象中如何获取class或者实例的方法的总结
- 如何用Jquery获取某一个Div的Class或者ID
- SSH如何获取外键表ID对应的Name问题
- 如何使用jQUery获取选中radio对应的值(一句代码)
- 如何获取域名(网址)对应的IP地址
- js 如何获取class的元素
- Arcgis Engine(ae)接口详解(3):featureClass的feature编辑和删除
- js中不支持getClassName,如何获取呢
- 通过反射获取父类中的泛型参数对应的Class对象