added storage unit to human

This commit is contained in:
2025-07-11 13:14:18 +05:30
parent d92e1b8ea4
commit 52ac89f8b7
8 changed files with 143 additions and 63 deletions

View File

@@ -76,12 +76,42 @@ export default function PolygonGenerator({
turf.lineString(line.map((p: any) => p?.position))
);
const validLineFeatures = lineFeatures.filter((line) => {
const coords = line.geometry.coordinates;
return coords.length >= 2;
});
const validLineFeatures = lineFeatures.map(ls => {
const coords = ls.geometry.coordinates.map(coord => coord.join(','));
const polygons = turf.polygonize(turf.featureCollection(validLineFeatures));
if (coords.length < 2) return null;
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);
const polygons = turf.polygonize(turf.featureCollection(validLineFeatures as any) as any);
renderWallGeometry(wallPoints);