UPDATE
This commit is contained in:
@@ -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: "مقدار برآوردشده با وزن دهی زمانی/فضایی",
|
||||
|
||||
Reference in New Issue
Block a user