fix: GeometryCollection incompatible avec colonne MultiPolygon
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user