fix(duckpipe): keep web choropleths polygonal after GDAL rounding - #10
Merged
Conversation
GDAL's COORDINATE_PRECISION collapses islands smaller than the grid into degenerate points/linestrings and wraps the feature in a GeometryCollection (nested for Nouvelle-Aquitaine), which the webapp cannot render: the region showed as 'no data' despite having aggregated scores. Repair written GeoJSON by rebuilding Polygon/MultiPolygon from the polygonal parts and dropping collapse artifacts, and guard all published choropleth layers in the e2e test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problème
Sur la carte « Qualité de vie », la Nouvelle-Aquitaine s'affichait « Pas de donnée » alors que ses agrégats régionaux sont corrects (
stats/regions.json: score_median 0.437, 2457 communes scorées).Cause racine
L'option
COORDINATE_PRECISIONpassée au driver GeoJSON de GDAL dans_copy_geojsonarrondit les coordonnées à l'écriture : les îles plus petites que la grille s'effondrent en Point/LineString dégénérés et GDAL emballe la feature dans uneGeometryCollection. Sur le run publié 2026-07-08 : 3 régions (52, 75, 76), 26 départements en low, 21 en mid. Seule la Nouvelle-Aquitaine avait une collection doublement imbriquée que le front ne rend pas du tout.Correctif
Réparation post-écriture dans
_copy_geojson(entonnoir unique de tous les GeoJSON web) : reconstruction de Polygon/MultiPolygon à partir des parties polygonales, artefacts d'effondrement écartés.L'alternative « pré-arrondi SQL » (
ST_ReducePrecision+ST_CollectionExtract) a été testée et rejetée : elle vide la géométrie de 7 communes réelles à la précision mid (dont Saint-Jean-Cap-Ferrat).Tests
tests/test_publish_web.py: repro déterministe du collapse GDAL (carré + île sous la grille), cas réel de collection imbriquée, contrats de réparation.Validé en rejouant l'export sur le
regions-1000m.geojsonEtalab réel : plus aucune GeometryCollection, la région 75 redevient un MultiPolygon de 755 points.