AE中点生成面的代码

时间:2013-4-16    作者:悬浮的青春    分类:


           
            获取点集。强制转换为多边形。然后在图层上以polygon画出面。
            
           ILayer layer = axMapControl1.Map.get_Layer[3];
            IFeatureLayer m_pFeatureLayer = layer as IFeatureLayer;
          if( m_pFeatureLayer.FeatureClass.ShapeType  ==  esriGeometryType.esriGeometryPolygon) 
          {
              IPointCollection m_pPointCollection = new PolygonClass(); 
              object missing = Type.Missing; 
              int icount = newFeature.XLIST.Count; //点集数目
              if (icount < 3) return; 
              for (int i = 0; i < icount; i++) //遍历添加
              { 
                  ESRI.ArcGIS.Geometry.IPoint point  =  new  PointClass();  
                  point.PutCoords(newFeature.XLIST,  newFeature.YLIST); 
                  m_pPointCollection.AddPoint(point,  ref  missing,  ref  missing);  
              }  IPolygon  m_pPolygon  = m_pPointCollection  as  IPolygon; 
              if  (m_pPolygon  ==  null) 

              {  
                  System.Windows.Forms.MessageBox.Show("null");  
                  return;  
              }  
              else  
              {  
                  ITopologicalOperator pTopo  =  m_pPolygon  as  ITopologicalOperator; 
                  if  (pTopo  !=  null)  
                  {  
                      pTopo.Simplify(); 
                  }  
              }
           
              IWorkspaceEdit  m_pWorkspaceEdit  =  m_EngineEditor.EditWorkspace  as  IWorkspaceEdit; 

              m_pWorkspaceEdit.StartEditOperation();  
              IFeature  m_pFeature  = m_pFeatureLayer.FeatureClass.CreateFeature();
              m_pFeature.Shape = m_pPolygon as ESRI.ArcGIS.Geometry.IGeometry; 

              m_pFeature.Store(); 
              m_pWorkspaceEdit.StopEditOperation(); 
          }   

标签: arcgis二次开发

WRITTEN BY

avatar