Skip to content

Commit 1165bd2

Browse files
akoylasargithub-actions[bot]
authored andcommitted
[MAPS3D-1952] Introduce building-facade-unit-width (internal-6170)
GitOrigin-RevId: 5591e21091a496d2b702808393ba18ff1bec1793
1 parent 2c1a083 commit 1165bd2

File tree

7 files changed

+179
-3
lines changed

7 files changed

+179
-3
lines changed

3d-style/data/bucket/building_bucket.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ export class BuildingBucket implements BucketWithGroundEffect {
402402
endPositionTile = height / tileToMeters;
403403
startPositionTile = Math.min(startPositionTile, endPositionTile);
404404

405-
const floorWidths = [3.1, 5.3, 10.5, 20.0];
406-
floorXTile = floorWidths[feature.id ? feature.id % floorWidths.length : 0] / tileToMeters;
405+
const unitWidth = layer.layout.get('building-facade-unit-width').evaluate(feature, {}, canonical);
406+
floorXTile = unitWidth / tileToMeters;
407407
floorYTile = (endPositionTile - startPositionTile) / numFloors;
408408

409409
buildingGen.setFauxFacadeOptions(true, true, floorXTile);

3d-style/style/style_layer/building_style_layer_properties.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type LayoutProps = {
2020
"visibility": DataConstantProperty<"visible" | "none">;
2121
"building-facade": DataDrivenProperty<boolean>;
2222
"building-facade-floors": DataDrivenProperty<number>;
23+
"building-facade-unit-width": DataDrivenProperty<number>;
2324
"building-facade-window": DataDrivenProperty<[number, number]>;
2425
"building-roof-shape": DataDrivenProperty<"flat" | "hipped" | "gabled" | "parapet" | "mansard" | "skillion" | "pyramidal">;
2526
"building-height": DataDrivenProperty<number>;
@@ -30,6 +31,7 @@ export const getLayoutProperties = (): Properties<LayoutProps> => layout || (lay
3031
"visibility": new DataConstantProperty(styleSpec["layout_building"]["visibility"]),
3132
"building-facade": new DataDrivenProperty(styleSpec["layout_building"]["building-facade"]),
3233
"building-facade-floors": new DataDrivenProperty(styleSpec["layout_building"]["building-facade-floors"]),
34+
"building-facade-unit-width": new DataDrivenProperty(styleSpec["layout_building"]["building-facade-unit-width"]),
3335
"building-facade-window": new DataDrivenProperty(styleSpec["layout_building"]["building-facade-window"]),
3436
"building-roof-shape": new DataDrivenProperty(styleSpec["layout_building"]["building-roof-shape"]),
3537
"building-height": new DataDrivenProperty(styleSpec["layout_building"]["building-height"]),

debug/procedural-buildings.standard.fragment.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@
253253
]
254254
]
255255
],
256+
"building-facade-unit-width": [
257+
"at",
258+
["%", ["to-number", ["id"], 0], 4],
259+
[3.1, 5.3, 10.5, 20.0]
260+
],
256261
"building-facade-window": [
257262
"case",
258263
[

src/style-spec/reference/v8.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,14 +2100,36 @@
21002100
"building-facade"
21012101
]
21022102
},
2103+
"building-facade-unit-width": {
2104+
"type": "number",
2105+
"minimum": 1.0,
2106+
"maximum": 20.0,
2107+
"default": 3.1,
2108+
"doc": "Width of a floor. Think of this as measure how wide each unit should be. This effectively determines the number of units per each floor. Note that this does not affect the ground level facades (i.e. number of windows).",
2109+
"experimental": true,
2110+
"property-type": "data-driven",
2111+
"sdk-support": {
2112+
"basic functionality": {},
2113+
"data-driven styling": {}
2114+
},
2115+
"expression": {
2116+
"interpolated": false,
2117+
"parameters": [
2118+
"feature"
2119+
]
2120+
},
2121+
"requires": [
2122+
"building-facade"
2123+
]
2124+
},
21032125
"building-facade-window": {
21042126
"type": "array",
21052127
"length": 2,
21062128
"value": "number",
21072129
"minimum": 0.1,
21082130
"maximum": 1.0,
21092131
"default": [0.9, 0.9],
2110-
"doc": "Given as fractions, specifies the percentage of floor area covered by windows when building-facade is enabled",
2132+
"doc": "Given as fractions, specifies the percentage of unit area covered by windows when building-facade is enabled. Note that the area of a unit is ultimately determined by `building-facade-unit-width` and `building-facade-floors`.",
21112133
"experimental": true,
21122134
"property-type": "data-driven",
21132135
"sdk-support": {

src/style-spec/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,10 @@ export type BuildingLayerSpecification = {
10991099
* @experimental This property is experimental and subject to change in future versions.
11001100
*/
11011101
"building-facade-floors"?: DataDrivenPropertyValueSpecification<number>,
1102+
/**
1103+
* @experimental This property is experimental and subject to change in future versions.
1104+
*/
1105+
"building-facade-unit-width"?: DataDrivenPropertyValueSpecification<number>,
11021106
/**
11031107
* @experimental This property is experimental and subject to change in future versions.
11041108
*/
4.91 KB
Loading
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"allowed": 0.0019,
6+
"height": 256,
7+
"width": 256,
8+
"operations": []
9+
}
10+
},
11+
"lights": [
12+
{
13+
"type": "ambient",
14+
"id": "environment",
15+
"properties": {
16+
"intensity": 0.4
17+
}
18+
},
19+
{
20+
"type": "directional",
21+
"id": "sun_light",
22+
"properties": {
23+
"intensity": 0.6,
24+
"direction": [
25+
15,
26+
30
27+
]
28+
}
29+
}
30+
],
31+
"sources": {
32+
"geojson": {
33+
"type": "geojson",
34+
"data": {
35+
"type": "FeatureCollection",
36+
"features": [
37+
{
38+
"type": "Feature",
39+
"properties": {
40+
},
41+
"geometry": {
42+
"coordinates": [
43+
[
44+
[
45+
11.568937291974436,
46+
48.13246952281412
47+
],
48+
[
49+
11.568937291974436,
50+
48.132286810394845
51+
],
52+
[
53+
11.56931009612731,
54+
48.132286810394845
55+
],
56+
[
57+
11.56931009612731,
58+
48.13246952281412
59+
],
60+
[
61+
11.568937291974436,
62+
48.13246952281412
63+
]
64+
]
65+
],
66+
"type": "Polygon"
67+
}
68+
}
69+
]
70+
}
71+
}
72+
},
73+
"bearing": -45,
74+
"pitch": 60,
75+
"zoom": 18,
76+
"center": [
77+
11.5690308,
78+
48.1324576
79+
],
80+
"layers": [
81+
{
82+
"id": "background",
83+
"type": "background",
84+
"paint": {
85+
"background-color": "white"
86+
}
87+
},
88+
{
89+
"id": "building",
90+
"type": "building",
91+
"source": "geojson",
92+
"minzoom": 17,
93+
"layout": {
94+
"building-facade": true,
95+
"building-roof-shape": "parapet",
96+
"building-facade-floors": 4,
97+
"building-facade-unit-width": 5.1,
98+
"building-facade-window": [
99+
0.9,
100+
0.8
101+
],
102+
"building-base": 0,
103+
"building-height": 20
104+
},
105+
"paint": {
106+
"building-color": [
107+
"match",
108+
[
109+
"get",
110+
"building-part"
111+
],
112+
"wall",
113+
[
114+
"hsl",
115+
41,
116+
90,
117+
90
118+
],
119+
"roof",
120+
[
121+
"hsl",
122+
25,
123+
43,
124+
80
125+
],
126+
"window",
127+
[
128+
"hsl",
129+
186,
130+
35.3,
131+
67.3
132+
],
133+
[
134+
"hsl",
135+
41,
136+
90,
137+
90
138+
]
139+
]
140+
}
141+
}
142+
]
143+
}

0 commit comments

Comments
 (0)