diff --git a/src/util/qpolygon-utils.js b/src/util/qpolygon-utils.js index 74ab4dce..639455c9 100644 --- a/src/util/qpolygon-utils.js +++ b/src/util/qpolygon-utils.js @@ -1008,6 +1008,7 @@ export const splitPolygonWithLines = (polygon) => { routes.push(startLine.startPoint) routes.push(startLine.endPoint) //hip끼리 만나는 경우는 아무것도 안해도됨 + let count = 0 if (!isSamePoint(startLine.endPoint, arrivalPoint)) { // polygon line까지 추가 const allLinesCopy = [...allLines, ...polygon.lines] @@ -1015,7 +1016,8 @@ export const splitPolygonWithLines = (polygon) => { let currentPoint = startLine.endPoint let currentLine = startLine - while (!isSamePoint(currentPoint, arrivalPoint)) { + while (!isSamePoint(currentPoint, arrivalPoint) && count <= polygon.points.length) { + count++ // startHip에서 만나는 출발선 두개. 두개의 선을 출발하여 arrivalPoint에 도착할 때 까지 count를 세고, 더 낮은 count를 가진 길을 선택한다. let connectedLines = allLinesCopy.filter((line) => isSamePoint(line.startPoint, currentPoint) || isSamePoint(line.endPoint, currentPoint)) @@ -1052,8 +1054,10 @@ export const splitPolygonWithLines = (polygon) => { } } - routes.push(endLine.startPoint) - roofs.push(routes) + if (count <= polygon.points.length - 1) { + routes.push(endLine.startPoint) + roofs.push(routes) + } }) // 중복 제거