From bb996d0c980536c413a4ff900918dad320e91d56 Mon Sep 17 00:00:00 2001 From: grigo Date: Tue, 23 Jun 2026 10:06:38 +0300 Subject: [PATCH] added bootstrap buildings --- scripts/osm2pgsql_buildings.lua | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/osm2pgsql_buildings.lua b/scripts/osm2pgsql_buildings.lua index bb7db33..bc0bd30 100644 --- a/scripts/osm2pgsql_buildings.lua +++ b/scripts/osm2pgsql_buildings.lua @@ -1,6 +1,6 @@ local buildings = osm2pgsql.define_area_table('buildings', { { column = 'osm_id', type = 'bigint', not_null = true }, - { column = 'geom', type = 'multipolygon', projection = 4326, not_null = true }, + { column = 'geom', type = 'geometry', projection = 4326, not_null = true }, { column = 'height_m', type = 'real', not_null = true }, { column = 'levels', type = 'int' }, { column = 'building_type', type = 'text' }, @@ -52,24 +52,30 @@ local function add_building(object, geom) end local height_m, levels, source = building_height(object.tags) - buildings:add_row({ - osm_id = object.id, - geom = geom, - height_m = height_m, - levels = levels, - building_type = object.tags.building, - source = source, - }) + local ok, err = pcall(function() + buildings:add_row({ + osm_id = object.id, + geom = geom, + height_m = height_m, + levels = levels, + building_type = object.tags.building, + source = source, + }) + end) + + if not ok then + print('skip building ' .. tostring(object.id) .. ': ' .. tostring(err)) + end end function osm2pgsql.process_way(object) if object.is_closed then - add_building(object, object:as_multipolygon()) + add_building(object, object:as_polygon()) end end function osm2pgsql.process_relation(object) - if object.tags.type == 'multipolygon' or object.tags.type == 'boundary' then + if object.tags.type == 'multipolygon' then add_building(object, object:as_multipolygon()) end end