Opened 11 years ago

Closed 11 years ago

#4034 closed enhancement (invalid)

Casting to MultiPolygon and MultiPolyLine from "untyped" formats

Reported by: lpercich Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: MapInfo, MultiPolygon, MultiPolyLine
Cc:

Description

I'm having problems when inserting MapInfo data into a PostgreSQL table with a MultiPolygon or MultiPolyLine geometry column.

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.

Attachments (1)

test_OGR_PGDump_multi.zip (5.2 KB ) - added by lpercich 11 years ago.
Generating a PG Dump from a MapInfo table containing polygons and multipolygons

Download all attachments as: .zip

Change History (4)

by lpercich, 11 years ago

Attachment: test_OGR_PGDump_multi.zip added

Generating a PG Dump from a MapInfo table containing polygons and multipolygons

comment:1 by Even Rouault, 11 years ago

Did you try the -nlt MULTILINESTRING or -nlt MULTIPOLYGON options of ogr2ogr ? It looks like it is what you need

in reply to:  1 comment:2 by lpercich, 11 years ago

Replying to rouault:

Did you try the -nlt MULTILINESTRING or -nlt MULTIPOLYGON options of ogr2ogr ? It looks like it is what you need

Yes, you are right! I just tried it with PGDump and PostGIS driver, works fine both when creating the layer and when appending to an existing layer of the appropriate type. I will RTMT (Read the manual... TWICE!)

In this case, shall I close the ticket? Or will you do it?

Thanks for your patience

Sig

comment:3 by Even Rouault, 11 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.