This commit is contained in:
2026-05-13 16:45:54 +03:30
parent 948c062b93
commit 46fe62fa04
96 changed files with 3834 additions and 155 deletions
+12
View File
@@ -281,6 +281,8 @@ def _heatmap_summary(sensor_points: list[dict[str, Any]], grid_cells: list[dict[
class SoilMoistureHeatmapService:
def get_heatmap(self, *, farm_uuid: str) -> dict[str, Any]:
# Spatial-first endpoint: preserve grid/cluster-aware output and never flatten the
# heatmap to a single farm-average metric. Aggregated summaries are supplementary only.
current_sensor = (
SensorData.objects.select_related("center_location")
.prefetch_related("plant_assignments__plant")
@@ -329,6 +331,11 @@ class SoilMoistureHeatmapService:
],
},
"summary": _heatmap_summary(sensor_points, []),
"source_metadata": {
"endpoint_policy": "spatial_first",
"primary_source": "sensor_network_spatial_interpolation",
"agronomic_aggregation": "supplementary_only",
},
"quality_legend": {
QUALITY_REAL: "اندازه گیری واقعی سنسور",
QUALITY_INTERPOLATED: "مقدار برآوردشده با وزن دهی زمانی/فضایی",
@@ -438,6 +445,11 @@ class SoilMoistureHeatmapService:
],
},
"summary": _heatmap_summary(sensor_points, [cell for cell in grid_cells if cell["inside_farm_boundary"]]),
"source_metadata": {
"endpoint_policy": "spatial_first",
"primary_source": "sensor_network_spatial_interpolation",
"agronomic_aggregation": "supplementary_only",
},
"quality_legend": {
QUALITY_REAL: "اندازه گیری واقعی سنسور",
QUALITY_INTERPOLATED: "مقدار برآوردشده با وزن دهی زمانی/فضایی",