1-- This config example file is released into the Public Domain. 2 3-- Put all OSM data into a single table 4 5-- inspect = require('inspect') 6 7-- We define a single table that can take any OSM object and any geometry. 8-- XXX expire will currently not work on these tables. 9local dtable = osm2pgsql.define_table{ 10 name = "data", 11 -- This will generate a column "osm_id INT8" for the id, and a column 12 -- "osm_type CHAR(1)" for the type of object: N(ode), W(way), R(relation) 13 ids = { type = 'any', id_column = 'osm_id', type_column = 'osm_type' }, 14 columns = { 15 { column = 'attrs', type = 'jsonb' }, 16 { column = 'tags', type = 'jsonb' }, 17 { column = 'geom', type = 'geometry' }, 18 } 19} 20 21-- print("columns=" .. inspect(dtable:columns())) 22 23-- Helper function to remove some of the tags we usually are not interested in. 24-- Returns true if there are no tags left. 25function clean_tags(tags) 26 tags.odbl = nil 27 tags.created_by = nil 28 tags.source = nil 29 tags['source:ref'] = nil 30 31 return next(tags) == nil 32end 33 34function process(object, geometry_type) 35 if clean_tags(object.tags) then 36 return 37 end 38 dtable:add_row({ 39 attrs = { 40 version = object.version, 41 timestamp = object.timestamp, 42 }, 43 tags = object.tags, 44 geom = { create = geometry_type } 45 }) 46end 47 48function osm2pgsql.process_node(object) 49 process(object, 'point') 50end 51 52function osm2pgsql.process_way(object) 53 process(object, 'line') 54end 55 56function osm2pgsql.process_relation(object) 57 if clean_tags(object.tags) then 58 return 59 end 60 61 if object.tags.type == 'multipolygon' or object.tags.type == 'boundary' then 62 dtable:add_row({ 63 attrs = { 64 version = object.version, 65 timestamp = object.timestamp, 66 }, 67 tags = object.tags, 68 geom = { create = 'area' } 69 }) 70 end 71end 72 73