Skip to content

Commit b57d7db

Browse files
committed
feat: export and render building:part
1 parent 07e878f commit b57d7db

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
@@ -356,6 +356,7 @@ function way_function()
356356
local housenumber = Find("addr:housenumber")
357357
local write_name = false
358358
local construction = Find("construction")
359+
local building_part = Find("building:part")
359360

360361
-- Miscellaneous preprocessing
361362
if Find("disused") == "yes" then return end
@@ -568,7 +569,7 @@ function way_function()
568569
end
569570

570571
-- Set 'building' and associated
571-
if building~="" then
572+
if building~="" or building_part~="" then
572573
Layer("building", true)
573574
SetBuildingHeightAttributes()
574575
SetMinZoomByArea()
@@ -773,17 +774,28 @@ end
773774

774775
function SetBuildingHeightAttributes()
775776
local height = tonumber(Find("height"), 10)
777+
local buildingHeight = tonumber(Find("building:height"), 10)
778+
local finalHeight = height or buildingHeight
779+
776780
local minHeight = tonumber(Find("min_height"), 10)
777-
local levels = tonumber(Find("building:levels"), 10)
778-
local minLevel = tonumber(Find("building:min_level"), 10)
781+
local buildingMinHeight = tonumber(Find("building:min_height"), 10)
782+
local finalMinHeight = minHeight or buildingMinHeight
783+
784+
local levels = tonumber(Find("levels"), 10)
785+
local buildingLevels = tonumber(Find("building:levels"), 10)
786+
local finalLevels = levels or buildingLevels
787+
788+
local minLevel = tonumber(Find("min_level"), 10)
789+
local buildingMinLevel = tonumber(Find("building:min_level"), 10)
790+
local finalMinLevel = minLevel or buildingMinLevel
779791

780792
local renderHeight = BUILDING_FLOOR_HEIGHT
781-
if height or levels then
782-
renderHeight = height or (levels * BUILDING_FLOOR_HEIGHT)
793+
if finalHeight or finalLevels then
794+
renderHeight = finalHeight or (finalLevels * BUILDING_FLOOR_HEIGHT)
783795
end
784796
local renderMinHeight = 0
785-
if minHeight or minLevel then
786-
renderMinHeight = minHeight or (minLevel * BUILDING_FLOOR_HEIGHT)
797+
if finalMinHeight or finalMinLevel then
798+
renderMinHeight = finalMinHeight or (finalMinLevel * BUILDING_FLOOR_HEIGHT)
787799
end
788800

789801
-- 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)