1524 모듈 배치영역 생성 오류 수정

This commit is contained in:
hyojun.choi 2026-03-09 12:28:23 +09:00
parent b735a6f54a
commit b1e823083e

View File

@ -184,14 +184,14 @@ export function useModuleBasicSetting(tabNum) {
// 방향에 따른 좌표 설정 // 방향에 따른 좌표 설정
const directionConfig = { const directionConfig = {
south: { coord1: 'y1', coord2: 'y2', findExtreme: Math.max }, south: { coord1: 'y1', coord2: 'y2', findExtreme: Math.max, offsetX: 0, offsetY: 1 },
north: { coord1: 'y1', coord2: 'y2', findExtreme: Math.min }, north: { coord1: 'y1', coord2: 'y2', findExtreme: Math.min, offsetX: 0, offsetY: -1 },
east: { coord1: 'x1', coord2: 'x2', findExtreme: Math.max }, east: { coord1: 'x1', coord2: 'x2', findExtreme: Math.max, offsetX: 1, offsetY: 0 },
west: { coord1: 'x1', coord2: 'x2', findExtreme: Math.min }, west: { coord1: 'x1', coord2: 'x2', findExtreme: Math.min, offsetX: -1, offsetY: 0 },
} }
const config = directionConfig[direction] || directionConfig.south const config = directionConfig[direction] || directionConfig.south
const { coord1, coord2, findExtreme } = config const { coord1, coord2, offsetX, offsetY } = config
// 2. 직선만 필터링 (대각선 제외) // 2. 직선만 필터링 (대각선 제외)
// 남/북: y1 === y2 인 경우 수평 직선 // 남/북: y1 === y2 인 경우 수평 직선
@ -200,22 +200,29 @@ export function useModuleBasicSetting(tabNum) {
if (straightLines.length === 0) return if (straightLines.length === 0) return
// 3. 가장 끝에 있는 직선 찾기 // 3. 폴리곤의 turf polygon 생성 (처마 방향 판별용)
// 남쪽: 가장 하단 (y값이 가장 큰), 북쪽: 가장 상단 (y값이 가장 작은) const points = polygon.getCurrentPoints()
// 동쪽: 가장 오른쪽 (x값이 가장 큰), 서쪽: 가장 왼쪽 (x값이 가장 작은) const turfCoords = points.map((p) => [p.x, p.y])
const extremeValue = findExtreme(...straightLines.map((line) => line[coord1])) turfCoords.push(turfCoords[0]) // 폴리곤 닫기
const eavesLines = straightLines.filter((line) => line[coord1] === extremeValue) const turfPolygon = turf.polygon([turfCoords])
// 4. 직선에 대해 타입 설정 // 4. 각 직선에 대해 처마/용마루 판별
// 라인 중점에서 처마 방향으로 약간 이동한 점이 폴리곤 외부이면 처마(eaves)
// 폴리곤 내부이면 용마루(ridge)
straightLines.forEach((line) => { straightLines.forEach((line) => {
if (eavesLines.includes(line)) { const midX = (line.x1 + line.x2) / 2
// 가장 끝에 있는 직선은 eaves 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 = {
...line.attributes, ...line.attributes,
type: LINE_TYPE.WALLLINE.EAVES, type: LINE_TYPE.WALLLINE.EAVES,
} }
} else { } else {
// 나머지 직선은 ridge // 테스트 포인트가 폴리곤 내부 → 용마루 방향을 향함
line.attributes = { line.attributes = {
...line.attributes, ...line.attributes,
type: LINE_TYPE.SUBLINE.RIDGE, type: LINE_TYPE.SUBLINE.RIDGE,