Skip to content

Commit bfc9a33

Browse files
dcojgithub-actions[bot]
authored andcommitted
Restore snapshot to fix flaky render test after rework.
GitOrigin-RevId: f207f96b8ad5209fd472fff14fc78963d2bf5864
1 parent 0b8c3a9 commit bfc9a33

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/source/building_index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,28 @@ class BuildingIndex {
114114
}
115115
}
116116

117+
/**
118+
* Returns true if any building layer tracked by this index is backed by
119+
* the source cache with the given `sourceCacheId`. Used to detect when a
120+
* fill-extrusion tile has finished loading so that a full label-placement
121+
* pass can be requested: symbol z-offsets depend on building heights, so
122+
* placement must re-run whenever new building data arrives.
123+
*
124+
* @param {string} sourceCacheId - The FQID of the source cache to check.
125+
* @returns {boolean} `true` if a tracked building layer uses this cache.
126+
* @example
127+
* if (buildingIndex.hasLayerForSourceCache(event.sourceCacheId)) { ... }
128+
*/
129+
hasLayerForSourceCache(sourceCacheId: string): boolean {
130+
for (const {layer} of this.layers) {
131+
const sourceCache = this.style.getLayerSourceCache(layer);
132+
if (sourceCache && sourceCache.id === sourceCacheId) {
133+
return true;
134+
}
135+
}
136+
return false;
137+
}
138+
117139
_mapCoordToOverlappingTile(
118140
tid: OverscaledTileID,
119141
x: number,

src/ui/map.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4364,6 +4364,18 @@ export class Map extends Camera {
43644364
if (elevationSource && event.sourceCacheId === elevationSource.id && this.style) {
43654365
this.style._setLabelPlacementStale();
43664366
}
4367+
// Force a full label re-placement when a fill-extrusion (building)
4368+
// tile loads. Symbol z-offsets are computed from building heights
4369+
// during placement, so if a building tile arrives after the initial
4370+
// placement pass (a common race when the symbol source is GeoJSON
4371+
// but buildings come from a separate vector tile source) the
4372+
// collision boxes and elevated symbol positions will be wrong.
4373+
// Re-running placement after the building data arrives ensures
4374+
// symbols appear at the correct elevation.
4375+
if (this.style && event.sourceCacheId &&
4376+
this.style._buildingIndex.hasLayerForSourceCache(event.sourceCacheId)) {
4377+
this.style._requestFullLabelPlacement();
4378+
}
43674379
this.painter.setTileLoadedFlag(true);
43684380
}
43694381
});

test/integration/render-tests/symbol-elevation/z-elevation-with-sort-by-viewport-y-and-collision-boxes/style.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"width": 256,
77
"height": 256,
88
"operations": [
9+
["waitFrameReady"]
910
],
1011
"image-threshold": [
1112
{"platform-tag-contains": "", "threshold": 0.0035}

0 commit comments

Comments
 (0)