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
|
private function updateSpatialMeta(string $id): void
|
||||||
{
|
{
|
||||||
// 1) Filtrer les micro-polygones < MIN_POLYGON_AREA_M2 avant simplification
|
// 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.
|
// 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(
|
$this->em->getConnection()->executeStatement(
|
||||||
"UPDATE sargassum_observation
|
"UPDATE sargassum_observation
|
||||||
SET geometry = (
|
SET geometry = (
|
||||||
SELECT COALESCE(
|
SELECT COALESCE(
|
||||||
ST_Collect(geom),
|
ST_Multi(ST_CollectionExtract(ST_Collect(geom), 3)),
|
||||||
'GEOMETRYCOLLECTION EMPTY'::geometry
|
ST_GeomFromText('MULTIPOLYGON EMPTY', 4326)
|
||||||
)
|
)
|
||||||
FROM (
|
FROM (
|
||||||
SELECT (ST_Dump(geometry)).geom AS geom
|
SELECT (ST_Dump(geometry)).geom AS geom
|
||||||
|
FROM sargassum_observation
|
||||||
|
WHERE id = :id
|
||||||
) parts
|
) parts
|
||||||
WHERE ST_Area(geom::geography) >= :minArea
|
WHERE ST_Area(parts.geom::geography) >= :minArea
|
||||||
)
|
)
|
||||||
WHERE id = :id",
|
WHERE id = :id",
|
||||||
['id' => $id, 'minArea' => self::MIN_POLYGON_AREA_M2]
|
['id' => $id, 'minArea' => self::MIN_POLYGON_AREA_M2]
|
||||||
|
|||||||
Reference in New Issue
Block a user