Skip to content

Commit 7b206a7

Browse files
committed
feat: export and render building:part
1 parent b89b0eb commit 7b206a7

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

resources/process-openmaptiles.lua

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ function way_function()
382382
local write_name = false
383383
local construction = Find("construction")
384384
local is_highway_area = highway~="" and Find("area")=="yes" and is_closed
385+
local building_part = Find("building:part")
385386

386387
-- Miscellaneous preprocessing
387388
if Find("disused") == "yes" then return end
@@ -645,7 +646,7 @@ function way_function()
645646
end
646647

647648
-- Set 'building' and associated
648-
if building~="" then
649+
if building~="" or building_part~="" then
649650
Layer("building", true)
650651
SetBuildingHeightAttributes()
651652
SetMinZoomByArea()
@@ -868,17 +869,28 @@ end
868869

869870
function SetBuildingHeightAttributes()
870871
local height = tonumber(Find("height"), 10)
872+
local buildingHeight = tonumber(Find("building:height"), 10)
873+
local finalHeight = height or buildingHeight
874+
871875
local minHeight = tonumber(Find("min_height"), 10)
872-
local levels = tonumber(Find("building:levels"), 10)
873-
local minLevel = tonumber(Find("building:min_level"), 10)
876+
local buildingMinHeight = tonumber(Find("building:min_height"), 10)
877+
local finalMinHeight = minHeight or buildingMinHeight
878+
879+
local levels = tonumber(Find("levels"), 10)
880+
local buildingLevels = tonumber(Find("building:levels"), 10)
881+
local finalLevels = levels or buildingLevels
882+
883+
local minLevel = tonumber(Find("min_level"), 10)
884+
local buildingMinLevel = tonumber(Find("building:min_level"), 10)
885+
local finalMinLevel = minLevel or buildingMinLevel
874886

875887
local renderHeight = BUILDING_FLOOR_HEIGHT
876-
if height or levels then
877-
renderHeight = height or (levels * BUILDING_FLOOR_HEIGHT)
888+
if finalHeight or finalLevels then
889+
renderHeight = finalHeight or (finalLevels * BUILDING_FLOOR_HEIGHT)
878890
end
879891
local renderMinHeight = 0
880-
if minHeight or minLevel then
881-
renderMinHeight = minHeight or (minLevel * BUILDING_FLOOR_HEIGHT)
892+
if finalMinHeight or finalMinLevel then
893+
renderMinHeight = finalMinHeight or (finalMinLevel * BUILDING_FLOOR_HEIGHT)
882894
end
883895

884896
-- Fix upside-down buildings

server/static/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
style: styleURL, // stylesheet location
3333
center: [(Number(bounds[0])+Number(bounds[2]))/2,
3434
(Number(bounds[1])+Number(bounds[3]))/2], // starting position [lng, lat]
35-
zoom: 13 // starting zoom
35+
zoom: 13, // starting zoom
36+
pitch: 60 // pitch in degrees
3637
});
3738
map.addControl(new mapboxgl.NavigationControl());
3839
map.addControl(new mapboxgl.AttributionControl({ compact: false, customAttribution:

server/static/style.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,23 +366,29 @@
366366
"metadata": {"mapbox:group": "1444849364238.8171"},
367367
"source": "openmaptiles",
368368
"source-layer": "building",
369+
"minzoom": 13,
370+
"maxzoom": 21,
371+
"layout": {
372+
"visibility": "visible"
373+
},
369374
"paint": {
370-
"fill-antialias": true,
371-
"fill-color": {"base": 1, "stops": [[15.5, "#f2eae2"], [16, "#dfdbd7"]]}
375+
"fill-color": "rgba(203, 198, 198, 1)",
376+
"fill-outline-color": {"base": 1, "stops": [[13,"rgba(131, 123, 123, 0.32)"], [14,"rgba(157, 3, 5, 1)"]]}
372377
}
373378
},
374379
{
375-
"id": "building-top",
376-
"type": "fill",
380+
"id": "building-3d",
381+
"type": "fill-extrusion",
377382
"metadata": {"mapbox:group": "1444849364238.8171"},
378383
"source": "openmaptiles",
379384
"source-layer": "building",
385+
"minzoom": 14,
380386
"layout": {"visibility": "visible"},
381387
"paint": {
382-
"fill-color": "#f2eae2",
383-
"fill-opacity": {"base": 1, "stops": [[13, 0], [16, 1]]},
384-
"fill-outline-color": "#dfdbd7",
385-
"fill-translate": {"base": 1, "stops": [[14, [0, 0]], [16, [-2, -2]]]}
388+
"fill-extrusion-color": "rgba(203, 198, 198, 1)",
389+
"fill-extrusion-height": {"property": "render_height","type": "identity"},
390+
"fill-extrusion-base": {"property": "render_min_height","type": "identity"},
391+
"fill-extrusion-opacity": 0.9
386392
}
387393
},
388394
{

0 commit comments

Comments
 (0)