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

1、将ICircularArc转化为IPolygon

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

 

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

posted on   jobgeo  阅读(845)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示