Skip to content

Commit 8f0998d

Browse files
andrewharveyRyan Hamley
authored andcommitted
fix tile debug rendering on satellite tiles (mapbox#8380)
1 parent f818169 commit 8f0998d

3 files changed

Lines changed: 64 additions & 4 deletions

File tree

src/render/draw_debug.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ function drawDebugTile(painter, sourceCache, coord) {
4343
const tileRawData = sourceCache.getTileByID(coord.key).latestRawTileData;
4444
const tileByteLength = (tileRawData && tileRawData.byteLength) || 0;
4545
const tileSizeKb = Math.floor(tileByteLength / 1024);
46-
const vertices = createTextVertices(`${coord.toString()} ${tileSizeKb}kb`, 50, 200, 5);
46+
const tileSize = sourceCache.getTile(coord).tileSize;
47+
const scaleRatio = 512 / Math.min(tileSize, 512);
48+
const vertices = createTextVertices(`${coord.toString()} ${tileSizeKb}kb`, 50, 200 * scaleRatio, 5 * scaleRatio);
4749
const debugTextArray = new PosArray();
4850
const debugTextIndices = new LineIndexArray();
4951
for (let v = 0; v < vertices.length; v += 2) {
@@ -56,9 +58,21 @@ function drawDebugTile(painter, sourceCache, coord) {
5658

5759
// Draw the halo with multiple 1px lines instead of one wider line because
5860
// the gl spec doesn't guarantee support for lines with width > 1.
59-
const tileSize = sourceCache.getTile(coord).tileSize;
60-
const onePixel = EXTENT / (Math.pow(2, painter.transform.zoom - coord.overscaledZ) * tileSize);
61-
const translations = [[-1, -1], [-1, 1], [1, -1], [1, 1]];
61+
const onePixel = EXTENT / (Math.pow(2, painter.transform.zoom - coord.overscaledZ) * tileSize * scaleRatio);
62+
63+
const haloWidth = 1;
64+
const translations = [];
65+
for (let x = -haloWidth; x <= haloWidth; x++) {
66+
for (let y = -haloWidth; y <= haloWidth; y++) {
67+
if (x === 0 && y === 0) {
68+
// don't draw the halo at 0,0 since the text is drawn there
69+
break;
70+
}
71+
72+
translations.push([x, y]);
73+
}
74+
}
75+
6276
for (let i = 0; i < translations.length; i++) {
6377
const translation = translations[i];
6478

290 KB
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"debug": true,
6+
"height": 256
7+
}
8+
},
9+
"center": [
10+
13.418056,
11+
52.499167
12+
],
13+
"zoom": 16,
14+
"sources": {
15+
"satellite": {
16+
"type": "raster",
17+
"tiles": [
18+
"local://tiles/{z}-{x}-{y}.satellite.png"
19+
],
20+
"maxzoom": 17,
21+
"tileSize": 256
22+
}
23+
},
24+
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
25+
"sprite": "local://sprites/sprite",
26+
"layers": [
27+
{
28+
"id": "background",
29+
"type": "background",
30+
"paint": {
31+
"background-color": "white"
32+
}
33+
},
34+
{
35+
"id": "raster",
36+
"type": "raster",
37+
"source": "satellite",
38+
"layout": {
39+
},
40+
"paint": {
41+
"raster-opacity": 1,
42+
"raster-fade-duration": 0
43+
}
44+
}
45+
]
46+
}

0 commit comments

Comments
 (0)