added bootstrap buildings
This commit is contained in:
@@ -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,24 +52,30 @@ 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)
|
||||||
buildings:add_row({
|
local ok, err = pcall(function()
|
||||||
osm_id = object.id,
|
buildings:add_row({
|
||||||
geom = geom,
|
osm_id = object.id,
|
||||||
height_m = height_m,
|
geom = geom,
|
||||||
levels = levels,
|
height_m = height_m,
|
||||||
building_type = object.tags.building,
|
levels = levels,
|
||||||
source = source,
|
building_type = object.tags.building,
|
||||||
})
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user