MCPcopy Create free account
hub / github.com/Thanas-R/Virdis / getZonePlacementMetrics

Function getZonePlacementMetrics

src/components/CropPlanningSection.tsx:1469–1485  ·  view source on GitHub ↗
(field: Field, zone: CropZone)

Source from the content-addressed store, hash-verified

1467 }
1468 return inside;
1469}
1470
1471function getZonePlacementMetrics(field: Field, zone: CropZone): ZonePlacementMetrics {
1472 const zoneAreaSqM = Math.max(field.area * 10000 * (zone.area_pct / 100), 90);
1473 const exactSpacing = Math.max(zone.spacing_m, 0.2);
1474 const exactPlantCount = Math.max(1, Math.round(zoneAreaSqM / (exactSpacing * exactSpacing)));
1475 const maxForZone = Math.round(MAX_GRID_MARKERS_TOTAL * (zone.area_pct / 100));
1476 const visualSpacing = exactPlantCount > maxForZone ? Math.sqrt(zoneAreaSqM / maxForZone) : exactSpacing;
1477 const visualPlantCount = Math.max(1, Math.round(zoneAreaSqM / (visualSpacing * visualSpacing)));
1478
1479 return {
1480 zoneAreaSqM,
1481 exactSpacing,
1482 visualSpacing: roundTo(visualSpacing, 1),
1483 exactPlantCount,
1484 visualPlantCount,
1485 sampled: visualSpacing > exactSpacing,
1486 };
1487}
1488

Callers 1

CropPlanningSectionFunction · 0.85

Calls 1

roundToFunction · 0.85

Tested by

no test coverage detected