From 997e2d186c29012dc072e05afb431081ea5ebfd8 Mon Sep 17 00:00:00 2001 From: Gwadaking Date: Thu, 2 Apr 2026 17:06:42 -0400 Subject: [PATCH] fix: GeometryCollection incompatible avec colonne MultiPolygon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ST_Collect peut retourner une GeometryCollection selon les sous-types. Correction : ST_CollectionExtract(..., 3) extrait uniquement les polygones, ST_Multi garantit le type MultiPolygon, ST_GeomFromText fournit un fallback vide typé correctement. Co-Authored-By: Claude Sonnet 4.6 --- backend/src/Service/Ingestion/IngestionService.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/src/Service/Ingestion/IngestionService.php b/backend/src/Service/Ingestion/IngestionService.php index e8ba90f..47ac937 100644 --- a/backend/src/Service/Ingestion/IngestionService.php +++ b/backend/src/Service/Ingestion/IngestionService.php @@ -222,19 +222,23 @@ class IngestionService private function updateSpatialMeta(string $id): void { - // 1) Filtrer les micro-polygones < MIN_POLYGON_AREA_M2 avant simplification - // Un fragment < 1 km² en plein océan est du bruit ou un artefact atmo. + // 1) Filtrer les micro-polygones < MIN_POLYGON_AREA_M2 avant simplification. + // ST_CollectionExtract(..., 3) extrait uniquement les Polygon pour éviter + // que ST_Collect retourne une GeometryCollection incompatible avec la colonne. + // ST_Multi force le type MultiPolygon même pour un seul polygone résiduel. $this->em->getConnection()->executeStatement( "UPDATE sargassum_observation SET geometry = ( SELECT COALESCE( - ST_Collect(geom), - 'GEOMETRYCOLLECTION EMPTY'::geometry + ST_Multi(ST_CollectionExtract(ST_Collect(geom), 3)), + ST_GeomFromText('MULTIPOLYGON EMPTY', 4326) ) FROM ( SELECT (ST_Dump(geometry)).geom AS geom + FROM sargassum_observation + WHERE id = :id ) parts - WHERE ST_Area(geom::geography) >= :minArea + WHERE ST_Area(parts.geom::geography) >= :minArea ) WHERE id = :id", ['id' => $id, 'minArea' => self::MIN_POLYGON_AREA_M2]