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;

注意:在給IPointCollection添加點的時候要按照一定的順序添加(按照順時針或者逆時針的順序選取起點進行添加,否則會使得圖形發生變化)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM