zoukankan      html  css  js  c++  java
  • [转] 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 " + "
    ";
                        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 + ")" + "
    ";
             }
             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 + ")" + "	";
                 }
                 textBox3.Text += "
    ";
             }
     
             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 + ")" + "	";
                 }
                 textBox3.Text += "
    ";
      }
      axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
    }
    
  • 相关阅读:
    实习小白::(转) Cocos2d-x 3.0开发(五)关联程序逻辑与cocoStudio导出文件
    实习小白::(转)Cocos2d-x 3.0开发(六)使用cocoStudio创建一个骨骼动画
    实习小白::(转) Cocos2d-x 3.0 开发(七)在程序中处理cocoStudio导出动画
    实习小白::(转) cocos2d-x使用cocosStudio编辑的动画文件
    (转)cocos2d-x 每帧动画的播放设置一个监听函数的做法
    Filter
    使用Cookie记住用户名和密码
    动态规划
    热分布
    背包问题
  • 原文地址:https://www.cnblogs.com/arxive/p/5903577.html
Copyright © 2011-2022 走看看