(field: Field, zone: CropZone)
| 1467 | } |
| 1468 | return inside; |
| 1469 | } |
| 1470 | |
| 1471 | function 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 |
no test coverage detected