Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5905 closed defect (fixed)

CartoDB geometry type declarations too correct

Reported by: pramsey Owned by: Even Rouault
Priority: normal Milestone: 2.0.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc:

Description

It looks like the CartoDB driver is declaring geometry columns with actual geometry types

create table foo (
  the_geom geometry(polygon,4326)
)

CartoDB prefers more generic declarations,

create table foo (
  the_geom geometry(geometry,4326)
)

I discovered this by running the same import routine twice, the second in -append mode, and got this error:

ERROR 1: Error returned by server : Geometry type (Polygon) does not match column type (MultiPolygon)

which brings up a second mystery, of how the column type got defined to multipolygon when the input type was polygon?

Change History (7)

comment:1 by Even Rouault, 9 years ago

The PostGIS driver also creates column with strong typing, ala "the_geom geometry(polygon,4326)". By removing that strong typing, this would allow multiple geometry types to be mixed, potential points, lines, polygons in the same column.

Regarding your second issue, this might come if you import a shapefile. The shapefile driver currently returns polygon or multipolygon, but declare the layer geometry type as polygon. This is a long known feature/issue. But your use case seems to be the reverse way, so I'm a bit confused. Maybe the layer was created with -nlt MULTIPOLYGON, and then the append was done after without specifying it ?

comment:2 by pramsey, 9 years ago

No, the commands to create it were basically the same:

ogr2ogr --config CARTODB_API_KEY e44...66  -f 'CartoDB' 'CartoDB:pramsey' g50.shp

and then

ogr2ogr --config CARTODB_API_KEY e44...66 -append -f 'CartoDB' 'CartoDB:pramsey' g50.shp

comment:3 by Even Rouault, 9 years ago

Ah ok, I did actually try the above and was doubly wrong: 1) To avoid this annoying issue with shapefiles, I actually *did* implement automatic Polygon->MultiPolygon promotion in the CartoDB driver, when creating a new table, when the declared geometry type of the source layer is Polygon 2) But in the second step, the driver currently fails to retrieve the actually geometry type, so CreateFeature() doesn't no longer do the Polygon->MultiPolygon promotion. The fix would be to improve the driver to retrieve the layer geometry type in read/update mode.

A workaround for your second step would actually be to add -nlt multipolygon.

comment:4 by javisantana, 9 years ago

The PostGIS driver also creates column with strong typing, ala "the_geom geometry(polygon,4326)". By removing that strong typing, this would allow multiple geometry types to be mixed, potential points, lines, polygons in the same column.

That's something we allow, editor wizard does not support that, but the everything is working with mixed types

comment:5 by Even Rouault, 9 years ago

You can disable strong geometry typing on conversion by adding -nlt GEOMETRY to the ogr2ogr command line.

The advantage of keeping the geometry type of the source (when it is strongly typed) in the CartoDB table declaration is that it makes conversion from CartoDB back to an "old" GIS format or consumption by GIS applications easier.

comment:6 by Even Rouault, 9 years ago

Milestone: 1.11.32.0
Resolution: fixed
Status: newclosed

trunk r28990 "CartoDB: properly identify geometry type on authenticated opening. Enable by default batch insertion of features in update mode (#5905)"

comment:7 by Even Rouault, 9 years ago

Milestone: 2.02.0.0

Milestone renamed

Note: See TracTickets for help on using tickets.