imposm3 icon indicating copy to clipboard operation
imposm3 copied to clipboard

On Generalized table : error Geometry type (MultiPolygon) does not match column type (Polygon)

Open frodrigo opened this issue 3 years ago • 1 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)

https://github.com/openmaptiles/openmaptiles/issues/1018

frodrigo avatar Feb 18 '21 17:02 frodrigo

I tried hard to reproduce this but couldn't with imposm3 v0.11.1, which has 9a98d9c5066e2c751c381b817013111226246895 in it. I see the original report at https://github.com/openmaptiles/openmaptiles/issues/1018#issuecomment-782148237 identified that OMT uses an old version of imposm3. Is it possible it's using one that doesn't support PostGIS 3?

pnorman avatar May 06 '21 19:05 pnorman

Fixed with #263

olt avatar Aug 23 '22 12:08 olt