added bootstrap buildings

This commit is contained in:
2026-06-23 10:06:38 +03:00
parent 1639840d2a
commit bb996d0c98
+17 -11
View File
@@ -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