added bootstrap buildings

This commit is contained in:
2026-06-23 10:06:38 +03:00
parent 1639840d2a
commit bb996d0c98
+9 -3
View File
@@ -1,6 +1,6 @@
local buildings = osm2pgsql.define_area_table('buildings', { local buildings = osm2pgsql.define_area_table('buildings', {
{ column = 'osm_id', type = 'bigint', not_null = true }, { 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 = 'height_m', type = 'real', not_null = true },
{ column = 'levels', type = 'int' }, { column = 'levels', type = 'int' },
{ column = 'building_type', type = 'text' }, { column = 'building_type', type = 'text' },
@@ -52,6 +52,7 @@ local function add_building(object, geom)
end end
local height_m, levels, source = building_height(object.tags) local height_m, levels, source = building_height(object.tags)
local ok, err = pcall(function()
buildings:add_row({ buildings:add_row({
osm_id = object.id, osm_id = object.id,
geom = geom, geom = geom,
@@ -60,16 +61,21 @@ local function add_building(object, geom)
building_type = object.tags.building, building_type = object.tags.building,
source = source, source = source,
}) })
end)
if not ok then
print('skip building ' .. tostring(object.id) .. ': ' .. tostring(err))
end
end end
function osm2pgsql.process_way(object) function osm2pgsql.process_way(object)
if object.is_closed then if object.is_closed then
add_building(object, object:as_multipolygon()) add_building(object, object:as_polygon())
end end
end end
function osm2pgsql.process_relation(object) 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()) add_building(object, object:as_multipolygon())
end end
end end