diff --git a/backend/src/routes/properties.js b/backend/src/routes/properties.js index 2b2c255..09ec203 100644 --- a/backend/src/routes/properties.js +++ b/backend/src/routes/properties.js @@ -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(