|
| 1 | +-- This config example file is released into the Public Domain. |
| 2 | + |
| 3 | +-- This config shows how to access the attributes of OSM objects: the version, |
| 4 | +-- changeset id, timestamp, user id and user name. For this to work the |
| 5 | +-- command line option --extra-attributes/-x must be set, otherwise those |
| 6 | +-- fields will be empty. |
| 7 | + |
| 8 | +-- Set this to the projection you want to use |
| 9 | +local srid = 4326 |
| 10 | + |
| 11 | +local tables = {} |
| 12 | + |
| 13 | +tables.points = osm2pgsql.define_node_table('points', { |
| 14 | + { column = 'tags', type = 'hstore' }, |
| 15 | + { column = 'geom', type = 'point', projection = srid }, |
| 16 | + { column = 'version', type = 'int' }, |
| 17 | + { column = 'changeset', type = 'int' }, |
| 18 | + { column = 'created', type = 'timestamp' }, |
| 19 | + { column = 'uid', type = 'int' }, |
| 20 | + { column = 'user', type = 'text' }, |
| 21 | +}) |
| 22 | + |
| 23 | +tables.lines = osm2pgsql.define_way_table('lines', { |
| 24 | + { column = 'tags', type = 'hstore' }, |
| 25 | + { column = 'geom', type = 'linestring', projection = srid }, |
| 26 | + { column = 'version', type = 'int' }, |
| 27 | + { column = 'changeset', type = 'int' }, |
| 28 | + { column = 'created', type = 'timestamp' }, |
| 29 | + { column = 'uid', type = 'int' }, |
| 30 | + { column = 'user', type = 'text' }, |
| 31 | +}) |
| 32 | + |
| 33 | +tables.relations = osm2pgsql.define_relation_table('relations', { |
| 34 | + { column = 'tags', type = 'hstore' }, |
| 35 | + { column = 'version', type = 'int' }, |
| 36 | + { column = 'changeset', type = 'int' }, |
| 37 | + { column = 'created', type = 'timestamp' }, |
| 38 | + { column = 'uid', type = 'int' }, |
| 39 | + { column = 'user', type = 'text' }, |
| 40 | +}) |
| 41 | + |
| 42 | +function osm2pgsql.process_node(object) |
| 43 | + if next(object.tags) == nil then |
| 44 | + return |
| 45 | + end |
| 46 | + |
| 47 | + tables.points:add_row({ |
| 48 | + tags = object.tags, |
| 49 | + version = object.version, |
| 50 | + changeset = object.changeset, |
| 51 | + created = os.date('!%Y-%m-%dT%TZ', object.timestamp), |
| 52 | + uid = object.uid, |
| 53 | + user = object.user |
| 54 | + }) |
| 55 | +end |
| 56 | + |
| 57 | +function osm2pgsql.process_way(object) |
| 58 | + tables.lines:add_row({ |
| 59 | + tags = object.tags, |
| 60 | + version = object.version, |
| 61 | + changeset = object.changeset, |
| 62 | + created = os.date('!%Y-%m-%dT%TZ', object.timestamp), |
| 63 | + uid = object.uid, |
| 64 | + user = object.user |
| 65 | + }) |
| 66 | +end |
| 67 | + |
| 68 | +function osm2pgsql.process_relation(object) |
| 69 | + tables.relations:add_row({ |
| 70 | + tags = object.tags, |
| 71 | + version = object.version, |
| 72 | + changeset = object.changeset, |
| 73 | + created = os.date('!%Y-%m-%dT%TZ', object.timestamp), |
| 74 | + uid = object.uid, |
| 75 | + user = object.user |
| 76 | + }) |
| 77 | +end |
| 78 | + |
0 commit comments