On Generalized table : error Geometry type (MultiPolygon) does not match column type (Polygon)
frodrigo opened this issue · 2 comments
Generalization of multi-polygon table may produce polygon table. Then it fails to update, when the update come with a multipolygon geometry.
The geometry type of generalized table is left to postgres.
When the imported tables is from polygons, the geometry type is geometry(Geometry,3857)
allowing any type of geometry, and it fine.
On generalisation process with a filter (WHERE
), multi-polygon may be excluded. Resulting only with polygon. Postgres compute the type of the column from the data. So it maybe a mix of polygons and multipolygons geometry(Geometry,3857)
or only polygon geometry(Polygon,3857)
.
When an update come with a type of multipolygon while the generalized table is only for polygon, the insert fails with:
ERROR: Geometry type (MultiPolygon) does not match column type (Polygon)
It look like to me the issue com from here:
https://github.com/omniscale/imposm3/blob/master/database/postgis/postgis.go#L335
The generalized field are computed here:
https://github.com/omniscale/imposm3/blob/master/database/postgis/columns.go#L29
and only the name is used.
The column must contain cast to the desired type, from the original field type:
geometry::geometry(Geometry,3857)
I tried hard to reproduce this but couldn't with imposm3 v0.11.1, which has 9a98d9c in it. I see the original report at openmaptiles/openmaptiles#1018 (comment) identified that OMT uses an old version of imposm3. Is it possible it's using one that doesn't support PostGIS 3?