• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

通过线构造面(C#+ArcGISEngine9.2)

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

生成面之前的截图:


生成为面之后的截图:


从线生成面的方法代码:

/// <summary>
/// 通过线创建面
/// </summary>
/// <param name="pPolyline">线</param>
/// <returns></returns>
IPolygon ConstructPolygonFromPolyline(IPolyline pPolyline)
{
    IGeometryCollection pPolygonGeoCol 
= new PolygonClass();

    
if ((pPolyline != null&& (!pPolyline.IsEmpty))
    {
        IGeometryCollection pPolylineGeoCol 
= pPolyline as IGeometryCollection;
        ISegmentCollection pSegCol 
= new RingClass();
        ISegment pSegment 
= null;
        
object missing = Type.Missing;

        
for (int i = 0; i < pPolylineGeoCol.GeometryCount; i++)
        {
            ISegmentCollection pPolylineSegCol 
= pPolylineGeoCol.get_Geometry(i) as ISegmentCollection;
            
for (int j = 0; j < pPolylineSegCol.SegmentCount; j++)
            {
                pSegment 
= pPolylineSegCol.get_Segment(j);
                pSegCol.AddSegment(pSegment, 
ref missing, ref missing);
            }
            pPolygonGeoCol.AddGeometry(pSegCol 
as IGeometry, ref missing, ref missing);
        }
    }
    
return pPolygonGeoCol as IPolygon;
}

调用示例:
ILayer pLayer = axMapControl1.get_Layer(1);
IFeatureLayer pFeatureLayer 
= pLayer as IFeatureLayer;
IFeatureClass pFeatureClass 
= pFeatureLayer.FeatureClass;
if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
{
    IFeatureCursor pFeatureCursor 
= pFeatureClass.Search(nullfalse);
    IFeature pFeature 
= pFeatureCursor.NextFeature();

    ILayer pTargetLayer 
= axMapControl1.get_Layer(2);
    IFeatureLayer pTargetFeatureLayer 
= pTargetLayer as IFeatureLayer;
    IFeatureClass pTargetFeatureClass 
= pTargetFeatureLayer.FeatureClass;
    
if (pTargetFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
    {
        IPolygon pPolygon 
= null;
        
while (pFeature != null)
        {
            IPolyline pPolyline 
= pFeature.Shape as IPolyline;
            pPolygon 
= ConstructPolygonFromPolyline(pPolyline);
            
if ((pPolygon != null&& (!pPolygon.IsEmpty))
            {
                
if (!pPolygon.IsClosed)
                {
                    pPolygon.Close();
                }
                IFeature pNewFeature 
= pTargetFeatureClass.CreateFeature();
                pNewFeature.Shape 
= pPolygon;
                pNewFeature.Store();
                pFeature.Delete();
            }
            pFeature 
= pFeatureCursor.NextFeature();
        }
    }
}
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, 
nullnull);

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#调用HTTP接口两种方式Demo发布时间:2022-07-14
下一篇:
MSIL反汇编程序(Ildasm.exe)[C#]发布时间:2022-07-14
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap