[转] AE中如何由IFeature 如何获取所对应的FeatureClass

转载的原文 AE中如何由IFeature 如何获取所对应的FeatureClass

先获取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);
}
时间: 2024-08-04 18:21:58

[转] AE中如何由IFeature 如何获取所对应的FeatureClass的相关文章

AE中Shapefile文件添加到SDE数据集

linder_lee 原文 AE中Shapefile文件添加到SDE数据集(c#) 主要完成用C#,通过AE将本地Shapefile文件导入到SDE的指定数据集下面. 首先说下思路: (1) 通过OpenFileDialog打开本地的Shp文件: (2)通过获取的Shp文件创建FeatureClass,获取shp的字段 IFields,并判断图层类别; (3)连接SDE中指定数据集,并创建新的FeatureClass: (4)将shp文件对应的 FeatureClass里的Feature复制到S

C# Winform中执行post操作并获取返回的XML类型的数据

/// <summary> /// 返回指定日期的订单数据 /// </summary> /// <param name="StartDate">起始日期</param> /// <param name="EndDate">结束日期</param> /// <returns>DataTable</returns> public System.Data.DataTable

jQuery遍历table中的tr td并获取td中的值

jQuery遍历table中的tr td并获取td中的值 $(function(){ $("#tableId tr").find("td").each(function(){ <span style="white-space:pre"> </span> var year = $("#year").val(); var month = $("#month").val(); var da

js获取url中的参数,并保证获取到的参数不乱码

  //网上比较经典的js获取url中的参数的方法  function getQueryString(name) {      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");      var r = window.location.search.substr(1).match(reg);      if ( r != null ){        

listView中的button控件获取索引

1.在listitem中初始化button的时候,给该button添加一个setTag方法,将此时的索引值传进去,然后在button的onclick事件中调用view的getTag方法,即可将listitem的索引读出来,代码如下: tagButton.setTag(position); 此处的tagButton就是定义的button,Position是view里边的位置. 2.初始化button的时候通过setTag方法传入一个item的索引值 private OnClickListener 

Git中从远程的分支获取最新的版本到本地

Git中从远程的分支获取最新的版本到本地有这样2个命令: 1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge git fetch origin master git log -p master..origin/master git merge origin/master 以上命令的含义: 首先从远程的origin的master主分支下载最新的版本到origin/master分支上 然后比较本地的master分支和origin/master分支的差别 最后进行合并 上述

Android中sqlite之从网上获取数据更新UI

Android中sqlite之从网上获取数据更新UI 在这里,本人主要想做一个 1.首先从网上获取数据 2.将获取的数据存储到本地 3.地图上显示屏幕范围内的marker. 4.当地图状态改变时,要查询本地数据库,并更新地图. BaiduMap有个setOnMapStatusChangeListener监听类,该类监听BaiduMap的状态,共有三个方法--onMapStatusChangeStart(),onMapStatusChangeFinish(),onMapStatusChange()

在C语言中以编程的方式获取函数名

调试常用的 __FILE__, __FUNCTION__, __LINE__ 调试常用的 __FILE__, __FUNCTION__, __LINE__ 没想到 VC6 不支持 __FUNCTION__ 所以我写了如下的奇怪代码 //用来记录当前行和当前函数//也可说是记录 堆栈void log_stack(const char *file, int line, const char * function); //当然还要对 __FUNCTION__ 宏作点修饰,因为这个宏只是在函数里面才起作

在完全由Spring管理的环境中使用Spring的Context获取Bean实例

在大型的应用中,常常会有很灵活的需求,而在使用了框架之后,虽然可以大大提高开发的效率,但同时,也把我们框到一个架子中了. 下面先说一下我遇到的问题,事情大概是这样的: @Component @Scope("prototype") public class Action1 implements Action{ ..... } @Component @Scope("prototype") public class Action2 implements Action{ .