|
| 1 | + |
| 2 | +local tables = {} |
| 3 | + |
| 4 | +tables.nodes = osm2pgsql.define_node_table('osm2pgsql_test_nodes', { |
| 5 | + { column = 'tags', type = 'jsonb' }, |
| 6 | + { column = 'tagged', type = 'bool' }, |
| 7 | + { column = 'geom', type = 'point', not_null = true }, |
| 8 | +}) |
| 9 | + |
| 10 | +tables.ways = osm2pgsql.define_way_table('osm2pgsql_test_ways', { |
| 11 | + { column = 'tags', type = 'jsonb' }, |
| 12 | + { column = 'tagged', type = 'bool' }, |
| 13 | + { column = 'geom', type = 'linestring', not_null = true }, |
| 14 | +}) |
| 15 | + |
| 16 | +tables.relations = osm2pgsql.define_relation_table('osm2pgsql_test_relations', { |
| 17 | + { column = 'tags', type = 'jsonb' }, |
| 18 | + { column = 'tagged', type = 'bool' }, |
| 19 | + { column = 'geom', type = 'geometry', not_null = true }, |
| 20 | +}) |
| 21 | + |
| 22 | +function insert(dtable, object, tagged, geom) |
| 23 | + tables[dtable]:insert({ |
| 24 | + tags = object.tags, |
| 25 | + tagged = tagged, |
| 26 | + geom = geom, |
| 27 | + }) |
| 28 | +end |
| 29 | + |
| 30 | +function osm2pgsql.process_node(object) |
| 31 | + insert('nodes', object, true, object:as_point()) |
| 32 | +end |
| 33 | + |
| 34 | +function osm2pgsql.process_way(object) |
| 35 | + insert('ways', object, true, object:as_linestring()) |
| 36 | +end |
| 37 | + |
| 38 | +function osm2pgsql.process_relation(object) |
| 39 | + insert('relations', object, true, object:as_geometrycollection()) |
| 40 | +end |
| 41 | + |
| 42 | +function osm2pgsql.process_untagged_node(object) |
| 43 | + insert('nodes', object, false, object:as_point()) |
| 44 | +end |
| 45 | + |
| 46 | +function osm2pgsql.process_untagged_way(object) |
| 47 | + insert('ways', object, false, object:as_linestring()) |
| 48 | +end |
| 49 | + |
| 50 | +function osm2pgsql.process_untagged_relation(object) |
| 51 | + insert('relations', object, false, object:as_geometrycollection()) |
| 52 | +end |
| 53 | + |
0 commit comments