1524 모듈 배치영역 생성 오류 수정
This commit is contained in:
parent
b735a6f54a
commit
b1e823083e
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user