직선라인 임시맞춤
This commit is contained in:
parent
6c8b424afd
commit
afef45c1c1
@ -401,35 +401,50 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
|
||||
console.log('baseLinePoints:', orderedBaseLinePoints)
|
||||
|
||||
// baseLinePoint에서 roofLinePoint 방향으로 45도 대각선 확장 후 가장 가까운 접점 계산
|
||||
let roofLineContactPoints = orderedBaseLinePoints.map((point, index) => {
|
||||
// 각 포인트의 dx, dy, sign 정보 수집
|
||||
const contactData = orderedBaseLinePoints.map((point, index) => {
|
||||
const roofPoint = roofLinePoints[index]
|
||||
if (!roofPoint) return point
|
||||
if (!roofPoint) return { dx: 0, dy: 0, signDx: 0, signDy: 0 }
|
||||
|
||||
const dx = roofPoint.x - point.x
|
||||
const dy = roofPoint.y - point.y
|
||||
const absDx = Math.abs(dx)
|
||||
const absDy = Math.abs(dy)
|
||||
return { dx, dy, signDx: Math.sign(dx), signDy: Math.sign(dy) }
|
||||
})
|
||||
|
||||
// 거리가 0이면 이미 같은 위치
|
||||
// if (absDx === 0 && absDy === 0) return point
|
||||
// maxStep: 모든 포인트 중 가장 큰 45도 step
|
||||
const maxStep = contactData.reduce((max, data) => {
|
||||
return Math.max(max, Math.min(Math.abs(data.dx), Math.abs(data.dy)))
|
||||
}, 0)
|
||||
|
||||
const step = Math.min(absDx, absDy)
|
||||
// if (step === 0) return point
|
||||
// baseLine 폴리곤의 중심 계산 (확장 방향 결정용)
|
||||
const centroid = orderedBaseLinePoints.reduce((acc, p) => {
|
||||
acc.x += p.x / orderedBaseLinePoints.length
|
||||
acc.y += p.y / orderedBaseLinePoints.length
|
||||
return acc
|
||||
}, { x: 0, y: 0 })
|
||||
|
||||
// 모든 포인트를 동일한 maxStep으로 45도 확장
|
||||
let roofLineContactPoints = orderedBaseLinePoints.map((point, index) => {
|
||||
const data = contactData[index]
|
||||
const { dx, dy } = data
|
||||
|
||||
// dx 또는 dy가 0인 경우 중심에서 바깥쪽 방향으로 확장
|
||||
let signDx = data.signDx
|
||||
let signDy = data.signDy
|
||||
if (signDx === 0) {
|
||||
signDx = point.x >= centroid.x ? 1 : -1
|
||||
}
|
||||
if (signDy === 0) {
|
||||
signDy = point.y >= centroid.y ? 1 : -1
|
||||
}
|
||||
|
||||
const nextX = point.x + Math.sign(dx) * step
|
||||
const nextY = point.y + Math.sign(dy) * step
|
||||
return {
|
||||
x: nextX,
|
||||
y: nextY
|
||||
x: point.x + signDx * maxStep,
|
||||
y: point.y + signDy * maxStep
|
||||
}
|
||||
})
|
||||
|
||||
const maxContactDistance = orderedBaseLinePoints.reduce((max, point, index) => {
|
||||
const contactPoint = roofLineContactPoints[index]
|
||||
if (!contactPoint) return max
|
||||
const dist = Math.hypot(contactPoint.x - point.x, contactPoint.y - point.y)
|
||||
return Math.max(max, dist)
|
||||
}, 0)
|
||||
const maxContactDistance = Math.hypot(maxStep, maxStep)
|
||||
|
||||
let changRoofLinePoints = orderedBaseLinePoints.map((point, index) => {
|
||||
const contactPoint = roofLineContactPoints[index]
|
||||
@ -458,7 +473,7 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
|
||||
roofLineContactPoints = movingLineFromSkeleton(roofId, canvas)
|
||||
}
|
||||
|
||||
console.log('points:', roofLineContactPoints)
|
||||
console.log('points:', changRoofLinePoints)
|
||||
const geoJSONPolygon = toGeoJSON(changRoofLinePoints)
|
||||
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user