[Tile-serving] [openstreetmap/osm2pgsql] Make it easier to reproduce --hstore behavior with flex backend (#1123)
Jochen Topf
notifications at github.com
Thu Apr 16 07:07:45 UTC 2020
There is one useful function `grab_tag` which pulls one tag out of the tags table which simplifies the content of your for-loop. See the `data-types.lua` example on how to use this.
Apart from that this looks pretty okay to me. I'd probably start with a list of text column names only, build the columns config for the define_table from that and then iterate over that using `grab_tag` to pull out the tags. Something like this (untested):
```
text_columns = {'foo', ...}
point_columns = {
{ column = 'geom', type = 'point' },
{ column = 'tags', type = 'hstore' }
}
for i,c in ipairs(text_columns) do
table.insert(point_columns, { column = c, type = 'text' }
end
tables.point = osm2pgsql.define_table{
name = 'planet_osm_point',
ids = { type = 'node', id_column = 'osm_id' },
columns = point_columns
}
function osm2pgsql.process_node(object)
if next(object.tags) == nil then
return
end
output_cols = { tags = object.tags }
for c in text_columns do
output_cols[c] = object:grab_tag(c)
done
tables.point:add_row(output_cols)
end
```
The `compatible.lua` was written to be compatible with the C transform, which doesn't have hstore in it if I remember correctly. But I think it would be great to have a `compatible-c.lua` and `compatible-lua.lua` example/test configuration to mimic the C transform as well as the default lua transform.
--
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/1123#issuecomment-614456518
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20200416/bf47a55a/attachment.htm>
More information about the Tile-serving
mailing list