From b1e823083ea4aa292b6e07d16b269ec731191529 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Mon, 9 Mar 2026 12:28:23 +0900 Subject: [PATCH] =?UTF-8?q?1524=20=EB=AA=A8=EB=93=88=20=EB=B0=B0=EC=B9=98?= =?UTF-8?q?=EC=98=81=EC=97=AD=20=EC=83=9D=EC=84=B1=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useModuleBasicSetting.js | 35 ++++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index 365ed1b0..c48c2d21 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -184,14 +184,14 @@ export function useModuleBasicSetting(tabNum) { // 방향에 따른 좌표 설정 const directionConfig = { - south: { coord1: 'y1', coord2: 'y2', findExtreme: Math.max }, - north: { coord1: 'y1', coord2: 'y2', findExtreme: Math.min }, - east: { coord1: 'x1', coord2: 'x2', findExtreme: Math.max }, - west: { coord1: 'x1', coord2: 'x2', findExtreme: Math.min }, + south: { coord1: 'y1', coord2: 'y2', findExtreme: Math.max, offsetX: 0, offsetY: 1 }, + north: { coord1: 'y1', coord2: 'y2', findExtreme: Math.min, offsetX: 0, offsetY: -1 }, + east: { coord1: 'x1', coord2: 'x2', findExtreme: Math.max, offsetX: 1, offsetY: 0 }, + west: { coord1: 'x1', coord2: 'x2', findExtreme: Math.min, offsetX: -1, offsetY: 0 }, } const config = directionConfig[direction] || directionConfig.south - const { coord1, coord2, findExtreme } = config + const { coord1, coord2, offsetX, offsetY } = config // 2. 직선만 필터링 (대각선 제외) // 남/북: y1 === y2 인 경우 수평 직선 @@ -200,22 +200,29 @@ export function useModuleBasicSetting(tabNum) { if (straightLines.length === 0) return - // 3. 가장 끝에 있는 직선 찾기 - // 남쪽: 가장 하단 (y값이 가장 큰), 북쪽: 가장 상단 (y값이 가장 작은) - // 동쪽: 가장 오른쪽 (x값이 가장 큰), 서쪽: 가장 왼쪽 (x값이 가장 작은) - const extremeValue = findExtreme(...straightLines.map((line) => line[coord1])) - const eavesLines = straightLines.filter((line) => line[coord1] === extremeValue) + // 3. 폴리곤의 turf polygon 생성 (처마 방향 판별용) + const points = polygon.getCurrentPoints() + const turfCoords = points.map((p) => [p.x, p.y]) + turfCoords.push(turfCoords[0]) // 폴리곤 닫기 + const turfPolygon = turf.polygon([turfCoords]) - // 4. 직선에 대해 타입 설정 + // 4. 각 직선에 대해 처마/용마루 판별 + // 라인 중점에서 처마 방향으로 약간 이동한 점이 폴리곤 외부이면 처마(eaves) + // 폴리곤 내부이면 용마루(ridge) straightLines.forEach((line) => { - if (eavesLines.includes(line)) { - // 가장 끝에 있는 직선은 eaves + const midX = (line.x1 + line.x2) / 2 + const midY = (line.y1 + line.y2) / 2 + // 처마 방향으로 약간 이동한 테스트 포인트 + const testPoint = turf.point([midX + offsetX * 0.5, midY + offsetY * 0.5]) + + if (!turf.booleanPointInPolygon(testPoint, turfPolygon)) { + // 테스트 포인트가 폴리곤 외부 → 처마 방향을 향함 line.attributes = { ...line.attributes, type: LINE_TYPE.WALLLINE.EAVES, } } else { - // 나머지 직선은 ridge + // 테스트 포인트가 폴리곤 내부 → 용마루 방향을 향함 line.attributes = { ...line.attributes, type: LINE_TYPE.SUBLINE.RIDGE,