fix: distance sargasses = min(patches) live ST_Dump, plus fiable que la valeur stockée
This commit is contained in:
@@ -49,6 +49,16 @@ class SpotScoreController extends AbstractController
|
|||||||
$current = $this->scoreService->getCachedScore($id);
|
$current = $this->scoreService->getCachedScore($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$patches = $this->loadPatches($id);
|
||||||
|
|
||||||
|
// La distance issue des patches (ST_Dump live) est plus fiable que
|
||||||
|
// distance_to_nearest_sargassum stockée (peut venir d'une obs lointaine).
|
||||||
|
// On l'utilise comme référence si des patches sont détectés à proximité.
|
||||||
|
if ($current !== null && !empty($patches)) {
|
||||||
|
$minPatchDist = min(array_column($patches, 'distanceKm'));
|
||||||
|
$current['distance'] = $minPatchDist;
|
||||||
|
}
|
||||||
|
|
||||||
$currentDistanceKm = $current !== null ? $current['distance'] : null;
|
$currentDistanceKm = $current !== null ? $current['distance'] : null;
|
||||||
|
|
||||||
return $this->json([
|
return $this->json([
|
||||||
@@ -57,7 +67,7 @@ class SpotScoreController extends AbstractController
|
|||||||
'type' => $spot->getType(),
|
'type' => $spot->getType(),
|
||||||
'region' => $spot->getRegion(),
|
'region' => $spot->getRegion(),
|
||||||
'score' => $current,
|
'score' => $current,
|
||||||
'patches' => $this->loadPatches($id),
|
'patches' => $patches,
|
||||||
'horizons' => $this->loadHorizonScores($id, $currentDistanceKm),
|
'horizons' => $this->loadHorizonScores($id, $currentDistanceKm),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user