ArcEngine 将圆形、矩形转换为多边形 ;ICircularArc、IEnvelope转化为IPolygon

编程入门 行业动态 更新时间:2024-10-27 10:21:44

ArcEngine 将圆形、矩形转换为<a href=https://www.elefans.com/category/jswz/34/1760301.html style=多边形 ;ICircularArc、IEnvelope转化为IPolygon"/>

ArcEngine 将圆形、矩形转换为多边形 ;ICircularArc、IEnvelope转化为IPolygon

1、将ICircularArc转化为IPolygon

   1: ICircularArc pCircularArc = null;2: IRubberBand pRubberBand = new RubberCircleClass();3: pCircularArc = pRubberBand.TrackNew(axMapControl_Main.ActiveView.ScreenDisplay, null) as ICircularArc;4: if (pCircularArc == null)5:     return;6: object missing = Type.Missing;7: ISegmentCollection pSegmentColl = new RingClass();8: pSegmentColl.AddSegment((ISegment)pCircularArc, ref missing, ref missing);9: IRing pRing = (IRing)pSegmentColl;10: pRing.Close(); //得到闭合的环11: IGeometryCollection pGeometryCollection = new PolygonClass();12: pGeometryCollection.AddGeometry(pRing, ref missing, ref missing); //环转面13: IPolygon pPolygon = (IPolygon)pGeometryCollection;


2、将IEnvelope转化为IPolygon

   1: IEnvelope pEnvelope = null;2: IRubberBand pRubberBand = new RubberEnvelopeClass();3: pEnvelope = pRubberBand.TrackNew(axMapControl_Main.ActiveView.ScreenDisplay, null) as IEnvelope;4: if (pEnvelope == null)5:     return;           6: IPoint p1 = new PointClass();7: IPoint p2 = new PointClass();8: IPoint p3 = new PointClass();9: IPoint p4 = new PointClass();10: p1 = pEnvelope.UpperLeft;11: p2 = pEnvelope.LowerLeft;12: p3 = pEnvelope.LowerRight;13: p4 = pEnvelope.UpperRight;14: IPointCollection pPointCollection = new PolygonClass();15: object missing = Type.Missing;16: pPointCollection.AddPoint(p1, ref missing, ref missing);17: pPointCollection.AddPoint(p2, ref missing, ref missing);18: pPointCollection.AddPoint(p3, ref missing, ref missing);19: pPointCollection.AddPoint(p4, ref missing, ref missing);20: IPolygon pPolygon = (IPolygon)pPointCollection;

完成以后记得使用ITopologicalOperator.Simplify()进行处理,可以处理面自动闭合等问题

注意:在给IPointCollection添加点的时候要按照一定的顺序添加(按照顺时针或者逆时针的顺序选取起点进行添加,否则会使得图形发生变化)


更多推荐

ArcEngine 将圆形、矩形转换为多边形 ;ICircularArc、IEnvelope转化为IPolygon

本文发布于:2024-03-05 06:55:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1711612.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多边形   矩形   转化为   转换为   圆形

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!