您好,登錄后才能下訂單哦!
背景:
如果Polyline不為簡(jiǎn)單的幾何圖形,則求出其自相交的點(diǎn)。如果FromPoint和ToPoint重合也一并返回。
實(shí)現(xiàn)邏輯:
一、創(chuàng)建IMulitPoint pTargetPoint
二、判斷Polyline是否首尾相接,如果首尾相接,將點(diǎn)加入到pTargetPoint;
三、判斷Polyline是否為簡(jiǎn)單的幾何圖形,如果不是則進(jìn)行以下步驟:
1)得出Polyline中所有Path的起點(diǎn)和終點(diǎn),List<IPoint> lstOrigin;
2)將Polyline簡(jiǎn)單化,得出所有Path在LstOrigin中找不到的起點(diǎn)和終點(diǎn),添加到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; }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。