added storage unit to human
This commit is contained in:
@@ -85,13 +85,45 @@ export function useWallClassification(walls: Walls) {
|
||||
}));
|
||||
}
|
||||
|
||||
const allCoords = mergedLineStrings.flatMap(ls => ls.geometry.coordinates);
|
||||
const uniqueCoords = Array.from(new Set(allCoords.map(coord => coord.join(','))));
|
||||
if (uniqueCoords.length < 4) return [];
|
||||
const validLineStrings = mergedLineStrings.map(ls => {
|
||||
const coords = ls.geometry.coordinates.map(coord => coord.join(','));
|
||||
|
||||
const lineStrings = turf.featureCollection(mergedLineStrings);
|
||||
if (coords.length < 2) return null;
|
||||
|
||||
const polygons = turf.polygonize(lineStrings);
|
||||
const start = coords[0];
|
||||
const end = coords[coords.length - 1];
|
||||
const middle = coords.slice(1, -1);
|
||||
|
||||
const seen = new Set<string>([start, end]);
|
||||
const filteredMiddle: string[] = [];
|
||||
|
||||
for (const point of middle) {
|
||||
if (!seen.has(point)) {
|
||||
seen.add(point);
|
||||
filteredMiddle.push(point);
|
||||
}
|
||||
}
|
||||
|
||||
const newCoords = [start, ...filteredMiddle, end];
|
||||
|
||||
if (newCoords.length >= 4) {
|
||||
const resultCoords = newCoords.map(str => str.split(',').map(Number));
|
||||
return {
|
||||
...ls,
|
||||
geometry: {
|
||||
...ls.geometry,
|
||||
coordinates: resultCoords,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}).filter(Boolean);
|
||||
|
||||
if (validLineStrings.length === 0) return [];
|
||||
|
||||
const lineStrings = turf.featureCollection(validLineStrings as any);
|
||||
const polygons = turf.polygonize(lineStrings as any);
|
||||
|
||||
const rooms: Point[][] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user