같은좌표판단 1오차 허용
This commit is contained in:
parent
04e8e66b04
commit
c60db3cda5
@ -1380,22 +1380,27 @@ export const splitPolygonWithLines = (polygon) => {
|
||||
})
|
||||
}
|
||||
|
||||
const removeDuplicatePolygons = (polygons) => {
|
||||
function normalizePoint(point) {
|
||||
return {
|
||||
x: Math.round(point.x),
|
||||
y: Math.round(point.y),
|
||||
}
|
||||
}
|
||||
|
||||
function arePolygonsEqual(polygon1, polygon2) {
|
||||
if (polygon1.length !== polygon2.length) return false
|
||||
|
||||
const normalizedPolygon1 = polygon1.map(normalizePoint).sort((a, b) => a.x - b.x || a.y - b.y)
|
||||
const normalizedPolygon2 = polygon2.map(normalizePoint).sort((a, b) => a.x - b.x || a.y - b.y)
|
||||
|
||||
return normalizedPolygon1.every((point, index) => arePointsEqual(point, normalizedPolygon2[index]))
|
||||
}
|
||||
|
||||
function removeDuplicatePolygons(polygons) {
|
||||
const uniquePolygons = []
|
||||
|
||||
polygons.forEach((polygon) => {
|
||||
const sortedPolygon = polygon
|
||||
.map((point) => `${Math.floor(point.x)},${Math.floor(point.y)}`)
|
||||
.sort()
|
||||
.join('|')
|
||||
const isDuplicate = uniquePolygons.some((uniquePolygon) => {
|
||||
const sortedUniquePolygon = uniquePolygon
|
||||
.map((point) => `${Math.floor(point.x)},${Math.floor(point.y)}`)
|
||||
.sort()
|
||||
.join('|')
|
||||
return sortedPolygon === sortedUniquePolygon
|
||||
})
|
||||
|
||||
const isDuplicate = uniquePolygons.some((uniquePolygon) => arePolygonsEqual(polygon, uniquePolygon))
|
||||
if (!isDuplicate) {
|
||||
uniquePolygons.push(polygon)
|
||||
}
|
||||
@ -3551,7 +3556,7 @@ function createRoofPaddingPolygon(polygon, lines, arcSegments = 0) {
|
||||
}
|
||||
|
||||
function arePointsEqual(point1, point2) {
|
||||
return Math.abs(point1.x - point2.x) < 1 && Math.abs(point1.y - point2.y) - 1
|
||||
return Math.abs(point1.x - point2.x) <= 1 && Math.abs(point1.y - point2.y) <= 1
|
||||
}
|
||||
|
||||
function arraysHaveSamePoints(array1, array2) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user