[Tile-serving] [openstreetmap/osm2pgsql] Can't use multipolygon as column type using flex (#1313)

MasterR8 notifications at github.com
Sun Nov 8 15:32:58 UTC 2020


I have a lua script I use to transform data and load it into the database. In my database, I would like to have a table osm_boundary with multipolygons: 
```lua
tables.osm_boundary = osm2pgsql.define_table{
    name = "osm_boundary",
    ids = { type = 'area', id_column = 'osm_id'},
    columns = {
        { column = 'osm_version', type = 'integer'},
        { column = 'osm_timestamp', type = 'timestamptz'},
        { column = 'name', type = 'text' },
        { column = 'label', type = 'text' },
        { column = 'tags', type = 'hstore' },
        { column = 'geom', type = 'multipolygon' }
    }
} 
```
while processing relations, I search for relations with type=multipolygons with the tag boundary and try to add them into my table. In the future I also want to expand my search by relations with type=boundary. In the documentation it is stated, that in order to keep polygons as multipolygons I need to add a multi parameter to the transformation.
```lua
    local type = object.tags.type

    if (type == 'multipolygon' and object.tags.boundary) then

        tables.osm_boundary:add_row({
            osm_version = version,
            osm_timestamp = getTimestamp(object.timestamp),
            name = object.tags.name,
            label = label,
            tags = object.tags,
            geom = { create = 'area', multi = true }
        })
        return
    end
```
Starting osm2pgsql with this script leads to the following output:
```
b'osm2pgsql version 1.3.0 (1.3.0)\n\nAllocating memory for dense node cache\nAllocating dense node cache in one big chunk\nAllocating memory for sparse node cache\nSharing dense sparse\nNode-cache: cache=800MB, maxblocks=12800*65536, allocation method=11\nMid: pgsql, cache=800\nSetting up table: planet_osm_nodes\nSetting up table: planet_osm_ways\nSetting up table: planet_osm_rels\nUsing projection SRS 4326 (Latlong)\n\nReading in file: /data/all-countries.osm.pbf\nUsing PBF parser.\n\rProcessing: Node(50k 50.0k/s) Way(0k 0.00k/s) Relation(0 0.0/s)\rProcessing: Node(283k 141.5k/s) Way(1k 1.00k/s) Relation(0 0.0/s)\rProcessing: Node(283k 141.5k/s) Way(22k 22.00k/s) Relation(0 0.0/s)\rProcessing: Node(283k 141.5k/s) Way(28k 28.00k/s) Relation(849 849.0/s)  parse time: 3s\nNode stats: total(283696), max(8084224264) in 2s\nWay stats: total(28040), max(867264596) in 1s\nRelation stats: total(849), max(11559074) in 0s\nresult COPY END for osm_boundary failed: ERROR:  Geometry type (Polygon) does not match column type (MultiPolygon)\nCONTEXT:  COPY osm_boundary, line 1, column geom: "0103000020E6100000010000000B00000075988AE83244234013A8B4B4098B4740AFAA03C534442340157A5803EF8A47408F..."\n\nDB copy thread failed: Ending COPY mode\nNo marked ways (Skipping stage 2).\n'
```
with the error
```
ERROR:  Geometry type (Polygon) does not match column type (MultiPolygon)\nCONTEXT:  COPY osm_boundary, line 1, column geom: 
```
and an empty table:
```
select * from osm_boundary;
 osm_id | osm_version | osm_timestamp | name | label | tags | admin_level | geom 
--------+-------------+---------------+------+-------+------+-------------+------
(0 rows)
```
Pleas help me get a Solution. Thank you in advance

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/issues/1313
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20201108/a2010f7d/attachment.htm>


More information about the Tile-serving mailing list