@@ -3,7 +3,7 @@ local tables = {}
33
44tables .point = osm2pgsql .define_node_table (' osm2pgsql_test_point' , {
55 { column = ' tags' , type = ' hstore' },
6- { column = ' geom' , type = ' point' },
6+ { column = ' geom' , type = ' point' , not_null = true },
77})
88
99tables .line = osm2pgsql .define_table {
@@ -12,7 +12,7 @@ tables.line = osm2pgsql.define_table{
1212 columns = {
1313 { column = ' tags' , type = ' hstore' },
1414 { column = ' name' , type = ' text' },
15- { column = ' geom' , type = ' linestring' },
15+ { column = ' geom' , type = ' linestring' , not_null = true },
1616 },
1717 cluster = ' auto'
1818}
@@ -23,8 +23,8 @@ tables.polygon = osm2pgsql.define_table{
2323 columns = {
2424 { column = ' tags' , type = ' hstore' },
2525 { column = ' name' , type = ' text' },
26- { column = ' geom' , type = ' geometry' },
27- { column = ' area' , type = ' area ' },
26+ { column = ' geom' , type = ' geometry' , not_null = true },
27+ { column = ' area' , type = ' real ' },
2828 }
2929}
3030
@@ -33,7 +33,7 @@ tables.route = osm2pgsql.define_table{
3333 ids = { type = ' relation' , id_column = ' osm_id' },
3434 columns = {
3535 { column = ' tags' , type = ' hstore' },
36- { column = ' geom' , type = ' multilinestring' },
36+ { column = ' geom' , type = ' multilinestring' , not_null = true },
3737 }
3838}
3939
@@ -85,8 +85,9 @@ function osm2pgsql.process_node(object)
8585 return
8686 end
8787
88- tables .point :add_row ({
89- tags = object .tags
88+ tables .point :insert ({
89+ tags = object .tags ,
90+ geom = object :as_point ()
9091 })
9192end
9293
@@ -96,15 +97,18 @@ function osm2pgsql.process_way(object)
9697 end
9798
9899 if is_polygon (object .tags ) then
99- tables .polygon :add_row ({
100+ local geom = object :as_polygon ()
101+ tables .polygon :insert ({
100102 tags = object .tags ,
101103 name = object .tags .name ,
102- geom = { create = ' area' }
104+ geom = geom ,
105+ area = geom :area ()
103106 })
104107 else
105- tables .line :add_row ({
108+ tables .line :insert ({
106109 tags = object .tags ,
107- name = object .tags .name
110+ name = object .tags .name ,
111+ geom = object :as_linestring ()
108112 })
109113 end
110114end
@@ -115,18 +119,22 @@ function osm2pgsql.process_relation(object)
115119 end
116120
117121 if object .tags .type == ' multipolygon' or object .tags .type == ' boundary' then
118- tables .polygon :add_row ({
119- tags = object .tags ,
120- name = object .tags .name ,
121- geom = { create = ' area' , split_at = ' multi' }
122- })
122+ local mgeom = object :as_multipolygon ()
123+ for sgeom in mgeom :geometries () do
124+ tables .polygon :insert ({
125+ tags = object .tags ,
126+ name = object .tags .name ,
127+ geom = sgeom ,
128+ area = sgeom :area ()
129+ })
130+ end
123131 return
124132 end
125133
126134 if object .tags .type == ' route' then
127- tables .route :add_row ({
135+ tables .route :insert ({
128136 tags = object .tags ,
129- geom = { create = ' line ' }
137+ geom = object : as_multilinestring ()
130138 })
131139 end
132140end
0 commit comments