Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4830 debug tiles #7314

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/render/draw_debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function drawDebug(painter: Painter, sourceCache: SourceCache, coords: Array<Ove
}
}

function drawDebugTile(painter, sourceCache, coord) {
function drawDebugTile(painter, sourceCache, coord: OverscaledTileID) {
const context = painter.context;
const gl = context.gl;

Expand All @@ -45,7 +45,11 @@ function drawDebugTile(painter, sourceCache, coord) {
const tileSizeKb = Math.floor(tileByteLength / 1024);
const tileSize = sourceCache.getTile(coord).tileSize;
const scaleRatio = 512 / Math.min(tileSize, 512);
const vertices = createTextVertices(`${coord.toString()} ${tileSizeKb}kb`, 50, 200 * scaleRatio, 5 * scaleRatio);
let tileIdText = coord.canonical.toString();
if (coord.overscaledZ !== coord.canonical.z) {
tileIdText += ` => ${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) {
Expand Down
20 changes: 17 additions & 3 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Use a for..of?

Also would it be possible to clean up the loop somehow? seems its a bit unnecessarily complex for what it needs to do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified it a good bit 👍

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this has become moot as we've reverted to the original forEach, but for future reference just noting here that IE can't handle for...of 😬

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());
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/source/tile_id.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Binary file modified test/integration/render-tests/debug/tile-overscaled/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/integration/render-tests/debug/tile/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions test/integration/render-tests/debug/tile/style.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -30,6 +38,14 @@
"background-color": "white"
}
},
{
"id": "raster",
"type": "raster",
"source": "satellite",
"paint": {
"raster-fade-duration": 0
}
},
{
"id": "line",
"type": "symbol",
Expand Down