This commit is contained in:
Jake Kasper
2025-09-05 12:50:21 -04:00
parent bb6dc070de
commit e85bf3256a

View File

@@ -371,8 +371,14 @@ router.post('/:id/sections', validateParams(idParamSchema), validateRequest(lawn
// Sanitize polygon before storing
let poly = polygonData;
try {
const cleaned = sanitizePolygon(polygonData?.coordinates?.[0] || []);
poly = { ...polygonData, coordinates: [cleaned] };
const ring = polygonData?.coordinates?.[0] || [];
// For GPS-captured shapes, keep the user's ring as-is to avoid over-simplifying
if (captureMethod === 'gps_points' || captureMethod === 'gps_trace') {
poly = { ...polygonData, coordinates: [ring] };
} else {
const cleaned = sanitizePolygon(ring);
poly = { ...polygonData, coordinates: [cleaned && cleaned.length >= 3 ? cleaned : ring] };
}
} catch {}
const result = await pool.query(
@@ -446,8 +452,13 @@ router.put('/:propertyId/sections/:sectionId', async (req, res, next) => {
let upoly = polygonData;
try {
const cleaned = sanitizePolygon(polygonData?.coordinates?.[0] || []);
upoly = { ...polygonData, coordinates: [cleaned] };
const ring = polygonData?.coordinates?.[0] || [];
if (captureMethod === 'gps_points' || captureMethod === 'gps_trace') {
upoly = { ...polygonData, coordinates: [ring] };
} else {
const cleaned = sanitizePolygon(ring);
upoly = { ...polygonData, coordinates: [cleaned && cleaned.length >= 3 ? cleaned : ring] };
}
} catch {}
const result = await pool.query(