Forum OSM France

[SOLVED} What is " { create = 'area' }" for?

Hi, i’m creating a relation-table with this code:

local sub = os.getenv("SUB")

local admin_boundaries = osm2pgsql.define_table({
    name = 'osm_' .. sub .. '_admin_boundaries' ,
    ids = { type = 'any', type_column = 'osm_type', id_column = 'osm_id' },
    columns = {
        { column = 'country' },
        { column = 'type' },
        { column = 'name' },
        { column = 'admin_level' },
        { column = 'path', sql_type = 'bigint[]' },
        { column = 'tags', type = 'hstore' },
        { column = 'version' },
        { column = 'timestamp' },
        { column = 'geom', type = 'multipolygon', projection = '4326' }
}})

function process_relation(object)
    local a = {
        country        = '',  
        tags           = object.tags,
        version        = object.version,
        timestamp      = object.timestamp,
        geom           = { create = 'area' }  -- <-------------------------------
    }

    if object.tags.boundary then
       if object.tags.boundary == 'administrative' then 
          if object.tags.admin_level then
             a.type = 'admin'
             a.name = object.tags.name
             a.admin_level = object.tags.admin_level
             a.path = '{}'
             admin_boundaries:add_row(a)   -- <-------------------------------
          end
       end  
    end
end

function osm2pgsql.process_relation(object)
    process_relation(object)
end

This code is running fine and the geom column is what i want.

Now i have to add an additional geometric colum (pointonsurface), which i later need.
Because of now two geometric columns i have to move from add_row(a) to insert(a)

And that does not work :frowning:

if object.tags.boundary then
if object.tags.boundary == ‘administrative’ then
if object.tags.admin_level then
a.type = ‘admin’
a.name = object.tags.name
a.admin_level = object.tags.admin_level
a.path = ‘{}’
admin_boundaries:insert(a) – <----------------------------------
end
end
end

[0] ERROR: Failed to execute Lua function 'osm2pgsql.process_relation': lua/global_only_admin_boundaries_new.lua:36: Error in 'insert': Need geometry data for geometry column 'geom'.

stack traceback:
	[C]: in method 'insert'
	lua/global_only_admin_boundaries_new.lua:36: in function 'process_relation'
	lua/global_only_admin_boundaries_new.lua:43: in function .

{ create = ‘area’ } looks like a method of add_row(), but that’s all i know.

i tryed some other versions but nothing works.

regards
walter

2 posts - 1 participant

Read full topic


Ce sujet de discussion accompagne la publication sur https://community.openstreetmap.org/t/solved-what-is-create-area-for/2937