@@ -27,6 +27,9 @@ ZRES11 = 76.4
2727ZRES12 = 38.2
2828ZRES13 = 19.1
2929
30+ -- The height of one floor, in meters
31+ BUILDING_FLOOR_HEIGHT = 3.66
32+
3033-- Process node/way tags
3134aerodromeValues = Set { " international" , " public" , " regional" , " military" , " private" }
3235
@@ -403,6 +406,7 @@ function way_function(way)
403406 -- Set 'building' and associated
404407 if building ~= " " then
405408 way :Layer (" building" , true )
409+ SetBuildingHeightAttributes (way )
406410 SetMinZoomByArea (way )
407411 end
408412
@@ -572,6 +576,30 @@ function GetPOIRank(obj)
572576 return nil ,nil ,nil
573577end
574578
579+ function SetBuildingHeightAttributes (way )
580+ local height = tonumber (way :Find (" height" ), 10 )
581+ local minHeight = tonumber (way :Find (" min_height" ), 10 )
582+ local levels = tonumber (way :Find (" building:levels" ), 10 )
583+ local minLevel = tonumber (way :Find (" building:min_level" ), 10 )
584+
585+ local renderHeight = BUILDING_FLOOR_HEIGHT
586+ if height or levels then
587+ renderHeight = height or (levels * BUILDING_FLOOR_HEIGHT )
588+ end
589+ local renderMinHeight = 0
590+ if minHeight or minLevel then
591+ renderMinHeight = minHeight or (minLevel * BUILDING_FLOOR_HEIGHT )
592+ end
593+
594+ -- Fix upside-down buildings
595+ if renderHeight < renderMinHeight then
596+ renderHeight = renderHeight + renderMinHeight
597+ end
598+
599+ way :AttributeNumeric (" render_height" , renderHeight )
600+ way :AttributeNumeric (" render_min_height" , renderMinHeight )
601+ end
602+
575603-- ==========================================================
576604-- Lua utility functions
577605
0 commit comments