diff --git a/src/render/draw_debug.js b/src/render/draw_debug.js index 16fe2c9067d..56cb6cfc473 100644 --- a/src/render/draw_debug.js +++ b/src/render/draw_debug.js @@ -24,7 +24,7 @@ function drawDebug(painter: Painter, sourceCache: SourceCache, coords: Array ${coord.overscaledZ}`; + } + const vertices = createTextVertices(`${tileIdText} ${tileSizeKb}kb`, 50, 200 * scaleRatio, 5 * scaleRatio); const debugTextArray = new PosArray(); const debugTextIndices = new LineIndexArray(); for (let v = 0; v < vertices.length; v += 2) { diff --git a/src/render/painter.js b/src/render/painter.js index cd6d894280d..b7cf3fe292e 100644 --- a/src/render/painter.js +++ b/src/render/painter.js @@ -8,6 +8,7 @@ import EXTENT from '../data/extent'; import pixelsToTileUnits from '../source/pixels_to_tile_units'; import SegmentVector from '../data/segment'; import {RasterBoundsArray, PosArray, TriangleIndexArray, LineStripIndexArray} from '../data/array_types'; +import {values} from '../util/util'; import rasterBoundsAttributes from '../data/raster_bounds_attributes'; import posAttributes from '../data/pos_attributes'; import ProgramConfiguration from '../data/program_configuration'; @@ -431,9 +432,22 @@ class Painter { } if (this.options.showTileBoundaries) { - for (const id in sourceCaches) { - draw.debug(this, sourceCaches[id], coordsAscending[id]); - break; + //Use source with highest maxzoom + let selectedSource; + let sourceCache; + const layers = values(this.style._layers); + layers.forEach((layer) => { + if (layer.source && !layer.isHidden(this.transform.zoom)) { + if (layer.source !== (sourceCache && sourceCache.id)) { + sourceCache = this.style.sourceCaches[layer.source]; + } + if (!selectedSource || (selectedSource.getSource().maxzoom < sourceCache.getSource().maxzoom)) { + selectedSource = sourceCache; + } + } + }); + if (selectedSource) { + draw.debug(this, selectedSource, selectedSource.getVisibleCoordinates()); } } diff --git a/src/source/tile_id.js b/src/source/tile_id.js index 16d06f97254..9d39d3eae7b 100644 --- a/src/source/tile_id.js +++ b/src/source/tile_id.js @@ -48,6 +48,10 @@ export class CanonicalTileID { (coord.x * tilesAtZoom - this.x) * EXTENT, (coord.y * tilesAtZoom - this.y) * EXTENT); } + + toString() { + return `${this.z}/${this.x}/${this.y}`; + } } export class UnwrappedTileID { diff --git a/test/integration/render-tests/debug/tile-overscaled/expected.png b/test/integration/render-tests/debug/tile-overscaled/expected.png index 1d123bd64a3..35c9ba41f54 100644 Binary files a/test/integration/render-tests/debug/tile-overscaled/expected.png and b/test/integration/render-tests/debug/tile-overscaled/expected.png differ diff --git a/test/integration/render-tests/debug/tile/expected.png b/test/integration/render-tests/debug/tile/expected.png index 03993d0c483..15f1d78f1e0 100644 Binary files a/test/integration/render-tests/debug/tile/expected.png and b/test/integration/render-tests/debug/tile/expected.png differ diff --git a/test/integration/render-tests/debug/tile/style.json b/test/integration/render-tests/debug/tile/style.json index cd2240afff3..3188f1a0d63 100644 --- a/test/integration/render-tests/debug/tile/style.json +++ b/test/integration/render-tests/debug/tile/style.json @@ -12,6 +12,14 @@ ], "zoom": 14, "sources": { + "satellite": { + "type": "raster", + "tiles": [ + "local://tiles/{z}-{x}-{y}.satellite.png" + ], + "maxzoom": 1, + "tileSize": 256 + }, "mapbox": { "type": "vector", "maxzoom": 14, @@ -30,6 +38,14 @@ "background-color": "white" } }, + { + "id": "raster", + "type": "raster", + "source": "satellite", + "paint": { + "raster-fade-duration": 0 + } + }, { "id": "line", "type": "symbol",