Skip to content

Commit 061331a

Browse files
akoylasargithub-actions[bot]
authored andcommitted
Avoid reparsing overscaled procedural buildings layer tiles (internal-8230)
GitOrigin-RevId: 4bbeb816b496fcf6894d3abb58dba9c2af89fafe
1 parent 8342871 commit 061331a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/style/style.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ class Style extends Evented<MapEvents> {
361361
_has3DLayers: boolean;
362362
_hasCircleLayers: boolean;
363363
_hasSymbolLayers: boolean;
364+
_hasBuildingLayers: boolean;
364365

365366
_worldview: string | undefined;
366367
_hasAppearances: boolean;
@@ -406,6 +407,7 @@ class Style extends Evented<MapEvents> {
406407
this._has3DLayers = false;
407408
this._hasCircleLayers = false;
408409
this._hasSymbolLayers = false;
410+
this._hasBuildingLayers = false;
409411

410412
this._importedAsBasemap = false;
411413

@@ -1152,6 +1154,7 @@ class Style extends Evented<MapEvents> {
11521154
this._has3DLayers = false;
11531155
this._hasCircleLayers = false;
11541156
this._hasSymbolLayers = false;
1157+
this._hasBuildingLayers = false;
11551158

11561159
this.forEachFragmentStyle((style: Style) => {
11571160
for (const layerId of style._order) {
@@ -1194,6 +1197,7 @@ class Style extends Evented<MapEvents> {
11941197
if (layer.type === 'circle') this._hasCircleLayers = true;
11951198
if (layer.type === 'symbol') this._hasSymbolLayers = true;
11961199
if (layer.type === 'clip') this._clipLayerPresent = true;
1200+
if (layer.type === 'building') this._hasBuildingLayers = true;
11971201
}
11981202
}
11991203
};
@@ -4078,17 +4082,28 @@ class Style extends Evented<MapEvents> {
40784082
if (this.directionalLight) {
40794083
lightDirection = shadowDirectionFromProperties(this.directionalLight);
40804084
}
4085+
4086+
// Hack to ensure that for procedural buildings we don't reparse the tile on zoom levels
4087+
// above source maxzoom. Here we assume that building layer has its own separate source.
4088+
const sourcesForBuildingLayers: Set<string> = new Set();
40814089
// Find sources with elevated layers
40824090
const sourcesWithElevatedLayers: Set<string> = new Set();
40834091
for (const id in this._mergedLayers) {
40844092
const layer = this._mergedLayers[id];
4093+
if (layer.type === 'building') {
4094+
sourcesForBuildingLayers.add(layer.source);
4095+
}
40854096
if (layer.hasElevation() && !sourcesWithElevatedLayers.has(layer.source)) {
40864097
sourcesWithElevatedLayers.add(layer.source);
40874098
}
40884099
}
4100+
40894101
for (const id in this._mergedSourceCaches) {
40904102
const sourceCache = this._mergedSourceCaches[id];
40914103
const elevatedLayers = sourcesWithElevatedLayers.has(sourceCache._source.id);
4104+
if (sourcesForBuildingLayers.has(sourceCache._source.id)) {
4105+
sourceCache._source.reparseOverscaled = false;
4106+
}
40924107
sourceCache.update(transform, undefined, undefined, lightDirection, elevatedLayers);
40934108
}
40944109
}

0 commit comments

Comments
 (0)