Skip to content

Commit 87460ef

Browse files
authored
Merge pull request #1774 from lonvia/unitable-example-to-insert
Switch unitable example to insert()
2 parents 00e6912 + 163e3be commit 87460ef

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

flex-config/unitable.lua

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
-- inspect = require('inspect')
66

77
-- We define a single table that can take any OSM object and any geometry.
8+
-- OSM nodes are converted to Points, ways to LineStrings and relations
9+
-- to GeometryCollections. If an object would create an invalid geometry
10+
-- it is still added to the table with a NULL geometry.
811
-- XXX expire will currently not work on these tables.
912
local dtable = osm2pgsql.define_table{
1013
name = "data",
@@ -31,42 +34,29 @@ function clean_tags(tags)
3134
return next(tags) == nil
3235
end
3336

34-
function process(object, geometry_type)
37+
function process(object, geometry)
3538
if clean_tags(object.tags) then
3639
return
3740
end
38-
dtable:add_row({
41+
dtable:insert({
3942
attrs = {
4043
version = object.version,
4144
timestamp = object.timestamp,
4245
},
4346
tags = object.tags,
44-
geom = { create = geometry_type }
47+
geom = geometry
4548
})
4649
end
4750

4851
function osm2pgsql.process_node(object)
49-
process(object, 'point')
52+
process(object, object:as_point())
5053
end
5154

5255
function osm2pgsql.process_way(object)
53-
process(object, 'line')
56+
process(object, object:as_linestring())
5457
end
5558

5659
function 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
60+
process(object, object:as_geometrycollection())
7161
end
7262

0 commit comments

Comments
 (0)