您好,登錄后才能下訂單哦!
背景:
如果Polyline不為簡單的幾何圖形,則求出其自相交的點。如果FromPoint和ToPoint重合也一并返回。
實現邏輯:
一、創建IMulitPoint pTargetPoint
二、判斷Polyline是否首尾相接,如果首尾相接,將點加入到pTargetPoint;
三、判斷Polyline是否為簡單的幾何圖形,如果不是則進行以下步驟:
1)得出Polyline中所有Path的起點和終點,List<IPoint> lstOrigin;
2)將Polyline簡單化,得出所有Path在LstOrigin中找不到的起點和終點,添加到pTargetPoint中
第三步的代碼:
private IMultipoint getInersectPoint(IPolyline pPolyline) { IGeometryCollection pGeoColl = pPolyline as IGeometryCollection; List<IPoint> lstPoint = new List<IPoint>(); for (int i = 0; i < pGeoColl.GeometryCount; i++) { IPath pPath = pGeoColl.get_Geometry(i) as IPath; IPoint pTemp = lstPoint.Find(p => (p.X == pPath.FromPoint.X && p.Y == pPath.FromPoint.Y)); if (pTemp == null) lstPoint.Add(pPath.FromPoint); pTemp = lstPoint.Find(p => (p.X == pPath.ToPoint.X && p.Y == pPath.ToPoint.Y)); if (pTemp == null) lstPoint.Add(pPath.ToPoint); } ITopologicalOperator2 ptopo = pPolyline as ITopologicalOperator2; ptopo.IsKnownSimple_2 = false; ptopo.Simplify(); IMultipoint pMultipoint = new MultipointClass(); IPointCollection pPointColl = pMultipoint as IPointCollection; for (int i = 0; i < pGeoColl.GeometryCount; i++) { IPath pPath = pGeoColl.get_Geometry(i) as IPath; IPoint pTemp = lstPoint.Find(p => (p.X == pPath.FromPoint.X && p.Y == pPath.FromPoint.Y)); if (pTemp == null) pPointColl.AddPoint(pPath.FromPoint); pTemp = lstPoint.Find(p => (p.X == pPath.ToPoint.X && p.Y == pPath.ToPoint.Y)); if (pTemp == null) pPointColl.AddPoint(pPath.ToPoint); } return pMultipoint; }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。