1

getting the following error when attempting to load data into pgsql database with osm2pgsql:

ERROR: Failed to execute Lua function 'osm2pgsql.process_node': test.lua:183: unknown field 'as_point'
stack traceback:
    [C]: in function 'error'
    [string "..."]:178: in metamethod '__index'

The associated line 178 is just inside the tables.node:insert() method calling the geom = object:as_point().

The only thing I can think of is the limited resources available (i.e. a rpi with 1gb of memory but the osm.pbf file is quite small as well.)

Any help is appreciated.

evan
  • 169
  • 3
  • 12
  • your error says that your `object` does not have an `as_point`, i am unsure how you got to your conclusion as to the nature of the problem. – Nifim Mar 10 '23 at 17:40
  • Because I was using one of the example scripts only changing names of tables. A facsimile had worked on a different computer previously. – evan Mar 11 '23 at 11:09

1 Answers1

0

The as_point function seems to been added in a newer version. I am currently using the version 1.6.0 and therefore had to adjust my lua script a bit. You can find the old syntax via the osm2pgsql git history.

Example lua script that works in version 1.6.0:

local tables = {}

tables.public_transport_stop = osm2pgsql.define_table({
    name = 'public_transport_stop',
    ids = { type = 'node', id_column = 'osm_id' },
    columns = {
        { column = 'tags', type = 'jsonb' },
        { column = 'geom', type = 'point', projection = 4326, not_null = true },
    },
    schema = 'osm'
})

function osm2pgsql.process_node(object)
    if object.tags.railway == 'station' then
        tables.public_transport_stop:add_row({
            tags = object.tags
        })
    end
end
Jonas Frei
  • 182
  • 1
  • 4
  • 17