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.
912local dtable = osm2pgsql .define_table {
1013 name = " data" ,
@@ -31,42 +34,29 @@ function clean_tags(tags)
3134 return next (tags ) == nil
3235end
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 })
4649end
4750
4851function osm2pgsql .process_node (object )
49- process (object , ' point ' )
52+ process (object , object : as_point () )
5053end
5154
5255function osm2pgsql .process_way (object )
53- process (object , ' line ' )
56+ process (object , object : as_linestring () )
5457end
5558
5659function 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 ())
7161end
7262
0 commit comments