-
-
Notifications
You must be signed in to change notification settings - Fork 479
Closed
Description
Let's say you want to save some extra data with your OSM import, for example I want to have timestamp of newest node or way in dataset. So I defined extra table for it, keep max timestamp I encounter while processing nodes and ways, and finally try to insert it while processing relations (normal OSM data tables and processing omitted for brevity):
local maxTimestamp = 0
local tables = {}
tables.osm_data_version = osm2pgsql.define_table({
name = 'osm_data_version',
columns = {
{ column = 'timestamp', type = 'bigint', not_null = true }
}
})
function osm2pgsql.process_node(object)
if object.timestamp > maxTimestamp then
maxTimestamp = object.timestamp
end
...
end
function osm2pgsql.process_relation(object)
-- add single row with max timestamp from nodes and ways
if maxTimestamp > 0 then
print('MAXTIMESTAMP:' .. maxTimestamp)
tables.osm_data_version:insert({
timestamp = maxTimestamp
})
maxTimestamp = 0
end
...
end
But if you do this, you will get error:
2025-06-17 07:53:40 ERROR: Failed to execute Lua function 'osm2pgsql.process_relation': test.lua:512: Error in 'insert': Trying to add relation to table 'osm_data_version'.
Looking at source code for this error, it seems that output_flex_t::check_and_get_context_object expect all tables to be node/way/relation tables? So you can't do simple insert into "custom" table like this anymore? (I say anymore, because this has to be new, I used to do this successfully some time ago).
Metadata
Metadata
Assignees
Labels
No labels