Casting to MultiPolygon and MultiPolyLine from "untyped" formats
|Reported by:||lpercich||Owned by:||warmerdam|
|Severity:||normal||Keywords:||MapInfo, MultiPolygon, MultiPolyLine|
MapInfo has no geometric typing at the schema (column) level (i.e. the geometric column type in MapInfo is always "GEOMETRY"); nor it makes distinction at the programmatic or data model level between Polygons and Multipolygons, or PolyLines and MultiPolyLines. Thus when reading a "MultiPolygon" MapInfo layer in OGR, the one-ring poligons will be read as Polygons, and not as one-element MultiPolygons.
I don't know if other formats have the same limitation with geometric typing. The best solution anyway could be adding a -lco TO_MULTI=ON|OFF to force casting single geometries into collections of one geometry. (More than a -lco this is related with the source format)
As a workaround, I'm generating SQL with WKT through PGDump format, and processing it with sed:
sed -r 's/;(POLYGON|LINESTRING)[ ]*\(([\(\)0-9,\. ]+)\)/;MULTI\1 ((\2))/' "$sqlsingle" >> $sqlmulti
which is faster than inserting into an untyped geometry temp PG table, updating with multi(geom) and inserting into the final table.