Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export and render building:part #692

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions resources/process-openmaptiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ function way_function()
local write_name = false
local construction = Find("construction")
local is_highway_area = highway~="" and Find("area")=="yes" and is_closed
local building_part = Find("building:part")

-- Miscellaneous preprocessing
if Find("disused") == "yes" then return end
Expand Down Expand Up @@ -645,7 +646,7 @@ function way_function()
end

-- Set 'building' and associated
if building~="" then
if building~="" or building_part~="" then
Layer("building", true)
SetBuildingHeightAttributes()
SetMinZoomByArea()
Expand Down Expand Up @@ -868,17 +869,28 @@ end

function SetBuildingHeightAttributes()
local height = tonumber(Find("height"), 10)
local buildingHeight = tonumber(Find("building:height"), 10)
local finalHeight = height or buildingHeight

local minHeight = tonumber(Find("min_height"), 10)
local levels = tonumber(Find("building:levels"), 10)
local minLevel = tonumber(Find("building:min_level"), 10)
local buildingMinHeight = tonumber(Find("building:min_height"), 10)
local finalMinHeight = minHeight or buildingMinHeight

local levels = tonumber(Find("levels"), 10)
local buildingLevels = tonumber(Find("building:levels"), 10)
local finalLevels = levels or buildingLevels

local minLevel = tonumber(Find("min_level"), 10)
local buildingMinLevel = tonumber(Find("building:min_level"), 10)
local finalMinLevel = minLevel or buildingMinLevel

local renderHeight = BUILDING_FLOOR_HEIGHT
if height or levels then
renderHeight = height or (levels * BUILDING_FLOOR_HEIGHT)
if finalHeight or finalLevels then
renderHeight = finalHeight or (finalLevels * BUILDING_FLOOR_HEIGHT)
end
local renderMinHeight = 0
if minHeight or minLevel then
renderMinHeight = minHeight or (minLevel * BUILDING_FLOOR_HEIGHT)
if finalMinHeight or finalMinLevel then
renderMinHeight = finalMinHeight or (finalMinLevel * BUILDING_FLOOR_HEIGHT)
end

-- Fix upside-down buildings
Expand Down
3 changes: 2 additions & 1 deletion server/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
style: styleURL, // stylesheet location
center: [(Number(bounds[0])+Number(bounds[2]))/2,
(Number(bounds[1])+Number(bounds[3]))/2], // starting position [lng, lat]
zoom: 13 // starting zoom
zoom: 13, // starting zoom
pitch: 60 // pitch in degrees
});
map.addControl(new mapboxgl.NavigationControl());
map.addControl(new mapboxgl.AttributionControl({ compact: false, customAttribution:
Expand Down
22 changes: 14 additions & 8 deletions server/static/style.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,23 +366,29 @@
"metadata": {"mapbox:group": "1444849364238.8171"},
"source": "openmaptiles",
"source-layer": "building",
"minzoom": 13,
"maxzoom": 21,
"layout": {
"visibility": "visible"
},
"paint": {
"fill-antialias": true,
"fill-color": {"base": 1, "stops": [[15.5, "#f2eae2"], [16, "#dfdbd7"]]}
"fill-color": "rgba(203, 198, 198, 1)",
"fill-outline-color": {"base": 1, "stops": [[13,"rgba(131, 123, 123, 0.32)"], [14,"rgba(157, 3, 5, 1)"]]}
}
},
{
"id": "building-top",
"type": "fill",
"id": "building-3d",
"type": "fill-extrusion",
"metadata": {"mapbox:group": "1444849364238.8171"},
"source": "openmaptiles",
"source-layer": "building",
"minzoom": 14,
"layout": {"visibility": "visible"},
"paint": {
"fill-color": "#f2eae2",
"fill-opacity": {"base": 1, "stops": [[13, 0], [16, 1]]},
"fill-outline-color": "#dfdbd7",
"fill-translate": {"base": 1, "stops": [[14, [0, 0]], [16, [-2, -2]]]}
"fill-extrusion-color": "rgba(203, 198, 198, 1)",
"fill-extrusion-height": {"property": "render_height","type": "identity"},
"fill-extrusion-base": {"property": "render_min_height","type": "identity"},
"fill-extrusion-opacity": 0.9
}
},
{
Expand Down