asdfasdf
This commit is contained in:
@@ -371,8 +371,14 @@ router.post('/:id/sections', validateParams(idParamSchema), validateRequest(lawn
|
|||||||
// Sanitize polygon before storing
|
// Sanitize polygon before storing
|
||||||
let poly = polygonData;
|
let poly = polygonData;
|
||||||
try {
|
try {
|
||||||
const cleaned = sanitizePolygon(polygonData?.coordinates?.[0] || []);
|
const ring = polygonData?.coordinates?.[0] || [];
|
||||||
poly = { ...polygonData, coordinates: [cleaned] };
|
// 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 {}
|
} catch {}
|
||||||
|
|
||||||
const result = await pool.query(
|
const result = await pool.query(
|
||||||
@@ -446,8 +452,13 @@ router.put('/:propertyId/sections/:sectionId', async (req, res, next) => {
|
|||||||
|
|
||||||
let upoly = polygonData;
|
let upoly = polygonData;
|
||||||
try {
|
try {
|
||||||
const cleaned = sanitizePolygon(polygonData?.coordinates?.[0] || []);
|
const ring = polygonData?.coordinates?.[0] || [];
|
||||||
upoly = { ...polygonData, coordinates: [cleaned] };
|
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 {}
|
} catch {}
|
||||||
|
|
||||||
const result = await pool.query(
|
const result = await pool.query(
|
||||||
|
|||||||
Reference in New Issue
Block a user